-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[FEAT] Support nullable Array<org.springframework.web.multipart.MultipartFile> in Kotlin-Spring generator
#21994
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
Merged
wing328
merged 3 commits into
OpenAPITools:master
from
jreynard-code:make_multipartfile_nullable_when_non_required
Oct 18, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
cd55f64
Support nullable `org.springframework.web.multipart.MultipartFile` in…
jreynard-code 51491da
Support nullable `org.springframework.web.multipart.MultipartFile` in…
jreynard-code 4511762
Support nullable `org.springframework.web.multipart.MultipartFile` in…
jreynard-code 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
2 changes: 1 addition & 1 deletion
2
modules/openapi-generator/src/main/resources/kotlin-spring/optionalDataType.mustache
This file contains hidden or 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 +1 @@ | ||
| {{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}Array<{{/isArray}}org.springframework.web.multipart.MultipartFile{{#isArray}}>{{/isArray}}{{^isArray}}{{^required}}?{{/required}}{{/isArray}}{{/isFile}} | ||
| {{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}Array<{{/isArray}}org.springframework.web.multipart.MultipartFile{{#isArray}}>{{/isArray}}{{#isNullable}}?{{/isNullable}}{{/isFile}} | ||
This file contains hidden or 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
182 changes: 182 additions & 0 deletions
182
modules/openapi-generator/src/test/resources/3_0/kotlin/feat-multipartfile_nullable.yaml
This file contains hidden or 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,182 @@ | ||
| openapi: 3.0.0 | ||
| servers: | ||
| - url: 'https://example.org/v1' | ||
| info: | ||
| description: >- | ||
| Example created for nullable multipartfile issue | ||
| version: 1.0.0 | ||
| title: OpenAPI Stuff API created to reproduce issue | ||
| license: | ||
| name: Apache-2.0 | ||
| url: 'https://www.apache.org/licenses/LICENSE-2.0.html' | ||
| tags: | ||
| - name: multipartfile | ||
| description: All about the nullable multipartfile | ||
| security: | ||
| - bearerAuth: [] | ||
| paths: | ||
| /nullable-multipartfile: | ||
| post: | ||
| tags: | ||
| - multipartfile | ||
| summary: simple nullable multipartfile | ||
| operationId: testNullableMultipartfile | ||
| requestBody: | ||
| content: | ||
| multipart/form-data: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| file: | ||
| type: string | ||
| description: File to upload | ||
| format: binary | ||
| nullable: true | ||
| jsonPayload: | ||
| type: object | ||
| description: simple json payload | ||
| properties: | ||
| name: | ||
| type: string | ||
| required: | ||
| - jsonPayload | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: string | ||
| '400': | ||
| description: Invalid status value | ||
|
|
||
| /nullable-multipartfile-array: | ||
| post: | ||
| tags: | ||
| - multipartfile | ||
| summary: simple nullable multipartfile | ||
| operationId: testNullableMultipartfile | ||
| requestBody: | ||
| content: | ||
| multipart/form-data: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| files: | ||
| type: array | ||
| items: | ||
| type: string | ||
| description: File to upload | ||
| format: binary | ||
| nullable: true | ||
| jsonPayload: | ||
| type: object | ||
| description: simple json payload | ||
| properties: | ||
| name: | ||
| type: string | ||
| required: | ||
| - jsonPayload | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: string | ||
| '400': | ||
| description: Invalid status value | ||
| /non-nullable-multipartfile: | ||
| post: | ||
| tags: | ||
| - multipartfile | ||
| summary: simple non nullable multipartfile | ||
| operationId: testNonNullableMultipartfile | ||
| requestBody: | ||
| content: | ||
| multipart/form-data: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| file: | ||
| type: string | ||
| description: File to upload | ||
| format: binary | ||
| nullable: false | ||
| jsonPayload: | ||
| type: object | ||
| description: simple json payload | ||
| properties: | ||
| name: | ||
| type: string | ||
| required: | ||
| - jsonPayload | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: string | ||
| '400': | ||
| description: Invalid status value | ||
|
|
||
| /non-nullable-multipartfile-array: | ||
| post: | ||
| tags: | ||
| - multipartfile | ||
| summary: simple non nullable multipartfile | ||
| operationId: testNonNullableMultipartfile | ||
| requestBody: | ||
| content: | ||
| multipart/form-data: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| files: | ||
| type: array | ||
| items: | ||
| type: string | ||
| description: File to upload | ||
| format: binary | ||
| nullable: false | ||
| jsonPayload: | ||
| type: object | ||
| description: simple json payload | ||
| properties: | ||
| name: | ||
| type: string | ||
| required: | ||
| - jsonPayload | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: string | ||
| '400': | ||
| description: Invalid status value | ||
| externalDocs: | ||
| description: Find out more about Swagger | ||
| url: 'http://swagger.io' | ||
| components: | ||
| securitySchemes: | ||
| bearerAuth: | ||
| type: http | ||
| scheme: bearer | ||
| bearerFormat: JWT | ||
| schemas: | ||
| Stuff: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: integer | ||
| format: int64 | ||
| name: | ||
| type: string | ||
| tag: | ||
| type: string | ||
| required: | ||
| - name | ||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
what about optional schema in which isNullable is set to false? should it also generate the
?at the end to make it nullable in kotlin?Uh oh!
There was an error while loading. Please reload this page.
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.
What do you mean exactly?
Something equivalent to
Optional<T>in Java?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.
I mean a schema (in OpenAPI spec) that is non required and nullable (3.0.x) spec) is set to true
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.
If both are managed by placeholders
requiredandisNullablethat's ok so ;)If something (class, property,...) has
nullableset to true, the type should have a?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.
i'll file another pr to show i mean by optional after merging yours
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.
I've filed a draft PR: #22176
please take a look to see if the change makes sense to you.