Skip to content

Commit

Permalink
(fix, openapi): Preserve descriptions in anyOf (#3748)
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney authored May 31, 2024
1 parent 1ac00a0 commit 7815f7d
Show file tree
Hide file tree
Showing 7 changed files with 469 additions and 10 deletions.
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",
},
}
`;
5 changes: 5 additions & 0 deletions packages/cli/openapi-ir-to-fern/src/__test__/anyOf.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { testConvertOpenAPI } from "./testConvertOpenApi";

describe("anyOf", () => {
testConvertOpenAPI("anyOf", "openapi.yml");
});
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
Loading

0 comments on commit 7815f7d

Please sign in to comment.