diff --git a/fern/pages/changelogs/cli/2024-11-11.mdx b/fern/pages/changelogs/cli/2024-11-11.mdx new file mode 100644 index 00000000000..cee5e04d9c4 --- /dev/null +++ b/fern/pages/changelogs/cli/2024-11-11.mdx @@ -0,0 +1,5 @@ +## 0.45.0-rc39 +**`(fix):`** The OpenAPI importer now supports correlating request and response examples by name. When an example name is shared +between a request body and response, they will be paired together in the generated Fern definition. + + diff --git a/fern/pages/changelogs/cli/2024-11-12.mdx b/fern/pages/changelogs/cli/2024-11-12.mdx new file mode 100644 index 00000000000..47258b34822 --- /dev/null +++ b/fern/pages/changelogs/cli/2024-11-12.mdx @@ -0,0 +1,4 @@ +## 0.45.0-rc40 +**`(fix):`** Fixed bug in the Conjure importer where query parameters were overwritten during endpoint parameter parsing. + + diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/__snapshots__/debug.json b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/__snapshots__/debug.json new file mode 100644 index 00000000000..f39d2bd0840 --- /dev/null +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/__snapshots__/debug.json @@ -0,0 +1,81 @@ +{ + "absoluteFilePath": "/DUMMY_PATH", + "rootApiFile": { + "contents": { + "name": "api", + "error-discrimination": { + "strategy": "status-code" + } + }, + "rawContents": "name: api\nerror-discrimination:\n strategy: status-code\n" + }, + "namedDefinitionFiles": { + "Debug/__package__.yml": { + "absoluteFilepath": "/DUMMY_PATH", + "rawContents": "service:\n auth: false\n base-path: /debug\n endpoints:\n debugEndpointAlpha:\n auth: true\n path: /debug-endpoint-alpha\n method: GET\n response: string\n docs: Test endpoint alpha.\n request:\n body: string\n debugEndpointBeta:\n auth: true\n path: /debug-endpoint-beta/{param1}\n method: GET\n response: string\n docs: Test endpoint beta.\n path-parameters:\n param1:\n type: string\n request:\n query-parameters:\n param2: string\n name: debugEndpointBetaRequest\n debugEndpointGamma:\n auth: true\n path: /debug-endpoint-beta/{param1}/test\n method: POST\n response: string\n docs: Test endpoint gamma.\n path-parameters:\n param1:\n type: string\n request:\n query-parameters:\n param2: string\n param3: string\n body: bytes\n name: debugEndpointGammaRequest\n", + "contents": { + "service": { + "auth": false, + "base-path": "/debug", + "endpoints": { + "debugEndpointAlpha": { + "auth": true, + "path": "/debug-endpoint-alpha", + "method": "GET", + "response": "string", + "docs": "Test endpoint alpha.", + "request": { + "body": "string" + } + }, + "debugEndpointBeta": { + "auth": true, + "path": "/debug-endpoint-beta/{param1}", + "method": "GET", + "response": "string", + "docs": "Test endpoint beta.", + "path-parameters": { + "param1": { + "type": "string" + } + }, + "request": { + "query-parameters": { + "param2": "string" + }, + "name": "debugEndpointBetaRequest" + } + }, + "debugEndpointGamma": { + "auth": true, + "path": "/debug-endpoint-beta/{param1}/test", + "method": "POST", + "response": "string", + "docs": "Test endpoint gamma.", + "path-parameters": { + "param1": { + "type": "string" + } + }, + "request": { + "query-parameters": { + "param2": "string", + "param3": "string" + }, + "body": "bytes", + "name": "debugEndpointGammaRequest" + } + } + } + } + } + }, + "__package__.yml": { + "absoluteFilepath": "/DUMMY_PATH", + "rawContents": "{}\n", + "contents": {} + } + }, + "packageMarkers": {}, + "importedDefinitions": {} +} \ No newline at end of file diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/conjure.test.ts b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/conjure.test.ts index 9aa67bf8ba9..d9eb136ab47 100644 --- a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/conjure.test.ts +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/conjure.test.ts @@ -5,6 +5,9 @@ import { loadAPIWorkspace } from "@fern-api/workspace-loader"; const FIXTURES_DIR = join(AbsoluteFilePath.of(__dirname), RelativeFilePath.of("fixtures")); const FIXTURES: Fixture[] = [ + { + name: "debug" + }, { name: "trace" } diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/conjure/debug.yml b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/conjure/debug.yml new file mode 100644 index 00000000000..f99f0dc9322 --- /dev/null +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/conjure/debug.yml @@ -0,0 +1,47 @@ +types: + definitions: + default-package: com.birch.debug.service + +services: + DebugService: + name: Generic debug service + package: com.birch.debug.service + base-path: /debug + endpoints: + + debugEndpointAlpha: + docs: Test endpoint alpha. + http: GET /debug-endpoint-alpha + auth: header + args: + param1: string + param2: string + returns: string + + debugEndpointBeta: + docs: Test endpoint beta. + http: GET /debug-endpoint-beta/{param1} + args: + param1: + type: string + param-type: path + param2: + type: string + param-type: query + returns: string + + debugEndpointGamma: + docs: Test endpoint gamma. + http: POST /debug-endpoint-beta/{param1}/test + args: + param1: + type: string + param-type: path + param2: + type: string + param-type: query + param3: + type: string + param-type: query + body: binary + returns: string \ No newline at end of file diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/fern.config.json b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/fern.config.json new file mode 100644 index 00000000000..7980537f564 --- /dev/null +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/fern.config.json @@ -0,0 +1,4 @@ +{ + "organization": "fern", + "version": "*" +} \ No newline at end of file diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/generators.yml b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/generators.yml new file mode 100644 index 00000000000..951dc85eda9 --- /dev/null +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/__test__/fixtures/debug/fern/generators.yml @@ -0,0 +1,11 @@ +api: + specs: + conjure: ../conjure +groups: + local: + generators: + - name: fernapi/fern-typescript-node-sdk + version: 0.39.3 + output: + location: local-file-system + path: ../sdks/typescript diff --git a/packages/cli/api-importers/conjure/conjure-to-fern/src/ConjureImporter.ts b/packages/cli/api-importers/conjure/conjure-to-fern/src/ConjureImporter.ts index 0b22ffb7f6a..283aed15e88 100644 --- a/packages/cli/api-importers/conjure/conjure-to-fern/src/ConjureImporter.ts +++ b/packages/cli/api-importers/conjure/conjure-to-fern/src/ConjureImporter.ts @@ -169,7 +169,12 @@ export class ConjureImporter extends APIDefinitionImporter continue; } if (typeof argDeclaration === "string") { - endpoint.request = { body: argDeclaration === "binary" ? "bytes" : argDeclaration }; + if (!endpoint.request) { + endpoint.request = {}; + } else if (typeof endpoint.request === "string") { + endpoint.request = { body: endpoint.request }; + } + endpoint.request.body = argDeclaration === "binary" ? "bytes" : argDeclaration; } else { switch (argDeclaration.paramType) { case "body": diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index f6cdcd970dc..460fe255e76 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,3 +1,10 @@ +- changelogEntry: + - summary: | + Fixed bug in the Conjure importer where query parameters were overwritten during endpoint parameter parsing. + type: fix + irVersion: 53 + version: 0.45.0-rc40 + - changelogEntry: - summary: | The OpenAPI importer now supports correlating request and response examples by name. When an example name is shared