mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
fix: optimize and support inherited discriminator
This commit is contained in:
parent
193f4bfb44
commit
64e5741f67
|
@ -183,6 +183,21 @@ export class SpecManager {
|
|||
let globalDefs = this._schema.definitions || {};
|
||||
let res:DescendantInfo[] = [];
|
||||
let extendedDiscriminatorProp = definition['x-extendedDiscriminator'];
|
||||
|
||||
let pointers;
|
||||
if (definition['x-derived-from']) {
|
||||
// support inherited discriminator o_O
|
||||
let derivedDiscriminator = definition['x-derived-from'].filter(ptr => {
|
||||
if (!ptr) return false;
|
||||
let def = this.byPointer(ptr);
|
||||
return def && def.discriminator;
|
||||
});
|
||||
pointers = [defPointer, ...derivedDiscriminator];
|
||||
} else {
|
||||
pointers = [defPointer];
|
||||
}
|
||||
|
||||
|
||||
for (let defName of Object.keys(globalDefs)) {
|
||||
let def = globalDefs[defName];
|
||||
if (!def.allOf &&
|
||||
|
@ -190,12 +205,6 @@ export class SpecManager {
|
|||
let subTypes = def['x-derived-from'] ||
|
||||
def.allOf.map(subType => subType._pointer || subType.$ref);
|
||||
|
||||
let pointers;
|
||||
if (definition['x-derived-from']) {
|
||||
pointers = [defPointer, ...definition['x-derived-from']];
|
||||
} else {
|
||||
pointers = [defPointer];
|
||||
}
|
||||
let idx = -1;
|
||||
|
||||
for (let ptr of pointers) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user