-
-
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
[Java] add missing nullable judgement when required property is true #18518
Open
fanqiewanzi
wants to merge
5
commits into
OpenAPITools:master
Choose a base branch
from
fanqiewanzi:fix_issue_18516
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6d9a7c
[Java] add missing nullable judgement when required property is true
fanqiewanzi f33a47a
[Java] add okhttp template test and regenerate sample
fanqiewanzi f240c93
[Java] add tests when field is nullable and required
fanqiewanzi ec027a3
[Java] regenerate samples to fix pipeline error
fanqiewanzi 42a572b
[Java] add JSONTest fro RequiredNullableBody class
fanqiewanzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
61 changes: 61 additions & 0 deletions
61
modules/openapi-generator/src/test/resources/bugs/issue_18516.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,61 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: test | ||
description: Test API | ||
version: 1.0.1 | ||
|
||
paths: | ||
/test: | ||
get: | ||
responses: | ||
200: | ||
description: Valid response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/SomeObject" | ||
|
||
components: | ||
schemas: | ||
SomeObject: | ||
type: object | ||
required: | ||
- ids | ||
- users | ||
- user | ||
- role | ||
- custom | ||
properties: | ||
ids: | ||
type: array | ||
nullable: true | ||
items: | ||
type: integer | ||
users: | ||
type: array | ||
nullable: true | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
user: | ||
type: object | ||
nullable: true | ||
properties: | ||
id: | ||
type: string | ||
role: | ||
type: string | ||
nullable: true | ||
enum: | ||
- admin | ||
- tenant | ||
custom: | ||
$ref: "#/components/schemas/customEnum" | ||
customEnum: | ||
type: string | ||
nullable: true | ||
enum: | ||
- custom | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
thanks for the fix and the test.
shall the new condition
{{#isNullable}} && !jsonObj.get("{{baseName}}").isJsonNull(){{/isNullable}}
be put in its own code block instead of adding to the JSON array type check as the error message right below only mentions expecting the field to be an array?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.
Hi, I don't quite understand. It doesn't seem to make sense to bring up the nullable judgment alone, because nullable is just an auxiliary judgment. If we put in its own code block, the nullable judgment is set outside the original judgment. From the code point of view, the logic is the same. If you write a judgment to nullable alone to throw an exception, the whole logic will seem even more strange.
Or this is the change you want.
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.
can you please PM me via Slack when you've time?
https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g
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.
ok👌