codekie / openapi-examples-validator

Validates embedded examples in OpenAPI-files
MIT License
57 stars 11 forks source link

External examples #127

Closed gap777 closed 3 years ago

gap777 commented 3 years ago

I'm confused about the validation provided for external examples.

Our end point snippet:

     ...
     responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Schema1'
              examples:
                ex1:
                  $ref: "examples/example1.json"

If the example has, for example, and incorrect value type for a property, openapi-examples-validator properly detects it:

Validating examples
Schemas with examples found: 5
Examples without schema found: 28
Total examples found: 73

Errors found.

[
    {
        "type": "Validation",
        "message": "should be string",
        "keyword": "type",
        "dataPath": ".data[0].foo.bar",
        "schemaPath": "#/allOf/1/properties/data/items/allOf/0/properties/thing/allOf/0/properties/thang/type",
        "params": {
            "type": "string"
        },
        "examplePath": "/paths/~1a~1b~1jc~1{id}~1d/get/responses/200/content/application~1json/examples/ex1/value"
    }

However, when my example is missing required properties (which are listed in the schema's required list), no errors are flagged.

codekie commented 3 years ago

Please provide a Minimal, Reproducible Example and the command you used, with all arguments.

codekie commented 3 years ago

Closing this, as there was no response after a month.