Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: validate request based on examples #95

Open
TristanSpeakEasy opened this issue Jan 29, 2024 · 2 comments
Open

feature request: validate request based on examples #95

TristanSpeakEasy opened this issue Jan 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@TristanSpeakEasy
Copy link

would be great if wiretap could validate the request included values that matched the examples in the spec.

Some way to configure wiretap to turn on example validation and ensure that the request contained one of the examples

@LasneF
Copy link

LasneF commented Feb 16, 2024

not sure to understand ,
example are validated against schema in vacuum

do you want to have API with no schema but just example and create a schema on the fly from the example (usually not super clean , cf enum and constrains , but enough for canvas )

@TristanSpeakEasy
Copy link
Author

So wiretap currently validates that a request (parameters, body, etc) match the schema in your OpenAPI document.

But I would also like to turn on a mode where it ensures that the values sent exist in the examples keyword of the schema.

For example for a schema like:

schema:
  type: object
  properties:
    test:
      type: string
      examples:
        - "some example 1"
        - "another example"

and a body like:

{
  "test": "some value that doesn't match examples"
}

wiretap would return a validation error.

My use case is we are writing some tests around wiretap as a mock server and it would be good if it could help us validate that we serialized the data correctly and serialized it to an expected value

@daveshanley daveshanley added the enhancement New feature or request label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants