-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make schema nullable instead of adding null-types into the apispec sc…
…hema These null-types are only supported in openapi 3.1.0. For 3.0.3, we need a different encoding. Therefore, we should leave the distinction to sttp-apispec, instead of deciding here in tapir.
- Loading branch information
Showing
5 changed files
with
118 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
docs/openapi-docs/src/test/resources/expected_nullable_option_class_field_303.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,48 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: ClassWithOptionClassField | ||
version: '1.0' | ||
paths: | ||
/: | ||
post: | ||
operationId: postRoot | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ClassWithOptionClassField' | ||
required: true | ||
responses: | ||
'200': | ||
description: '' | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'400': | ||
description: 'Invalid value for: body' | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
components: | ||
schemas: | ||
Bar: | ||
required: | ||
- bar | ||
type: object | ||
properties: | ||
bar: | ||
type: integer | ||
format: int32 | ||
ClassWithOptionClassField: | ||
required: | ||
- requiredStringField | ||
type: object | ||
properties: | ||
optionalObjField: | ||
allOf: | ||
- $ref: '#/components/schemas/Bar' | ||
nullable: true | ||
requiredStringField: | ||
type: string |
40 changes: 40 additions & 0 deletions
40
docs/openapi-docs/src/test/resources/expected_nullable_option_field_303.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,40 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: ClassWithOptionField | ||
version: '1.0' | ||
paths: | ||
/: | ||
get: | ||
operationId: getRoot | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ClassWithOptionField' | ||
required: true | ||
responses: | ||
'200': | ||
description: '' | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
'400': | ||
description: 'Invalid value for: body' | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
components: | ||
schemas: | ||
ClassWithOptionField: | ||
required: | ||
- requiredStringField | ||
type: object | ||
properties: | ||
optionalIntField: | ||
type: integer | ||
format: int32 | ||
nullable: true | ||
requiredStringField: | ||
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
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