Skip to content

OpenApiWebMvcResource.openapiJson returning String is brittle if custom MessageConverters are present #1699

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

Closed
cfieber opened this issue Jun 7, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@cfieber
Copy link

cfieber commented Jun 7, 2022

Is your feature request related to a problem? Please describe.
our app added a MessageConverter to support YAML content types and a JSON MessageConverter to add specific configuration of the Jackson ObjectMapper. As a result, the returned String gets serialized as a JSON String object (quoted and escaped) rather than as raw JSON

Describe the solution you'd like
Perhaps returning Map<String, Object> would play better with the Spring response serialization?

Describe alternatives you've considered
I need to figure out how to insert the correct MessageConverter to handle the String response through a WebMvcConfigurer

@bnasslahsen
Copy link
Collaborator

@cfieber,

You have so many ways to achieve your goal.
You can add StringHttpMessageConverter to your configureMessageConverters.
Or you can define your own OpenApiWebMvcResource Bean which returns what you are expecting...

All these options and others are discussed here:

@bnasslahsen bnasslahsen added the duplicate This issue or pull request already exists label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants