Skip to content

Commit

Permalink
fix(type-safe-api): remove imports for self-referential models (#877)
Browse files Browse the repository at this point in the history
Models which referenced themselves would previously attempt to import themselves too which produced
code which did not compile.
  • Loading branch information
cogwirrel authored Oct 30, 2024
1 parent 37b4aa2 commit ac073d3
Show file tree
Hide file tree
Showing 8 changed files with 9,685 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ const buildData = async (inSpec: OpenAPIV3.Document, metadata: any) => {
...model.imports,
// Include property imports, if any
...model.properties.filter(p => p.export === "reference").map(p => p.type),
]));
])).filter(modelImport => modelImport !== model.name); // Filter out self for recursive model references

// Add deprecated flag if present
(model as any).deprecated = specModel.deprecated || false;
Expand Down
2 changes: 1 addition & 1 deletion packages/type-safe-api/src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { OpenApiAsyncModelProject } from "./model/openapi/open-api-async-model-p
import { OpenApiModelProject } from "./model/openapi/open-api-model-project";
import { SmithyAsyncModelProject } from "./model/smithy/smithy-async-model-project";
import { SmithyModelProject } from "./model/smithy/smithy-model-project";
import { SmithyProjectDefinitionOptions } from "./model/smithy/smithy-project-definition";
import { TypeSpecAsyncModelProject } from "./model/type-spec/type-spec-async-model-project";
import { TypeSpecModelProject } from "./model/type-spec/type-spec-model-project";
import { SmithyProjectDefinitionOptions } from "./model/smithy/smithy-project-definition";
import { PythonProjectOptions } from "./python-project-options";
import { TypeScriptProjectOptions } from "./typescript-project-options";

Expand Down
Loading

0 comments on commit ac073d3

Please sign in to comment.