cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

angeschw opened this issue · 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