[BUG][kotlin-spring] Fix defaultValue for RequestHeader is not generated (#20504)#21003
Merged
wing328 merged 4 commits intoOpenAPITools:masterfrom Apr 23, 2025
Merged
[BUG][kotlin-spring] Fix defaultValue for RequestHeader is not generated (#20504)#21003wing328 merged 4 commits intoOpenAPITools:masterfrom
wing328 merged 4 commits intoOpenAPITools:masterfrom
Conversation
Member
|
please follow step 3 to update the samples (in windows, you may need to run the command in WSL) |
Contributor
Author
|
@wing328 , thanks! I've updated the samples. |
Member
|
i did a test with the spec provided in the issue but got errors: does it work for your use cases locally with this fix? |
Member
|
and here is the change with this fix (compared with master) --- a/src/main/kotlin/org/openapitools/api/PetApiController.kt
+++ b/src/main/kotlin/org/openapitools/api/PetApiController.kt
@@ -65,7 +65,7 @@ class PetApiController() {
method = [RequestMethod.DELETE],
value = ["/pet/{petId}"]
)
- fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER, schema = Schema(allowableValues = ["de", "at"], defaultValue = "de")) @RequestHeader(value = "x-tenant", required = false) xTenant: kotlin.String,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?): ResponseEntity<Unit> {
+ fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER, schema = Schema(allowableValues = ["de", "at"], defaultValue = "de")) @RequestHeader(value = "x-tenant", required = false, defaultValue = de) xTenant: kotlin.String,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?): ResponseEntity<Unit> {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
|
Contributor
Author
|
I just did a |
Member
|
please use https://gist.github.com/wing328/bb5ce7ec9a91527a67b4c0f1a3c95737 to reproduce the issue |
Contributor
Author
|
Thanks @wing328, I have the same error, will debug further. |
Member
|
tested again and the output builds without issue thanks for the pr |
Contributor
Author
|
Thanks @wing328 for your review :) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR will fix 20504. Copied the current Java spring generator logic for the Kotlin Spring generator.
PR checklist
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03)