Skip to content

Commit

Permalink
fix: fix deref logic for oas3.1 (#1767)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Oct 11, 2021
1 parent 3b8d644 commit 4fb9c83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/services/OpenAPIParser.ts
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/services/models/Schema.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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];

Expand All @@ -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,
Expand Down

0 comments on commit 4fb9c83

Please sign in to comment.