openapi-to-postman
openapi-to-postman copied to clipboard
Modeling inheritance does not work in validation
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.yamlin the API explorer. - Use the request
Add a new pet to the store. - We are trying to create a
catand 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.
@danielwinkler thanks for raising the issue, we are looking into it.