validator doesn't support media type place holders

Issue #177 resolved
Bashar Allabadi created an issue

OAS 3 allows using something like:

content:
   application/*: 
       ....
   */*:
      ...

but when I use that and run validator it fails and gives me this message: "Response Content-Type header 'application/json;charset=UTF-8' does not match any allowed types. Must be one of: [application/*]."

my env: with spring mvc mock v2.0.2

Comments (10)

  1. James Navin

    I believe this was fixed in v2.2.3

    Please re-open the issue if the problem is still present in the latest version.

  2. Gediminas Rimša

    @James Navin I can reproduce this with both version 2.9.0 and 2.10.2

    OpenAPI response is defined as:

          responses:
            '200':
              content:
                image/*:
                  schema:
                    type: string
                    format: binary
    

    And I’m getting an error:

    [ERROR][RESPONSE][GET /images/502ed595-9551-4d88-9c76-1a7f78cc5670/thumbnail] Response Content-Type header 'image/gif' does not match any allowed types. Must be one of: [image/*].

  3. Gediminas Rimša

    @James Navin I noticed request content type validation still fails with a wildcard (tested with version 2.12.0):

    {
      "messages" : [ {
        "key" : "validation.request.contentType.notAllowed",
        "level" : "ERROR",
        "message" : "Request Content-Type header '[image/jpeg]' does not match any allowed types. Must be one of: [image/*].",
        "context" : {
          "requestPath" : "/projects/d306de6a-8bfb-4f73-ba93-060ba0af442c/images",
          "location" : "REQUEST",
          "requestMethod" : "POST"
        }
      } ]
    }
    

    Response validation works OK when image/* content type is present in OpenAPI spec.

    Edit: reported it as a separate issue here: https://bitbucket.org/atlassian/swagger-request-validator/issues/318/request-content-type-validation-fails-when

  4. Log in to comment