-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix, openapi): Preserve descriptions in anyOf (#3748)
- Loading branch information
Showing
7 changed files
with
469 additions
and
10 deletions.
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
packages/cli/openapi-ir-to-fern/src/__test__/__snapshots__/anyOf.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,147 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`anyOf anyOf docs 1`] = ` | ||
{ | ||
"definitionFiles": {}, | ||
"packageMarkerFile": { | ||
"service": { | ||
"auth": false, | ||
"base-path": "", | ||
"endpoints": { | ||
"Get": { | ||
"auth": false, | ||
"docs": undefined, | ||
"examples": [ | ||
{ | ||
"request": {}, | ||
"response": { | ||
"body": { | ||
"value": 1.1, | ||
}, | ||
}, | ||
}, | ||
], | ||
"method": "GET", | ||
"pagination": undefined, | ||
"path": "/get", | ||
"request": { | ||
"body": { | ||
"properties": { | ||
"id": { | ||
"default": undefined, | ||
"docs": "An optional string value. | ||
", | ||
"type": "optional<string>", | ||
"validation": undefined, | ||
}, | ||
}, | ||
}, | ||
"headers": undefined, | ||
"name": "Request", | ||
"query-parameters": undefined, | ||
}, | ||
"response": { | ||
"docs": "A simple API response.", | ||
"type": "Response", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"types": { | ||
"Response": { | ||
"docs": "A generic response type used throughout the API. | ||
", | ||
"properties": { | ||
"value": { | ||
"default": undefined, | ||
"docs": "An optional numerical value. | ||
", | ||
"type": "optional<double>", | ||
"validation": undefined, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"rootApiFile": { | ||
"display-name": "Test spec for \`description\` settings defined in anyOf.", | ||
"error-discrimination": { | ||
"strategy": "status-code", | ||
}, | ||
"name": "api", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`anyOf anyOf simple 1`] = ` | ||
{ | ||
"definitionFiles": {}, | ||
"packageMarkerFile": { | ||
"service": { | ||
"auth": false, | ||
"base-path": "", | ||
"endpoints": { | ||
"Get": { | ||
"auth": false, | ||
"docs": undefined, | ||
"examples": [ | ||
{ | ||
"request": {}, | ||
"response": { | ||
"body": { | ||
"value": 1.1, | ||
}, | ||
}, | ||
}, | ||
], | ||
"method": "GET", | ||
"pagination": undefined, | ||
"path": "/get", | ||
"request": { | ||
"body": { | ||
"properties": { | ||
"id": { | ||
"default": undefined, | ||
"docs": "An optional string value. | ||
", | ||
"type": "optional<string>", | ||
"validation": undefined, | ||
}, | ||
}, | ||
}, | ||
"headers": undefined, | ||
"name": "Request", | ||
"query-parameters": undefined, | ||
}, | ||
"response": { | ||
"docs": "A simple API response.", | ||
"type": "Response", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"types": { | ||
"Response": { | ||
"docs": "A generic response type used throughout the API. | ||
", | ||
"properties": { | ||
"value": { | ||
"default": undefined, | ||
"docs": "An optional numerical value. | ||
", | ||
"type": "optional<double>", | ||
"validation": undefined, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"rootApiFile": { | ||
"display-name": "Test spec for \`description\` settings defined in anyOf.", | ||
"error-discrimination": { | ||
"strategy": "status-code", | ||
}, | ||
"name": "api", | ||
}, | ||
} | ||
`; |
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("anyOf", () => { | ||
testConvertOpenAPI("anyOf", "openapi.yml"); | ||
}); |
49 changes: 49 additions & 0 deletions
49
packages/cli/openapi-ir-to-fern/src/__test__/fixtures/anyOf/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,49 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Test spec for `description` settings defined in anyOf. | ||
version: 1.0.0 | ||
|
||
paths: | ||
/get: | ||
get: | ||
operationId: Get | ||
requestBody: | ||
required: true | ||
description: A simple API request. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Request" | ||
responses: | ||
'200': | ||
description: A simple API response. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Response" | ||
|
||
components: | ||
schemas: | ||
Request: | ||
description: | | ||
A generic request type used throughout the API. | ||
properties: | ||
id: | ||
anyOf: | ||
- type: string | ||
- type: 'null' | ||
description: | | ||
An optional string value. | ||
title: ID | ||
|
||
Response: | ||
description: | | ||
A generic response type used throughout the API. | ||
properties: | ||
value: | ||
anyOf: | ||
- type: number | ||
- type: 'null' | ||
description: | | ||
An optional numerical value. | ||
title: Value |
Oops, something went wrong.