swagger-ui: No operations defined in spec when Content-Type is missing/wrong

I was trying the v3 on a test server and I noticed that if the response to the xhr request to obtain the specification file does not have the proper Content-Type (missing or set to a wrong type) it will fail with No operations defined in spec!. Setting the proper type ( application/json for json or text/plain; charset=utf-8 for yaml) fixes the problem. Sorry if this the expected behaviour.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

No the problem is in the response the server returns with the spec file. It must have the appropriate Content-Type. You can use the browser debugger to see the network request and their details

@rockeshub The validation error is normal, since an external website can’t access your local network.

For me specifying the Content-Type header fixes the No operations defined in spec! problem?