mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-11 03:16:48 +03:00
parent
6ea2b7b0e6
commit
aaff311a3e
|
@ -111,7 +111,7 @@ export class SchemaModel {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!isChild && schema.discriminator !== undefined) {
|
||||
if (!isChild && getDiscriminator(schema) !== undefined) {
|
||||
this.initDiscriminator(schema, parser);
|
||||
return;
|
||||
}
|
||||
|
@ -171,7 +171,8 @@ export class SchemaModel {
|
|||
},
|
||||
parser: OpenAPIParser,
|
||||
) {
|
||||
this.discriminatorProp = schema.discriminator!.propertyName;
|
||||
const discriminator = getDiscriminator(schema)!;
|
||||
this.discriminatorProp = discriminator.propertyName;
|
||||
const derived = parser.findDerived([...(schema.parentRefs || []), this._$ref]);
|
||||
|
||||
if (schema.oneOf) {
|
||||
|
@ -184,7 +185,7 @@ export class SchemaModel {
|
|||
}
|
||||
}
|
||||
|
||||
const mapping = schema.discriminator!.mapping || {};
|
||||
const mapping = discriminator.mapping || {};
|
||||
for (const name in mapping) {
|
||||
derived[mapping[name]] = name;
|
||||
}
|
||||
|
@ -257,3 +258,7 @@ function buildFields(
|
|||
|
||||
return fields;
|
||||
}
|
||||
|
||||
function getDiscriminator(schema: OpenAPISchema): OpenAPISchema['discriminator'] {
|
||||
return schema.discriminator || schema['x-discriminator'];
|
||||
}
|
||||
|
|
4
src/types/index.d.ts
vendored
4
src/types/index.d.ts
vendored
|
@ -1,5 +1,3 @@
|
|||
export * from './open-api';
|
||||
|
||||
export type Diff<T extends string, U extends string> = ({ [P in T]: P } &
|
||||
{ [P in U]: never } & { [x: string]: never })[T];
|
||||
export type Omit<T, K extends keyof T> = { [P in Diff<keyof T, K>]: T[P] };
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
|
2
src/types/open-api.d.ts
vendored
2
src/types/open-api.d.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import { Omit } from './';
|
||||
import { Omit } from './index';
|
||||
|
||||
export interface OpenAPISpec {
|
||||
openapi: string;
|
||||
|
|
Loading…
Reference in New Issue
Block a user