-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): nullable array
types in 3.1.x
specs
#19687
Changes from 5 commits
1d9d0fb
f0e5913
d5a87bd
f6eda57
55d3759
97fac86
fa42b60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
generatorName: typescript | ||
outputDir: samples/client/others/typescript/builds/null-types-simple | ||
inputSpec: modules/openapi-generator/src/test/resources/3_1/null-types-simple.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/typescript |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: "" | ||
version: "" | ||
components: | ||
schemas: | ||
WithNullableType: | ||
type: object | ||
required: | ||
# This simplifies the output | ||
- arrayDataOrNull | ||
- stringDataOrNull | ||
- oneofOrNull | ||
properties: | ||
arrayDataOrNull: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the broken part |
||
items: | ||
$ref: "#/components/schemas/SomeObject" | ||
type: | ||
- array | ||
- 'null' | ||
# This was working when this fixture was introduced, | ||
# but we need to make sure we don't regress | ||
stringDataOrNull: | ||
type: | ||
- string | ||
- 'null' | ||
# This was working when this fixture was introduced, | ||
# but we need to make sure we don't regress | ||
oneofOrNull: | ||
oneOf: | ||
- $ref: "#/components/schemas/SomeObject" | ||
- type: 'null' | ||
SomeObject: | ||
type: object | ||
properties: | ||
data: | ||
type: string |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
builds/**/* linguist-generated=true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sure that all the generated code collapses in the github diff. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further up, we fix up the
nullable
flag when the types contain the new 3.1null
type:openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java
Lines 1249 to 1252 in 29c3b02
but then, if there's a single type left AND it is an array schema, we forget to copy this property to the cloned
ArraySchema
. This line makes sure that the nullable flag is transferred onto the schema clone.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is likely to happen again in the future when/if a new property is added that is in 3.1+ but not 3.0.x - we could possibly introduce a
clone
ortransfer
function somewhere which would make this a bit more obvious, but it's not a guarantee either.