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

Multiple specs are not supported #900

Closed
mzbik opened this issue Feb 4, 2024 · 1 comment
Closed

Multiple specs are not supported #900

mzbik opened this issue Feb 4, 2024 · 1 comment

Comments

@mzbik
Copy link
Contributor

mzbik commented Feb 4, 2024

Adding a second api spec (per express-openapi-validator/examples/2-standard-multiple-api-specs), results in API returns from the second set of API being validated against the schema in the first set.

This is easily reproducible by editing express-openapi-validator/examples/2-standard-multiple-api-specs/app.js to enable response validation. E.g.,

  app.use(
    OpenApiValidator.middleware({
      apiSpec: apiSpec,
      validateResponses: true,
    }),
  );

Running curl 'localhost:3000/v2/pets?pet_type=kitty' | jq shows schema violations reported against the v1 schema:

{
  "message": ".response[0] should have required property 'id', .response[0] should have required property 'name', .response[0] should have required property 'type'",
  "errors": [
    {
      "path": ".response[0].id",
      "message": "should have required property 'id'",
      "errorCode": "required.openapi.validation"
    },
    {
      "path": ".response[0].name",
      "message": "should have required property 'name'",
      "errorCode": "required.openapi.validation"
    },
    {
      "path": ".response[0].type",
      "message": "should have required property 'type'",
      "errorCode": "required.openapi.validation"
    }
  ]
}

Note: I encountered this in my project where an embedded $ref was used to look up a schema against a set of paths from a >previous< apiDoc.

@mzbik
Copy link
Contributor Author

mzbik commented Feb 4, 2024

Dup of #881

@mzbik mzbik closed this as completed Feb 4, 2024
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