mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
Fix broken order in discriminator dropdowns
This commit is contained in:
parent
f66b194e3d
commit
2be02c5aa1
|
@ -53,6 +53,20 @@ export class JsonSchema extends BaseComponent implements OnInit {
|
|||
|
||||
initDescendants() {
|
||||
this.descendants = this.specMgr.findDerivedDefinitions(this.normPointer);
|
||||
if (!this.descendants.length) return;
|
||||
let discriminator = this.schema.discriminator;
|
||||
let discrProperty = this.schema._properties &&
|
||||
this.schema._properties.filter((prop) => prop.name === discriminator)[0];
|
||||
if (discrProperty && discrProperty.enum) {
|
||||
let enumOrder = {};
|
||||
discrProperty.enum.forEach((enumItem, idx) => {
|
||||
enumOrder[enumItem.val] = idx;
|
||||
});
|
||||
|
||||
this.schema._descendants.sort((a, b) => {
|
||||
return enumOrder[a.name] > enumOrder[b.name] ? 1 : -1;
|
||||
});
|
||||
}
|
||||
this.selectDescendant(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user