Closed
Description
When custom HttpMessageConverter is used malformed api-docs endpoint produces malformed JSON
Steps to reproduce the behavior:
- spring-boot version 2.2.6.RELEASE
- springdoc-openapi 1.3.5-SNAPSHOT
- the actual result is a JSON String created from the String produced by
org.springdoc.webmvc.api.OpenApiResource#openapiJson
. The original response is wrapped with a leading and trailing double quote and all the double internal double quotes are escaped:
"{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"OpenAPI definition\",\"version\":\"v0\"},\"servers\":[{\"url\":\"http://localhost:8080\",\"description\":\"Generated server url\"}],\"paths\":{\"/get\":{\"get\":{\"tags\":[\"controller\"],\"operationId\":\"getSomeMap\",\"responses\":{\"200\":{\"description\":\"default response\",\"content\":{\"*/*\":{\"schema\":{\"$ref\":\"#/components/schemas/ImmutableMultimapStringString\"}}}}}}}},\"components\":{\"schemas\":{\"ImmutableMultimapStringString\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"}}}}}}"
- a sample application can be found in https://github.com/Geneea/springdoc-test
Expected behavior
- I would expect that
org.springdoc.webmvc.api.OpenApiResource#openapiJson
should not do the conversion fromOpenAPI
toString
. Just returnOpenAPI
orResponseEntity<OpenAPI>
and leave the serialization for the registeredHttpMessageConverter
.
Additional context
An ugly fix for this problem is https://github.com/Geneea/springdoc-test/blob/master/src/main/java/com/geneea/springdoc/FixApiDocsWithFilter.java
registering a Filter
what corrects the malformed response.
Same problem is described in https://stackoverflow.com/questions/59393191/endpoint-api-docs-doesnt-work-with-custom-gsonhttpmessageconverter