allOf multiple level inheritance bug?
See original GitHub issueQ&A (please complete the following information)
- OS: osx sierra
- Browser: chrome
- Version: 67.0.3396.87 (Official Build) (64-bit)
- Method of installation: dist
- Swagger-UI version: 3.17.1 gitRevision":“ga6656ced”
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Define four level inheritance like in my schema and try to use the last one
Example Swagger/OpenAPI definition:
"definitions": {
"profile_list": {
"type": "object",
"properties": {
"id": {"type": "integer"}
}
},
"profile_details": {
"allOf": [{
"$ref": "#/definitions/profile_list"
}, {
"type": "object",
"properties": {
"first_name": {"type": "string"}
}
}]
},
"profile_details_extended": {
"allOf": [
{
"$ref": "#/definitions/profile_details"
}, {
"type": "object",
"properties": {
"last_name": {"type": "string"}
}
}
]
},
"profile_details_extended_again": {
"allOf": [
{
"$ref": "#/definitions/profile_details_extended"
},
{
"type": "object",
"properties": {
"email": {"type": "string"}
}
}
]
}
}
...
in paths:
...
"post": {
"operationId": "profiles_create",
"responses": {
"201": {
"description": "test",
"schema": {
"$ref": "#/definitions/profile_details_extended_again"
}
}
}
Swagger-UI configuration options:
SwaggerUIBundle({
url: "schema.json",
dom_id: '#swagger-ui',
deepLinking: true,
docExpansion: 'none',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
Describe the bug you’re encountering
Schema displayed in swagger is not correct. Please see the screenshots
To reproduce…
Steps to reproduce the behavior:
- Go to path definition and see the responses
Expected behavior
Correct schema should be used
Screenshots
Bugged response schema. Note that schema has no name and two fields are missing. It appears like instead of using profile_details_extended_again its using profile_details.
It should look like this:
This is screenshot of an example of endpoint that is using parent schema (profile_details_extended) and is rendered properly:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (3 by maintainers)
Top Results From Across the Web
What is the exact problem with multiple inheritance?
The most obvious problem is with function overriding. Let's say have two classes A and B , both of which define a method...
Read more >Inheritance and Polymorphism - Swagger
OAS 3 This guide is for OpenAPI 3.0. Inheritance and Polymorphism. Model Composition. In your API, you may have model schemas that share...
Read more >Cascade, specificity, and inheritance - Learn web development
We'll start with inheritance. In the example below, we have a <ul> element with two levels of unordered lists nested inside it. We...
Read more >Inheritance - Happy Coding
Take OOP to the next level. ... So Cat would inherit all of the functions from Animal and Mammal . But note that...
Read more >Ruby programing tutorial - class inheritance & modules
Inheritance is when a class inherits behavior from another class. ... This means that all of the methods in the Animal class are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1. Have this issue on OAS 3.0.0 too when schema uses more than 2-levels of nested allOf
I’m getting this as well and it appears to be an ordering issue in my particular case.
I played around with the online editor and identified that when my YAML definition gets converted to JSON specification (using connexion) the
components
attribute ends up being the first attribute in the spec coming beforepaths
. In this configuration my nested schemas do not render properly (unless they are inside an array (weird)) . If I manually load a JSON specification where my ordering in the YAML is preserved (components
defined AFTERpaths
) everything renders fine.