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

Modeling inheritance does not work in validation #719

Open
danielwinkler opened this issue May 8, 2023 · 1 comment
Open

Modeling inheritance does not work in validation #719

danielwinkler opened this issue May 8, 2023 · 1 comment

Comments

@danielwinkler
Copy link

We are trying to model inheritance according to

https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/

To test the problem, please use the petstore example of your tests:

  • Import test/data/valid_openapi/petstore-detailed.yaml in the API explorer.
  • Use the request Add a new pet to the store.
  • We are trying to create a cat and have the cat specific properties validated (huntingSkill)
  • Send the following payload
{
  "name": "<string>",
  "photoUrls": [
    "<string>",
    "<string>"
  ],
  "id": "<long>",
  "category": {
    "id": "<long>",
    "name": "<string>",
    "sub": {
      "prop1": "<string>"
    }
  },
  "friend": {
    "value": "<Circular reference to #/components/schemas/Pet detected>"
  },
  "tags": [
    {
      "id": "<long>",
      "name": "<string>"
    }
  ],
  "status": "available",
  "petType": "cat",
  "huntingSkill": 3
}

Everything is fine, although huntingSkill should be a string (enum)

But when you change a property that is defined in the base component, e.g.

  "status": 3,

you'll get two errors, that status should be string, and that it should be one of the 3 enum values.

This issue becomes even worse, when additionalProperties is set to false in the openAPI specification of the base component.
The huntingSkill would not even be allowed, although it is a property of the derived Cat component.

@shashankawasthi88
Copy link

@danielwinkler thanks for raising the issue, we are looking into it.

@danielwinkler danielwinkler changed the title Modelling inheritance does not work in validation Modeling inheritance does not work in validation May 9, 2023
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

2 participants