Skip to content

Commit

Permalink
OpenApi generator supports top-level entities that are just aliases (…
Browse files Browse the repository at this point in the history
…refs)
  • Loading branch information
gius committed Feb 5, 2022
1 parent 906ec39 commit 0634ff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/generator/src/openapi/parsers/openApi2Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export default class OpenApi2Parser implements ApiModel {
parse() {
if (this.apiDocument.definitions) {
for (const [name, definition] of Object.entries(this.apiDocument.definitions)) {
this.parseSchemaObject(name, definition);
const parsed = this.parseSchemaObject(name, definition);
if (isV2ReferenceObject(definition)) {
// the definition is just a reference to another object
this.setTypeReference(name, new AliasEntity(name, parsed));
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/generator/src/openapi/parsers/openApi3Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export default class OpenApi3Parser implements ApiModel {
parse() {
if (this.apiDocument.components?.schemas) {
for (const [name, definition] of Object.entries(this.apiDocument.components.schemas)) {
this.parseSchemaObject(name, definition);
const parsed = this.parseSchemaObject(name, definition);
if (isV3ReferenceObject(definition)) {
// the definition is just a reference to another object
this.setTypeReference(name, new AliasEntity(name, parsed));
}
}
}

Expand Down

0 comments on commit 0634ff5

Please sign in to comment.