Skip to content

Commit

Permalink
fix missing component definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
inkognitro committed Apr 1, 2024
1 parent 83af4ae commit b5c31f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/oas3/codegen/ts/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface CodeGenerator {
createOperationOutputPath(operationId: string): OutputPath;
createOutputPathByComponentRef(componentRef: string): OutputPath;
addOutput(output: Output): void;
addComponentOutputByComponentRef(componentRef: string): void;
}

export enum OutputType {
Expand Down
11 changes: 9 additions & 2 deletions src/oas3/codegen/ts/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,16 @@ export class DefaultCodeGenerator implements CodeGenerator {
return contentParts.join('\n\n');
}

addComponentOutputByComponentRef(componentRef: string) {
private addComponentOutputByComponentRef(componentRef: string) {
const components = this.oas3Specs.components;
const outputPath = this.createOutputPathByComponentRef(componentRef);
if (this.outputs.find(o => areOutputPathsEqual(o.path, outputPath))) {
if (
this.outputs.find(
o =>
o.type !== OutputType.COMPONENT_REF &&
areOutputPathsEqual(o.path, outputPath)
)
) {
return;
}
if (
Expand Down Expand Up @@ -563,6 +569,7 @@ export class DefaultCodeGenerator implements CodeGenerator {
);
}
this.outputs.push(output);
this.addComponentOutputByComponentRef(output.componentRef);
break;
case OutputType.DEFINITION:
// eslint-disable-next-line no-case-declarations
Expand Down
1 change: 0 additions & 1 deletion src/oas3/codegen/ts/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export function applyComponentRefSchema(
codeGenerator.createOutputPathByComponentRef(schema.$ref),
],
});
codeGenerator.addComponentOutputByComponentRef(schema.$ref);
return {
createCode: referencingPath =>
codeGenerator.createComponentTypeName(schema.$ref, referencingPath),
Expand Down

0 comments on commit b5c31f7

Please sign in to comment.