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

Request body schema validations are skipped when using multiple external refs #906

Open
hiuxmaycry opened this issue Mar 1, 2024 · 0 comments

Comments

@hiuxmaycry
Copy link
Contributor

Describe the bug
When you use schemas that are defined in an external file and try to reuse this schema several times, the validations to the schema are completely ignored

To Reproduce
Create a an external file external.ref.yaml with the next content:

NewPet:
  type: object
  additionalProperties: false
  required:
    - name
  properties:
    name:
      type: string
      nullable: true
    tag:
      type: string

And then create a simple API with the next 2 post paths:

/pets1:
    post:
      operationId: addPet1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: external.ref.yaml#/NewPet
      responses:
        '200':
          description: pet response
          content:
            application/json: {}

  /pets2:
    post:
      operationId: addPet2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: external.ref.yaml#/NewPet
      responses:
        '200':
          description: pet response
          content:
            application/json: {}

Actual behavior
See that the schema validations for post1 and post2 are not applied.

Expected behavior
Validations that are defined in the API should be applied.

Fox example, sending to POST to /pets1 with body { "name": null } should fail

Examples and context
See last commit from this repo to reproduce the error, there are 2 new tests failing due to this bug https://github.com/hiuxmaycry/express-openapi-validator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant