You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm using HATEOAS and the generated request body seems wrong. Both the RequestBody and the ResponseBody contain additionalProp* fields in the _links field.
RequestBody according to Swagger UI: POST /company
What version of spring-boot you are using?
2.3.0.RELEASE
What modules and versions of springdoc-openapi are you using?
'org.springdoc:springdoc-openapi-ui:1.4.1'
'org.springdoc:springdoc-openapi-data-rest:1.4.1'
'org.springframework.data:spring-data-rest-webmvc:3.3.0.RELEASE'
What is the actual and the expected result using OpenAPI Description (yml or json)?
The actual result is displayed above in the description of the bug.
The expected result is displayed below.
Provide with a sample code (HelloController) or Test that reproduces the problem
Controller:
Expected behavior
I expect Swagger UI to not show the additionalProp*'s in _links but some output that's more in line with the actual output.
Actual RequestBody: POST /company
For the requestBody content, this is due to the fact that you are using the same object for the request and response. Your DTO extends on RepresentationModel.
We rely on swagger-core project, currently complex (object) payloads are always resolved as a reference to a schema defined in components. If its the same object used, by default, it will use the same reference.
You can use OperationCustomizer, to add a different request body. Or just separate your request and response objects that are used, if you are expecting they have different OpenAPI mappings.
If you are using spring-boot-starter-hateoas, then use springdoc-openapi-hateoas. (available since v1.4.0)
If you are using spring-boot-starter-data-rest, then use springdoc-openapi-data-rest.
With the next release, you will be able to define different mappings for the same object in the requestBody directly without using OperationCustomizer. An example is available in the tests:
Describe the bug
I'm using HATEOAS and the generated request body seems wrong. Both the RequestBody and the ResponseBody contain additionalProp* fields in the
_links
field.RequestBody according to Swagger UI: POST /company
ResponseBody according to Swagger UI: POST /company
To Reproduce
Steps to reproduce the behavior:
2.3.0.RELEASE
'org.springdoc:springdoc-openapi-ui:1.4.1'
'org.springdoc:springdoc-openapi-data-rest:1.4.1'
'org.springframework.data:spring-data-rest-webmvc:3.3.0.RELEASE'
The actual result is displayed above in the description of the bug.
The expected result is displayed below.
Controller:
CompanyModelAssembler:
DTO:
Expected behavior
I expect Swagger UI to not show the additionalProp*'s in
_links
but some output that's more in line with the actual output.Actual RequestBody: POST /company
Actual ReponseBody: POST /company
The text was updated successfully, but these errors were encountered: