-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix, openapi): fall back to default status code if none provided (#3834
- Loading branch information
Showing
7 changed files
with
341 additions
and
25 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
packages/cli/openapi-ir-to-fern/src/__test__/__snapshots__/default-content.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`open api ir to fern default-content docs 1`] = ` | ||
{ | ||
"definitionFiles": { | ||
"generativelanguage.yml": { | ||
"imports": { | ||
"root": "__package__.yml", | ||
}, | ||
"service": { | ||
"auth": false, | ||
"base-path": "", | ||
"endpoints": { | ||
"GenerateContent": { | ||
"auth": false, | ||
"docs": undefined, | ||
"examples": [ | ||
{ | ||
"path-parameters": { | ||
"model": "model", | ||
}, | ||
"response": { | ||
"body": { | ||
"bar": "bar", | ||
}, | ||
}, | ||
}, | ||
], | ||
"method": "POST", | ||
"pagination": undefined, | ||
"path": "/generateContent", | ||
"path-parameters": { | ||
"model": "string", | ||
}, | ||
"response": { | ||
"docs": "Successful operation", | ||
"type": "root.GenerateContentResponse", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"packageMarkerFile": { | ||
"types": { | ||
"GenerateContentResponse": { | ||
"docs": undefined, | ||
"properties": { | ||
"bar": "optional<string>", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"rootApiFile": { | ||
"default-environment": "Default", | ||
"display-name": "Default Content Type", | ||
"environments": { | ||
"Default": "https://ai.com", | ||
}, | ||
"error-discrimination": { | ||
"strategy": "status-code", | ||
}, | ||
"name": "api", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`open api ir to fern default-content simple 1`] = ` | ||
{ | ||
"definitionFiles": { | ||
"generativelanguage.yml": { | ||
"imports": { | ||
"root": "__package__.yml", | ||
}, | ||
"service": { | ||
"auth": false, | ||
"base-path": "", | ||
"endpoints": { | ||
"GenerateContent": { | ||
"auth": false, | ||
"docs": undefined, | ||
"examples": [ | ||
{ | ||
"path-parameters": { | ||
"model": "model", | ||
}, | ||
"response": { | ||
"body": { | ||
"bar": "bar", | ||
}, | ||
}, | ||
}, | ||
], | ||
"method": "POST", | ||
"pagination": undefined, | ||
"path": "/generateContent", | ||
"path-parameters": { | ||
"model": "string", | ||
}, | ||
"response": { | ||
"docs": "Successful operation", | ||
"type": "root.GenerateContentResponse", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"packageMarkerFile": { | ||
"types": { | ||
"GenerateContentResponse": { | ||
"docs": undefined, | ||
"properties": { | ||
"bar": "optional<string>", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"rootApiFile": { | ||
"default-environment": "Default", | ||
"display-name": "Default Content Type", | ||
"environments": { | ||
"Default": "https://ai.com", | ||
}, | ||
"error-discrimination": { | ||
"strategy": "status-code", | ||
}, | ||
"name": "api", | ||
}, | ||
} | ||
`; |
5 changes: 5 additions & 0 deletions
5
packages/cli/openapi-ir-to-fern/src/__test__/default-content.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { testConvertOpenAPI } from "./testConvertOpenApi"; | ||
|
||
describe("open api ir to fern", () => { | ||
testConvertOpenAPI("default-content", "openapi.yml"); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/cli/openapi-ir-to-fern/src/__test__/fixtures/default-content/openapi.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
openapi: 3.0.3 | ||
info: | ||
title: Default Content Type | ||
version: v1 | ||
servers: | ||
- url: https://ai.com | ||
paths: | ||
"/generateContent": | ||
post: | ||
tags: | ||
- generativelanguage | ||
operationId: GenerateContent | ||
parameters: | ||
- name: model | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
default: | ||
description: Successful operation | ||
content: | ||
application/json: | ||
schema: | ||
"$ref": "#/components/schemas/GenerateContentResponse" | ||
components: | ||
schemas: | ||
GenerateContentResponse: | ||
properties: | ||
bar: | ||
type: string |
94 changes: 94 additions & 0 deletions
94
packages/cli/openapi-parser/src/__test__/__snapshots__/default-content.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`open api parser default-content parse open api 1`] = ` | ||
{ | ||
"basePath": null, | ||
"channel": [], | ||
"description": null, | ||
"endpoints": [ | ||
{ | ||
"audiences": [], | ||
"authed": false, | ||
"availability": null, | ||
"description": null, | ||
"errors": {}, | ||
"examples": [], | ||
"generatedRequestName": "GenerateContentRequest", | ||
"headers": [], | ||
"idempotent": null, | ||
"internal": null, | ||
"method": "POST", | ||
"operationId": "GenerateContent", | ||
"pagination": null, | ||
"path": "/generateContent", | ||
"pathParameters": [ | ||
{ | ||
"description": null, | ||
"name": "model", | ||
"schema": { | ||
"description": null, | ||
"generatedName": "GenerateContentRequestModel", | ||
"groupName": null, | ||
"nameOverride": null, | ||
"schema": { | ||
"default": null, | ||
"format": null, | ||
"maxLength": null, | ||
"minLength": null, | ||
"pattern": null, | ||
"type": "string", | ||
}, | ||
"type": "primitive", | ||
}, | ||
"variableReference": null, | ||
}, | ||
], | ||
"queryParameters": [], | ||
"request": null, | ||
"requestNameOverride": null, | ||
"response": { | ||
"description": "Successful operation", | ||
"responseProperty": null, | ||
"schema": { | ||
"description": null, | ||
"generatedName": "GenerateContentResponse", | ||
"groupName": null, | ||
"nameOverride": null, | ||
"schema": "GenerateContentResponse", | ||
"type": "reference", | ||
}, | ||
"type": "json", | ||
}, | ||
"sdkName": null, | ||
"server": [], | ||
"summary": null, | ||
"tags": [ | ||
"generativelanguage", | ||
], | ||
}, | ||
], | ||
"globalHeaders": [], | ||
"groups": {}, | ||
"hasEndpointsMarkedInternal": false, | ||
"idempotencyHeaders": [], | ||
"nonRequestReferencedSchemas": [ | ||
"GenerateContentResponse", | ||
], | ||
"schemas": {}, | ||
"securitySchemes": {}, | ||
"servers": [ | ||
{ | ||
"description": null, | ||
"name": null, | ||
"url": "https://ai.com", | ||
}, | ||
], | ||
"tags": { | ||
"orderedTagIds": null, | ||
"tagsById": {}, | ||
}, | ||
"title": "Default Content Type", | ||
"variables": {}, | ||
"webhooks": [], | ||
} | ||
`; |
5 changes: 5 additions & 0 deletions
5
packages/cli/openapi-parser/src/__test__/default-content.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { testParseOpenAPI } from "./testParseOpenApi"; | ||
|
||
describe("open api parser", () => { | ||
testParseOpenAPI("default-content", "openapi.yml"); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/cli/openapi-parser/src/__test__/fixtures/default-content/openapi.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
openapi: 3.0.3 | ||
info: | ||
title: Default Content Type | ||
version: v1 | ||
servers: | ||
- url: https://ai.com | ||
paths: | ||
"/generateContent": | ||
post: | ||
tags: | ||
- generativelanguage | ||
operationId: GenerateContent | ||
parameters: | ||
- name: model | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
default: | ||
description: Successful operation | ||
content: | ||
application/json: | ||
schema: | ||
"$ref": "#/components/schemas/GenerateContentResponse" | ||
types: | ||
schemas: | ||
GenerateContentResponse: | ||
properties: | ||
bar: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters