swagger-api / swagger-api/swagger-client
Order of models in components/schemas causes incorrect rendering
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by loading the two OpenAPI definitions from the issue and comparing the Models rendering for ExtentionObject3 after a force refresh. Trace the client’s schema resolution and model rendering entry points to find why declaration order changes inherited properties. Done means ExtentionObject3 shows all four properties in both ordering examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100