Forum Discussion

jcsreddy's avatar
jcsreddy
Occasional Contributor
6 years ago

Getting -> swagger compliance testing failed. invalid content type: application/json; charset=UTF-8

Team,

 

I am using Ready API 1.8.5, and in that I am using 'Swagger Compliance Assertion' for validating the response to check if it is adhering to Swagger 2.0 [OpenAPI 2.0] or not.

 

While doing this validation got the below error.

 

'swagger compliance testing failed. invalid content type: application/json; charset=UTF-8'

 

Can some one help on this?

4 Replies

  • JHunt's avatar
    JHunt
    Community Hero

    Thanks.

     

    According to this...

    https://support.smartbear.com/readyapi/docs/testing/assertions/reference/compliance/swagger.html

    ... the assertion only works by looking at the content-type defined for the response, but yours specifies it at the API level rather than the response level.

     

    That might be the problem. I couldn't say for sure. Since I don't have ReadyAPI, I would recommend again that you ask on the SoapUI Pro forum.

     

    If it turns out that really is all the support that ReadyAPI has for OpenAPI, that seems pretty disappointing. Maybe there's another tool that's better suited for this specific type of test on your API. Aren't SmartBear supposed to be driving OpenAPI adoption? Anyway, I came across Dredd when I was looking online.

    • jcsreddy's avatar
      jcsreddy
      Occasional Contributor

      Thank you very much for your input.

  • JHunt's avatar
    JHunt
    Community Hero

    In a sense, an OpenAPI specification is comparable to a WSDL - it is a machine-readable file that describes how an API will behave. This assertion is about checking that your API behaves as described by its OpenAPI specification, not about whether it complies with OpenAPI as a standard (whatever that would mean).

     

    It sounds like your API returned a response with a Content-Type header of "application/json; charset=UTF-8", but that was not what was described among the possible response Content-Types in the spec.

     

    If you still think the assertion should pass, you will need to give the spec and the response. And probably ask it on the SoapUI Pro forum (us Open Source users have very limited features for Swagger/OpenAPI).