Skip to content

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

@rodrigoramos

Description

@rodrigoramos

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");

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions