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

When validation of MediaType fails, show all accept MediaType by the OpenApi document #3

Open
rodrigoramos opened this issue Feb 26, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@rodrigoramos
Copy link
Collaborator

rodrigoramos commented Feb 26, 2021

Validation of Media Type (Content-type) fails when a single letter is different from OpenApi document and the Request data.

In order to understand better what's going on, would be better to add to the error message which media types are allowed by the Open Api document.

The piece of code which has to change is:
src/OpenApiContract.Validator/RequestValidator.cs:170

if (!requestBodySpec.Content.TryGetValue(content.Headers.ContentType.MediaType, out OpenApiMediaType mediaTypeSpec))
   throw new RequestDoesNotMatchSpecException($"Content media type '{content.Headers.ContentType.MediaType}' is not specified");
@rodrigoramos rodrigoramos added the enhancement New feature or request label Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant