question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allOf multiple level inheritance bug?

See original GitHub issue

Q&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:

  1. 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.

screen shot 2018-06-22 at 10 13 44

It should look like this:

screen shot 2018-06-22 at 10 22 57

This is screenshot of an example of endpoint that is using parent schema (profile_details_extended) and is rendered properly:

screen shot 2018-06-22 at 10 16 38

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
rmanokacommented, Jul 6, 2018

+1. Have this issue on OAS 3.0.0 too when schema uses more than 2-levels of nested allOf

5reactions
tahowardcommented, Feb 26, 2019

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 before paths. 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 AFTER paths) everything renders fine.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found