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

Request content-type should default to application/json #105

Open
ethlo opened this issue Dec 27, 2021 · 2 comments · May be fixed by #166
Open

Request content-type should default to application/json #105

ethlo opened this issue Dec 27, 2021 · 2 comments · May be fixed by #166

Comments

@ethlo
Copy link

ethlo commented Dec 27, 2021

Spring defaults to application/json as expected content-type, this documenter should do the same (not */*)

@neiser
Copy link
Collaborator

neiser commented Dec 29, 2021

@ethlo Thanks for bringing this up. I think it's in de.qaware.openapigeneratorforspring.common.paths.method.SpringWebHandlerMethodContentTypesMapper which you could override to fix it now, but I'll see if I can fix it within the library itself. Currently, it uses */* for request and response types, which is probably not right.

@ethlo
Copy link
Author

ethlo commented Jan 3, 2022

Thanks for the hints!

I worked around it for now with:

    @Bean
    public OperationPostFilter replaceContentType()
    {
        return (operation, handlerMethod) ->
        {
            final RequestBody rb = operation.getRequestBody();
            if (rb != null)
            {
                final Content requestParams = rb.getContent();
                final Iterator<Map.Entry<String, de.qaware.openapigeneratorforspring.model.media.MediaType>> requestsIter = requestParams.entrySet().iterator();
                while (requestsIter.hasNext())
                {
                    final Map.Entry<String, de.qaware.openapigeneratorforspring.model.media.MediaType> e = requestsIter.next();
                    if (ALL_VALUE.equals(e.getKey()))
                    {
                        requestsIter.remove();
                        requestParams.put(APPLICATION_JSON_VALUE, e.getValue());
                    }
                }
            }
            
            return true;
        };
    }

neiser added a commit that referenced this issue Sep 5, 2022
@neiser neiser linked a pull request Sep 5, 2022 that will close this issue
neiser added a commit that referenced this issue Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants