-
-
Notifications
You must be signed in to change notification settings - Fork 500
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 default-flat-param-object doesn't work when using http body #2291
Conversation
You should provide the complete code of your |
@bnasslahsen |
@bnasslahsen package com.example.springdoc.defaultflatparam;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/test1")
public class HelloController {
@GetMapping
public String test1(RequestObject object) {
return null;
}
@PostMapping
public String test2(@RequestBody RequestObject obj) {
return null;
}
} package com.example.springdoc.defaultflatparam;
public class RequestObject {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} The same object is used for the GET method and the POST method of the same path, where the POST method notifies Spring that it should parse it from the HTTP request body by adding the RequestBody annotation to the parameter. But unfortunately, it was flattened into multiple query parameters, the reason is that when default-flat-param-object is true, it caused problems due to pr ignoring all annotations. I'm actually confused, I'm the original developer of this feature (https://github.com/springdoc/springdoc-openapi/pull/1805/files), someone misused the feature and modified it, I'm correcting this mistake. It is hoped that this error will be corrected relatively quickly. I also found another error because of default-support-form-data. When I realized the conversion between Scheme and Paramter, the array was set to null, which caused a null exception when I used this attribute later, but I checked the issue has been now fixed. I hope this pr can be released 2.1.1 after being merged, and fix these two problems of 2.1.0. |
2.1.1 When will it be released? |
@bnasslahsen Is there any chance this fix could be back-ported and released as a patch for v1? We're stuck on v1 while we work on our project's Spring Boot 3 upgrade and this issue is blocking us from being able to move forward. |
Hi @kylerjensen, It's already backported in the supported version. |
Hi @bnasslahsen, thanks for your quick response! I am using v1.7.0 and I am still experiencing this issue. I'm using |
As stated Earlier, if you need support for this version you should reach out to [email protected]. |
Okay, as far as I can tell this fix is definitely not present in v1.7.0. Luckily, there is a fork with this fix backported. For anyone coming here looking for a fix for v1, I was able to make it work in my Gradle project through JitPack: repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.eshizhan.springdoc-openapi:springdoc-openapi-ui:e986414ba5'
implementation 'com.github.eshizhan.springdoc-openapi:springdoc-openapi-webmvc-core:e986414ba5'
// ...
} |
Related issue:
Related pr:
error behavior:
command
is a json object but converted to multiple query param.