Skip to content

Commit

Permalink
fix(cli): the fern cli appropriately generates examples for undiscrim…
Browse files Browse the repository at this point in the history
…inated unions (#4808)
  • Loading branch information
dsinghvi authored Oct 10, 2024
1 parent c2379af commit f8497ac
Show file tree
Hide file tree
Showing 1,685 changed files with 441,630 additions and 247,177 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,7 @@ export class ConjureImporter extends APIDefinitionImporter<ConjureImporter.Args>
union: (value) => {
this.fernDefinitionBuilder.addType(fernFilePath, {
name: typeName,
schema: {
discriminant: "dummy",
union: Object.fromEntries(
Object.entries(value.union).map(([key, reference]) => {
return [
key,
{ type: typeof reference === "string" ? reference : reference.type, key }
];
})
)
}
schema: value
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Audiences, generatorsYml } from "@fern-api/configuration";
import { AbsoluteFilePath, stringifyLargeObject } from "@fern-api/fs-utils";
import { AbsoluteFilePath, streamObjectToFile, stringifyLargeObject } from "@fern-api/fs-utils";
import { migrateIntermediateRepresentationThroughVersion } from "@fern-api/ir-migrations";
import { serialization as IrSerialization } from "@fern-api/ir-sdk";
import { Project } from "@fern-api/project-loader";
Expand Down Expand Up @@ -50,10 +50,7 @@ export async function generateIrForWorkspaces({
});

const irOutputFilePath = path.resolve(irFilepath);
await writeFile(
irOutputFilePath,
await stringifyLargeObject(intermediateRepresentation, { pretty: true })
);
await streamObjectToFile(AbsoluteFilePath.of(irOutputFilePath), intermediateRepresentation);
context.logger.info(`Wrote IR to ${irOutputFilePath}`);
});
})
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- changelogEntry:
- summary: |
The CLI now generates endpoint examples for undiscriminated unions that are recusive.
type: fix
irVersion: 53
version: 0.45.0-rc2

- changelogEntry:
- summary: |
The OpenAPI importer now generates streaming examples based on OpenAPI examples.
Expand Down
1 change: 1 addition & 0 deletions packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export class DocsDefinitionResolver {
packageName: undefined,
context: this.taskContext
});
// console.log(JSON.stringify(ir, undefined, 2));
const apiDefinitionId = await this.registerApi({
ir,
snippetsConfig,
Expand Down
Loading

0 comments on commit f8497ac

Please sign in to comment.