Skip to content
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

[kotlin-spring] Handle arrays of files correctly using MultipartFile #20108

Merged

Conversation

ffffionn
Copy link
Contributor

This handles request parameters of arrays of files correctly, as well as changing them to use Spring's Multipart File class, as is recommended. Previously, Spring's Resource would be used as the input and the Delegate class would not recognize the array

Fixes the following open issues for Kotlin-spring generator:
#8333
#15251

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@ffffionn
Copy link
Contributor Author

ffffionn commented Nov 15, 2024

I'm not sure that I did the samples properly, as they seem to have switched to Windows path separators instead.
I used Git Bash on Windows

@wing328
Copy link
Member

wing328 commented Nov 16, 2024

thanks for the PR. i've filed #20117 with updated samples.

is it correct to say that this is a breaking change as org.springframework.web.multipart.MultipartFile is used instead?

@ffffionn
Copy link
Contributor Author

@wing328 Yeah, I guess you could consider it that. All Spring documentation says to be using MultipartFile for uploads (but we still keep Resource for downloads)

@wing328
Copy link
Member

wing328 commented Nov 16, 2024

can you please review the build failure when you've time?

https://github.com/OpenAPITools/openapi-generator/actions/runs/11868985076/job/33078813658?pr=20117

@wing328
Copy link
Member

wing328 commented Nov 16, 2024

@wing328 Yeah, I guess you could consider it that. All Spring documentation says to be using MultipartFile for uploads (but we still keep Resource for downloads)

ok. i'll see if i can come up with a way to fallback in case the users prefer the current implementation.

@ffffionn
Copy link
Contributor Author

can you please review the build failure when you've time?

https://github.com/OpenAPITools/openapi-generator/actions/runs/11868985076/job/33078813658?pr=20117

Sorry, I'm a bit of a noob on Github Actions. Maven build passes successfully when run, is there a way to run these tests locally? (should they be included in mvn test?)

@wing328
Copy link
Member

wing328 commented Nov 16, 2024

can you run ./gradlew build -x test in samples/server/petstore/kotlin-springboot-source-swagger1 for example?

@ffffionn
Copy link
Contributor Author

ffffionn commented Nov 16, 2024

There isn't any gradle wrapper in that directory

EDIT: Ah I got it to run locally after some playing around. Let me fix these issues..
(This would be ideally solved with being able to set the typeMapping for file differently on input parameters vs response type - but in the absence of this, the solution to hard-code the MultipartFile type will do)

@ffffionn
Copy link
Contributor Author

@wing328 I made some changes but there doesn't seem to be a good way to verify all the samples compile. I feel like this should be part of the maven build

@wing328
Copy link
Member

wing328 commented Nov 20, 2024

fyi. updated samples via 2c25491

@wing328
Copy link
Member

wing328 commented Nov 20, 2024

agreed with you that we should also test the kotlin spring project with maven as well

@wing328 wing328 added this to the 7.11.0 milestone Nov 20, 2024
@wing328
Copy link
Member

wing328 commented Nov 20, 2024

cc @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)

@wing328 wing328 merged commit e131d52 into OpenAPITools:master Dec 4, 2024
42 checks passed
@ffffionn ffffionn deleted the bugfix/kotlin-spring-multipartfile-array branch December 5, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants