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

Order of models in components/schemas causes incorrect rendering #1892

Closed
aleskovets opened this issue Sep 30, 2018 · 1 comment
Closed

Order of models in components/schemas causes incorrect rendering #1892

aleskovets opened this issue Sep 30, 2018 · 1 comment

Comments

@aleskovets
Copy link

aleskovets commented Sep 30, 2018

Q&A

  • OS: macOS
  • Browser: chrome
  • Version: 69
  • Method of installation: docker
  • Swagger-Editor version: 3.6.11 (docker latest)
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

In case of deep inheritance ordering of models might lead to incorrect behavior

Example 1. Order: BaseObject, ExtentionObject1, ExtentionObject2, ExtentionObject3
Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  version: '1'
  title: Test API

paths:
  '/objects':
    get:
      responses:
        200:
          description: result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtentionObject3'

components:
  schemas:
    BaseObject:
      type: object
      allOf:
        - type: object
          properties:
            baseObjectProp1:
              type: string
            baseObjectProp2:
              type: string

    ExtentionObject1:
      allOf:
        - $ref: '#/components/schemas/BaseObject'

    ExtentionObject2:
      type: object
      allOf:
        - $ref: '#/components/schemas/ExtentionObject1'
        - type: object
          properties:
            extObject2Prop:
              type: string

    ExtentionObject3:
      type: object
      allOf:
        - $ref: '#/components/schemas/ExtentionObject2'
        - type: object
          properties:
            extObject3Prop:
              type: string

Example 2 with reversed order. Order: ExtentionObject3, ExtentionObject2, ExtentionObject1, BaseObject
Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  version: '1'
  title: Test API

paths:
  '/objects':
    get:
      responses:
        200:
          description: result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtentionObject3'

components:
  schemas:
    ExtentionObject3:
      type: object
      allOf:
        - $ref: '#/components/schemas/ExtentionObject2'
        - type: object
          properties:
            extObject3Prop:
              type: string
              
    ExtentionObject2:
      type: object
      allOf:
        - $ref: '#/components/schemas/ExtentionObject1'
        - type: object
          properties:
            extObject2Prop:
              type: string

    ExtentionObject1:
      allOf:
        - $ref: '#/components/schemas/BaseObject'
              
    BaseObject:
      type: object
      allOf:
        - type: object
          properties:
            baseObjectProp1:
              type: string
            baseObjectProp2:
              type: string

Describe the bug you're encountering

In Example 1 in Models section ExtentionObject3 only have 2 properties. In Example 2 it has 4 properties as expected.

To reproduce...

Paste examples, force refresh page (sometimes it works when page is not force refreshed)

Expected behavior

In both cases ExtentionObject3 should have 4 properties

Screenshots

Example1 : screen shot 2018-09-30 at 15 33 51
Example 2: screen shot 2018-09-30 at 15 32 45

@aleskovets aleskovets changed the title Order of models in components/schemas leads to the incorrect rendering Order of models in components/schemas causes incorrect rendering Oct 1, 2018
@shockey
Copy link
Contributor

shockey commented Oct 11, 2018

This issue was moved to swagger-api/swagger-js#1394

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