fix: fix deref logic for oas3.1 (#1767)

This commit is contained in:
Roman Hotsiy 2021-10-11 15:02:08 +03:00 committed by GitHub
parent 3b8d6441bd
commit 4fb9c83525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -195,7 +195,7 @@ export class OpenAPIParser {
}
if (mergeAsAllOf && keys.some((k) => k !== 'description' && k !== 'title' && k !== 'externalDocs')) {
return {
allOf: [resolved, rest],
allOf: [rest, resolved],
};
} else {
// small optimization

View File

@ -80,7 +80,7 @@ export class SchemaModel {
makeObservable(this);
this.pointer = schemaOrRef.$ref || pointer || '';
this.rawSchema = parser.shallowDeref(schemaOrRef);
this.rawSchema = parser.deref(schemaOrRef, false, true);
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
this.init(parser, isChild);
@ -363,7 +363,7 @@ function buildFields(
): FieldModel[] {
const props = schema.properties || {};
const additionalProps = schema.additionalProperties;
const defaults = schema.default || {};
const defaults = schema.default;
let fields = Object.keys(props || []).map((fieldName) => {
let field = props[fieldName];
@ -384,7 +384,7 @@ function buildFields(
required,
schema: {
...field,
default: field.default === undefined ? defaults[fieldName] : field.default,
default: field.default === undefined && defaults ? defaults[fieldName] : field.default,
},
},
$ref + '/properties/' + fieldName,