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

default-flat-param-object doesn't work when using http body #2282

Closed
NaccOll opened this issue Jun 27, 2023 · 0 comments
Closed

default-flat-param-object doesn't work when using http body #2282

NaccOll opened this issue Jun 27, 2023 · 0 comments

Comments

@NaccOll
Copy link
Contributor

NaccOll commented Jun 27, 2023

Describe the bug

Because of an issue, a pr was proposed, but this led to a bigger problem. All annotations that use RequestBody, RequestPart and custom message body processing are rendered invalid on swagger-ui. Objects become flattened objects and eventually query parameters, which cannot be processed into json or other required message body formats.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    Spring Boot 3.1.1
  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi 2.1.0
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    When I use default-flat-param-object, I want swagger-ui to behave in line with how spring web handles
  • Provide with a sample code (HelloController) or Test that reproduces the problem
springdoc:
  default-flat-param-object: true

Expected behavior

I want springdoc to automatically flatten my complex query param objects when I use default-flat-param-object, but it shouldn't do anything for the json objects I need to accept as well as form objects. But now it turns my json object into a query parameter, and my swagger-ui is not working properly.

In fact, the emergence of default-flat-param-object is to solve the problem of repeatedly adding ParameterObject. But more importantly, the core problem is that it is close to springweb's default behavior. The simple way is of course to only process RequestBody and RequestPart, but I know that many developers will customize annotations to process requests. In order to be compatible with this part of developers, when using annotations for parameters, ignore default-flat-param-object

Screenshots
image

@PreAuthorize("hasPermission(0L,'GLOBAL','cms/column:add')")
@Operation(summary = "创建栏目")
@PostMapping
public CmsColumnDto create(@RequestBody CmsColumnCreateCommand command) {
     ...
}

command is a json object but converted to multiple query param.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant