Skip to content

Commit

Permalink
Merge branch 'main' into eden/fix-go-deliminator-error
Browse files Browse the repository at this point in the history
  • Loading branch information
eyw520 authored Dec 27, 2024
2 parents 38091a7 + 0af503e commit 8c54dba
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
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: |
Fixed issue where user specified examples would be omitted in favor of autogenerated examples.
type: fix
irVersion: 53
version: 0.46.15

- changelogEntry:
- summary: |
Boolean default values are now propagated from the Fern Definition through to docs generation.
Expand Down
65 changes: 37 additions & 28 deletions packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,28 @@ function convertService(
for (const irEndpoint of irService.endpoints) {
const autogeneratedExample = irEndpoint.autogeneratedExamples[0];
const examples: FdrCjsSdk.api.v1.register.ExampleEndpointCall[] = [];
if (irEndpoint.userSpecifiedExamples.length > 0 && autogeneratedExample != null) {
if (irEndpoint.userSpecifiedExamples.length > 0) {
examples.push(
...irEndpoint.userSpecifiedExamples.map((userSpecifiedExample) =>
convertHttpEndpointExample({
autogeneratedExample,
userSpecifiedExample,
irEndpoint,
ir
})
)
...irEndpoint.userSpecifiedExamples
.map((userSpecifiedExample) =>
convertHttpEndpointExample({
userSpecifiedExample,
...(autogeneratedExample != null && { autogeneratedExample }),
irEndpoint,
ir
})
)
.filter(isNonNullish)
);
} else if (autogeneratedExample != null) {
examples.push(
convertHttpEndpointExample({
autogeneratedExample,
irEndpoint,
ir
})
);
const endpointExample = convertHttpEndpointExample({
autogeneratedExample,
irEndpoint,
ir
});
if (endpointExample != null) {
examples.push(endpointExample);
}
} else if (irEndpoint.response?.body?.type === "fileDownload") {
const example = generateEndpointExample({
ir,
Expand All @@ -99,15 +102,18 @@ function convertService(
generationResponse: { type: "success" }
});
if (example.type === "success") {
const convertedExample: FdrCjsSdk.api.v1.register.ExampleEndpointCall = {
...convertHttpEndpointExample({
autogeneratedExample: example,
irEndpoint,
ir
}),
responseBodyV3: { type: "filename", value: "<bytes>" }
};
examples.push(convertedExample);
const endpointExample = convertHttpEndpointExample({
autogeneratedExample: example,
irEndpoint,
ir
});
if (endpointExample != null) {
const convertedExample: FdrCjsSdk.api.v1.register.ExampleEndpointCall = {
...endpointExample,
responseBodyV3: { type: "filename", value: "<bytes>" }
};
examples.push(convertedExample);
}
}
}
const endpoint = {
Expand Down Expand Up @@ -653,10 +659,10 @@ function convertHttpEndpointExample({
ir
}: {
userSpecifiedExample?: UserSpecifiedEndpointExample;
autogeneratedExample: AutogeneratedEndpointExample;
autogeneratedExample?: AutogeneratedEndpointExample;
irEndpoint: Ir.http.HttpEndpoint;
ir: Ir.ir.IntermediateRepresentation;
}): FdrCjsSdk.api.v1.register.ExampleEndpointCall {
}): FdrCjsSdk.api.v1.register.ExampleEndpointCall | undefined {
const requiredGlobalHeaders: Ir.ExampleHeader[] = ir.headers
.map((header) => {
const value =
Expand All @@ -679,7 +685,10 @@ function convertHttpEndpointExample({
return undefined;
})
.filter(isNonNullish);
const example = userSpecifiedExample?.example ?? autogeneratedExample.example;
const example = userSpecifiedExample?.example ?? autogeneratedExample?.example;
if (example == null) {
return undefined;
}
const { codeSamples } = userSpecifiedExample ?? { codeSamples: [] };
return {
name: example.name?.originalName,
Expand Down

0 comments on commit 8c54dba

Please sign in to comment.