Swagger-ui: Curl is generated and Curl is correct.But my Code is Undocumented, Details are TypeError: Failed to fetch, and the Response headers are not content

Created on 6 Jun 2017  路  13Comments  路  Source: swagger-api/swagger-ui

When reporting an issue, please provide the following details:

  • swagger-ui version
    3v.I downloaded the swagger from the master branch
  • a swagger file reproducing the issue
    As shown here, when I click Try it out, Curl is generated and Curl is correct.But my Code is Undocumented, Details are TypeError: Failed to fetch, and the Response headers are not content.Please have a look, thanks

I don't know why I can't upload pictures.I'm sorry
2222

11

lock-bot support

Most helpful comment

@LivesMountain your application needs to send back a Access-Control-Allow-Origin: * header in order to allow swagger-ui on a different host/port to communicate with it.

More info here: https://enable-cors.org/server.html

All 13 comments

I'm afraid the issue just isn't clear. Can you provide more details?

Can you check in the console, for where the request is going? Please provide the exact version you're using as well, you can type versions in the console to see what you have.

@webron Now I can upload pictures锛孭lease take a look锛宼hank you

@shockey Sorry, its version is 3.0.13

Thanks. Can you check and share with us the error you're getting in your browser's console?

@webron I appreciate your prompt reply
The first time I clicked Try it out
333
333330
After that, the console only has this information

66666

@webron I've seen you answer other questions about CORS, my "swagger.yaml" file and the "swagger-ui" on the same port under the same IP

@LivesMountain The CORS applies to two separate things - between swagger-ui and the yaml file, but also between swagger-ui and the application itself. Is the swagger-ui in the same ip and port as the app? If not, you'd need to enable CORS in the application.

@webron
You mean I don't have a CORS between my swagger-ui and app so my "Code = Undocumented" and "Details = TypeError: Failed to fetch"
May I Ask you what I need to do to solve this problem, whether my swagger-ui Set what parameter, or application needs to support CORS.thank you
Also, can the swagger-ui cancel the CORS mechanism?

Based on the error in the console, it seems like that's the cause of the issue. I'm afraid the CORS requirement is a browser restriction, and we cannot disable it from swagger-ui.

@LivesMountain your application needs to send back a Access-Control-Allow-Origin: * header in order to allow swagger-ui on a different host/port to communicate with it.

More info here: https://enable-cors.org/server.html

@webron @shockey Thank you for your timely reply銆俆he problem has been solved

I am a novice, without any experience and basic knowledge, finally solved, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

insideshell picture insideshell  路  3Comments

shockey picture shockey  路  3Comments

ankon picture ankon  路  4Comments

Deraen picture Deraen  路  4Comments

prabhat1790 picture prabhat1790  路  3Comments