Ask a Question

Swagger Compliance Assertion: Invalid content type [image/bmp]

SOLVED
LennSar
Contributor

Swagger Compliance Assertion: Invalid content type [image/bmp]

Hi there,

 

I wonder why I get the error mentioned in the topic. The image is properly transfered and displayed. Also I think image/bmp as a content type should be allowed. 
Any suggestion what could go wrong here? 

 

Thanks in advance!

6 REPLIES 6
KarelHusa
Champion Level 3

You need to check your API definition to see if it allows image/bmp content type in the response. 

 

See https://swagger.io/docs/specification/describing-responses/ for more information.

 

Karel@apimate.eu
https://apimate.eu
LennSar
Contributor

Hi @KarelHusa,

 

thanks for the suggestions. I forgot to say it because it became so self-evident for me to have a proper OpenApi.yaml. 
image/bmp is the defined content-type in the swagger UI so the compliance assertion actually should get it right. Maybe you see something in our definition that I don't see:


@LennSar wrote:

Hi there,

 

I wonder why I get the error mentioned in the topic. The image is properly transfered and displayed. Also I think image/bmp as a content type should be allowed. 
Any suggestion what could go wrong here? 

 

Thanks in advance!


  /screenshot.bmp:
    get:
      servers:
        - url: http://{Hostname}
          description: http direct
          variables:
            Hostname:
              default: 169.254.2.0
              description: Hostname of the device
        - url: https://{Hostname}
          description: https direct
          variables:
            Hostname:
              default: 169.254.2.0
              description: Hostname of the device
        - url: http://{Hostname}/{ID}
          description: http forward
          variables:
            Hostname:
              default: 169.254.2.0
              description: Hostname of the device
            ID:
              default: "1"
              description: System ID of the device
              enum:
                - "1"
                - "2"
                - "3"
                - "4"
        - url: https://{Hostname}/{ID}
          description: https forward
          variables:
            Hostname:
              default: 169.254.2.0
              description: Hostname of the device
            ID:
              default: "1"
              description: System ID of the device
              enum:
                - "1"
                - "2"
                - "3"
                - "4"
      summary: Get a screenshot
      operationId: GET_screenshot.bmp
      responses:
        "200":
          description: Screenshot in BMP format
          content:
            image/bmp:
              schema:
                type: string
                format: binary
        "405":
          description: Method not allowed. Rights missing?



If the API specification permits the content type and the response matches, it seems like a bug in the ReadyAPI assertion evaluation.

Karel@apimate.eu
https://apimate.eu

That's what I suspect

JoostDG
Frequent Contributor

Yes, I have come across this as well. I think it's a known bug at ReadyAPI, but which they did not address yet. I disable the assertions for such a case.

 

Also detailed in this post: https://community.smartbear.com/t5/ReadyAPI-Questions/Swagger-compliance-assertion-with-content-type...

 

LennSar
Contributor

thanks @JoostDG for letting me know. I think I've seen that post before which is why I assumed it is a bug. I was just hoping it's not since the issue seems to be known for quite a while.

cancel
Showing results for 
Search instead for 
Did you mean: