Skip to content

Commit

Permalink
fix(cli): conjure importer handles parsing query params on file upload (
Browse files Browse the repository at this point in the history
#5157)

* Update `ConjureImporter` and implement debug tests.

* fix

* Minor fixes & changelog entry

* chore: update changelog

---------

Co-authored-by: Eden <[email protected]>
Co-authored-by: fern-bot <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent a6b7511 commit 48e2b03
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 1 deletion.
5 changes: 5 additions & 0 deletions fern/pages/changelogs/cli/2024-11-11.mdx
Original file line number Diff line number Diff line change
@@ -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.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-11-12.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.0-rc40
**`(fix):`** Fixed bug in the Conjure importer where query parameters were overwritten during endpoint parameter parsing.


Original file line number Diff line number Diff line change
@@ -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": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "fern",
"version": "*"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ export class ConjureImporter extends APIDefinitionImporter<ConjureImporter.Args>
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":
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: |
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
Expand Down

0 comments on commit 48e2b03

Please sign in to comment.