express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Multiple `example` set in OpenAPI schema doesn't work

Open angeschw opened this issue 1 year ago • 0 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior.

Create an OpenAPI schema 3.0.0. Use a repeated component in various responses.

// first path has a response with component
      responses:
        201:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyRepeatedObject'
              example:
                id: 'mock_id'
                name: 'repeated_object_name'

// a different path later in the same file
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyRepeatedObject'
              example:
                id: 'mock_id_2'
                name: 'repeated_object_name_2'

Actual behavior A clear and concise description of what happens.

Presence of 1 example builds + validates fine. Presence of 2 example fails with no clear error from express-openapi-validator. error: {}

Expected behavior A clear and concise description of what you expected to happen.

Multiple examples should be allowed

Examples and context An example or relevant context e.g. an OpenAPI snippet, an Express handler function snippet

angeschw avatar Apr 25 '24 17:04 angeschw