wiretap icon indicating copy to clipboard operation
wiretap copied to clipboard

feature request: validate request based on examples

Open TristanSpeakEasy opened this issue 1 year ago • 2 comments

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

TristanSpeakEasy avatar Jan 29 '24 12:01 TristanSpeakEasy

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 )

LasneF avatar Feb 16 '24 13:02 LasneF

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

TristanSpeakEasy avatar Feb 16 '24 15:02 TristanSpeakEasy