swagger-js
swagger-js copied to clipboard
Order of models in components/schemas causes incorrect rendering
From @aleskovets on September 30, 2018 19:47
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 :
Example 2: 
Copied from original issue: swagger-api/swagger-editor#1892