Skip to content

Commit

Permalink
chore(cli): exploded form data params in docs (#5928)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Feb 7, 2025
1 parent 4515358 commit 540e9ea
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { FernIr } from "@fern-api/dynamic-ir-sdk";
import { AbstractDynamicSnippetsGeneratorContext } from "./AbstractDynamicSnippetsGeneratorContext";

export abstract class AbstractEndpointSnippetGenerator<Context extends AbstractDynamicSnippetsGeneratorContext> {
// eslint-disable-next-line @typescript-eslint/no-empty-function
public constructor({ context }: { context: Context }) {
// eslint-disable-line @typescript-eslint/no-useless-constructor
}

public abstract generateSnippet({
endpoint,
request
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- changelogEntry:
- summary: |
The IR generator now correctly handles exploded form parameters in the docs, ensuring that curl code snippets
accurately reflect the expected request format. Previously, exploded parameters were not properly formatted in the documentation, which
could lead to incorrect API usage. This fix ensures that array parameters marked as "exploded" are properly expanded in the generated curl examples.
type: fix
irVersion: 55
version: 0.51.34

- changelogEntry:
- summary: |
The OpenAPI parser v2 now handles `null` values in examples, parses request and response bodies as unions if multiple, handles required
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/configuration-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"find-up": "^6.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/path-utils": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-fern/fiddle-sdk": "0.0.584",
"zod": "^3.22.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-importers/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/configuration": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"js-yaml": "^4.1.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-importers/mintlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"gray-matter": "^4.0.3"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/docs-importers/readme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/docs-importer-commons": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"gray-matter": "^4.0.3",
"hast-util-to-mdast": "^10.1.0",
"mdast-util-mdx-jsx": "^3.1.3",
Expand All @@ -59,4 +59,4 @@
"typescript": "5.7.2",
"vitest": "^2.1.9"
}
}
}
2 changes: 1 addition & 1 deletion packages/cli/docs-markdown-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"gray-matter": "^4.0.3",
"mdast-util-from-markdown": "^2.0.2",
"mdast-util-gfm": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/fdr-sdk": "0.129.4-b6c699ad2",
"@fern-api/fdr-sdk": "0.130.0-8bf179148",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
"@fern-api/logger": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-markdown-utils": "workspace:*",
"@fern-api/docs-parsers": "0.0.53",
"@fern-api/fdr-sdk": "0.129.4-b6c699ad2",
"@fern-api/fdr-sdk": "0.130.0-8bf179148",
"@fern-api/lazy-fern-workspace": "workspace:*",
"@fern-api/ui-core-utils": "0.129.4-b6c699ad2",
"@fern-api/fs-utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/ete-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/configuration": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-typescript/fetcher": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function createRawFileUploadRequest(
style
});
} else {
acc.push({ isFile: false, key, propertyType, docs, contentType });
acc.push({ isFile: false, key, propertyType, docs, contentType, style });
}
return acc;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-migrations": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/register/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@fern-api/configuration": "workspace:*",
"@fern-api/core": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
"type": "string"
}
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -98,7 +99,8 @@
"value": {
"type": "integer"
}
}
},
"exploded": false
},
{
"type": "file",
Expand Down Expand Up @@ -143,7 +145,8 @@
"type": "integer"
}
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -159,7 +162,8 @@
}
}
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -170,7 +174,8 @@
"type": "id",
"value": "type_service:MyObject"
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -180,7 +185,8 @@
"itemType": {
"type": "unknown"
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -191,7 +197,8 @@
"type": "id",
"value": "type_service:ObjectType"
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -202,7 +209,8 @@
"type": "id",
"value": "type_service:Id"
}
}
},
"exploded": false
}
]
}
Expand Down Expand Up @@ -394,7 +402,8 @@
"value": {
"type": "string"
}
}
},
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -403,7 +412,8 @@
"type": "id",
"value": "type_service:MyObject"
},
"contentType": "application/json"
"contentType": "application/json",
"exploded": false
},
{
"type": "bodyProperty",
Expand All @@ -415,7 +425,8 @@
"value": "type_service:MyObject"
}
},
"contentType": "application/json"
"contentType": "application/json",
"exploded": false
}
]
}
Expand Down
19 changes: 14 additions & 5 deletions packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ function convertRequestBody(irRequest: Ir.http.HttpRequestBody): FdrCjsSdk.api.v
valueType: convertTypeReference(bodyProperty.valueType),
contentType: bodyProperty.contentType,
description: bodyProperty.docs,
availability: convertIrAvailability(bodyProperty.availability)
availability: convertIrAvailability(bodyProperty.availability),
exploded: bodyProperty.style === "exploded"
}),
_other: () => undefined
});
Expand Down Expand Up @@ -764,10 +765,18 @@ function convertHttpEndpointExample({
}
},
bodyProperty: (bodyProperty) => {
value[bodyProperty.name.wireValue] = {
type: "json",
value: fullExample[bodyProperty.name.wireValue]
};
if (bodyProperty.style === "exploded") {
const example = fullExample[bodyProperty.name.wireValue];
value[bodyProperty.name.wireValue] = {
type: "exploded",
value: Array.isArray(example) ? example : [example]
};
} else {
value[bodyProperty.name.wireValue] = {
type: "json",
value: fullExample[bodyProperty.name.wireValue]
};
}
},
_other: noop
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/yaml/docs-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-markdown-utils": "workspace:*",
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/fdr-sdk": "0.129.4-b6c699ad2",
"@fern-api/fdr-sdk": "0.130.0-8bf179148",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/core-utils/src/mergeWithOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface OmitDeepBy {
export const omitDeepBy: OmitDeepBy = (object: unknown, cb: any): any => {
function omitByDeepByOnOwnProps(object: unknown) {
if (Array.isArray(object)) {
return object.map((element) => omitDeepBy(element, cb));
return object.map((element) => omitDeepBy(element, cb)) as unknown[];
}

if (isPlainObject(object)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/fdr-cjs-sdk": "0.129.4-b6c699ad2",
"@fern-fern/fdr-cjs-sdk": "0.130.0-8bf179148",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@fern-api/venus-api-sdk": "0.10.2",
"@fern-fern/fdr-test-sdk": "^0.0.5297",
Expand Down
Loading

0 comments on commit 540e9ea

Please sign in to comment.