0

http://localhost:8080/swagger-ui.html#/ deosn;t display Ui page."406 - Not Acceptable" is the error.but http://localhost:8080/v2/api-docs and /swagger-resources work fine with no error.

there is no duplicate in the dependencies.

what should be the issue?

Dipali Lohar
  • 11
  • 1
  • 1
  • 2
  • Which version of Swagger UI are you using? – Dennis Kieselhorst Jul 23 '18 at 14:20
  • Which library/framework are you using (Springfox, Swashbuckle, etc.)? Also please post your Swagger UI configuration code so that others can reproduce the issue you are seeing. – Helen Jul 23 '18 at 14:23
  • Is your issue the same as [this](https://stackoverflow.com/questions/43642179/configuring-swagger-ui-with-spring-boot) or [this](https://stackoverflow.com/q/40789139/113116)? – Helen Jul 23 '18 at 14:27
  • springfox-swagger2 and springfox-swagger-ui version 2.7.0 – Dipali Lohar Jul 23 '18 at 14:27
  • yes @Helen, its the first issue – Dipali Lohar Jul 23 '18 at 14:28
  • 1
    Possible duplicate of [Configuring Swagger UI with Spring Boot](https://stackoverflow.com/questions/43642179/configuring-swagger-ui-with-spring-boot) – Helen Jul 23 '18 at 14:33
  • @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("")) .paths(PathSelectors.any()) .build().securitySchemes(apiKey()); } – Dipali Lohar Jul 23 '18 at 14:34
  • No, there is no duplicate. Can it be related to CORS config or spring security? – Dipali Lohar Jul 23 '18 at 15:27
  • 1
    Possible duplicate of [Swagger UI causing HTTP 406 Not Acceptable response for operations producing content types other than json](https://stackoverflow.com/questions/30926619/swagger-ui-causing-http-406-not-acceptable-response-for-operations-producing-con) – chevybow Jul 23 '18 at 15:49

1 Answers1

1

Add the following line in ConfigureServices of Startup.cs

services.AddMvcCore().AddJsonFormatters().AddApiExplorer();
Musab
  • 1,067
  • 12
  • 12