Skip to content

Malformed api-docs JSON when StringHttpMessageConverter is not active #2051

Closed
@micw

Description

@micw

Describe the bug

StringHttpMessageConverter unwraps a JSON string and delivers it's content a string. This may have some uses but it breaks JSON compatibility. If StringHttpMessageConverter is disabled, a JSON string is quoted properly.

In #624 the issue was already partially discussed. The only working solution is to use StringHttpMessageConverter. A real solution that works without StringHttpMessageConverter is needed, so that it works along with fully JSON compatible applications.

To Reproduce

Create an app with a WebMvcConfigurer with the following code:

	@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		converters.removeIf(c -> c instanceof StringHttpMessageConverter);
	}

Query for spec/v1.

Expected behavior

A Json should be returned. Instead a JSON quoted as JSON string is returned.

Edit:

The fix is trivial, see my comment in #624 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions