-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basic support for openapi 3.1 (#109)
this adds basic support for openapi 3.1 definitions, based on the migration blog post from openapis.org. the primary change is allowing `null` as a `type`, and that `type` can be an array. the other changes listed relating to file uploads, and `exclusiveMinimum` aren't applicable as these aren't really supported at all yet (#51, #53) there's probably a bunch of other gaps in general JSON schema support, such as the `if` / `else` things mentioned, but there's relatively few examples of complex `3.1.0` definitions to test against. I stumbled across https://github.com/APIs-guru/openapi-directory looking for samples and I've tested these changes against these definitions: - https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/vercel.com/0.0.1/openapi.yaml - https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/discourse.local/latest/openapi.yaml - https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/adyen.com/CheckoutService/70/openapi.yaml It appears to be giving reasonable output - no compile errors at least, and nothing obviously wrong doing a quick scan of output. ref: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
- Loading branch information
Showing
8 changed files
with
381 additions
and
155 deletions.
There are no files selected for viewing
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...-generator/src/test/unit-test-inputs.yaml → ...ator/src/test/unit-test-inputs-3.0.3.yaml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
openapi: "3.0.0" | ||
openapi: "3.0.3" | ||
info: | ||
title: unit-test-inputs | ||
version: '0.0.1' | ||
|
179 changes: 179 additions & 0 deletions
179
packages/openapi-code-generator/src/test/unit-test-inputs-3.1.0.yaml
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,179 @@ | ||
openapi: "3.1.0" | ||
info: | ||
title: unit-test-inputs | ||
version: '0.0.1' | ||
components: | ||
schemas: | ||
SimpleObject: | ||
required: | ||
- str | ||
- num | ||
- date | ||
- datetime | ||
- required_nullable | ||
properties: | ||
str: | ||
type: string | ||
num: | ||
type: number | ||
date: | ||
type: string | ||
format: date | ||
datetime: | ||
type: string | ||
format: date-time | ||
optional_str: | ||
type: string | ||
required_nullable: | ||
type: | ||
- string | ||
- "null" | ||
NamedNullableStringEnum: | ||
type: | ||
- string | ||
- "null" | ||
enum: | ||
- '' | ||
- one | ||
- two | ||
- three | ||
- null | ||
ObjectWithRefs: | ||
required: | ||
- requiredObject | ||
properties: | ||
optionalObject: | ||
$ref: '#/components/schemas/SimpleObject' | ||
requiredObject: | ||
$ref: '#/components/schemas/SimpleObject' | ||
|
||
ObjectWithComplexProperties: | ||
required: | ||
- requiredOneOf | ||
- requiredOneOfRef | ||
properties: | ||
requiredOneOf: | ||
oneOf: | ||
- type: string | ||
- type: number | ||
requiredOneOfRef: | ||
$ref: '#/components/schemas/OneOf' | ||
optionalOneOf: | ||
oneOf: | ||
- type: string | ||
- type: number | ||
optionalOneOfRef: | ||
$ref: '#/components/schemas/OneOf' | ||
|
||
OneOf: | ||
oneOf: | ||
- type: object | ||
properties: | ||
strs: | ||
type: array | ||
items: | ||
type: string | ||
minItems: 1 | ||
required: | ||
- strs | ||
- type: array | ||
items: | ||
type: string | ||
minItems: 1 | ||
- type: string | ||
|
||
AnyOf: | ||
type: | ||
- number | ||
- string | ||
|
||
AllOf: | ||
allOf: | ||
- $ref: '#/components/schemas/Base' | ||
- type: object | ||
required: | ||
- id | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
Base: | ||
type: object | ||
required: | ||
- name | ||
properties: | ||
name: | ||
type: string | ||
breed: | ||
type: string | ||
|
||
Ordering: | ||
type: object | ||
required: | ||
- dependency1 | ||
- dependency2 | ||
properties: | ||
dependency1: | ||
$ref: "#/components/schemas/ZOrdering" | ||
dependency2: | ||
$ref: "#/components/schemas/AOrdering" | ||
|
||
ZOrdering: | ||
type: object | ||
required: | ||
- dependency1 | ||
properties: | ||
name: | ||
type: string | ||
dependency1: | ||
$ref: "#/components/schemas/AOrdering" | ||
AOrdering: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
|
||
AdditionalPropertiesBool: | ||
type: object | ||
additionalProperties: true | ||
|
||
AdditionalPropertiesSchema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
additionalProperties: | ||
$ref: "#/components/schemas/NamedNullableStringEnum" | ||
|
||
Recursive: | ||
type: object | ||
properties: | ||
child: | ||
$ref: "#/components/schemas/Recursive" | ||
|
||
OneOfAllOf: | ||
type: object | ||
oneOf: | ||
- allOf: | ||
- $ref: '#/components/schemas/AOrdering' | ||
- $ref: '#/components/schemas/ZOrdering' | ||
|
||
Enums: | ||
properties: | ||
str: | ||
type: | ||
- string | ||
- "null" | ||
enum: | ||
- null | ||
- "foo" | ||
- "bar" | ||
num: | ||
type: | ||
- number | ||
- "null" | ||
enum: | ||
- null | ||
- "ignored" | ||
- 10 | ||
- 20 |
Oops, something went wrong.