Swagger shows "Failed to fetch" error but works fine in Postman (API gateway)

Viewed 994

I'm new to Swagger. I have created a aws API gateway. When I try to run that using swagger I get this error

Failed to fetch. Possible Reasons:

  • CORS
  • Network Failure
  • URL scheme must be "http" or "https" for CORS request.

This is the error in swagger

But when I copy the curl and import it in postman it works fine. It works fine in postman but I get errors in swagger. Can anyone help me with this? Thanks in advance!!

1 Answers
@OpenAPIDefinition(servers = {@Server(url = "/", description = "Default Server URL")})

In Springboot, you have to configure the default server and in case you have context in your application you have to add it as follwing:

@OpenAPIDefinition(servers = {@Server(url = "/", description = "Default Server URL"), @Server(url = "/myapp", description = "MyAPP Server URL")})
Related