spring boot & swagger/openapi

Viewed 662

I recently upgraded my Spring Boot app from 2.1 to 2.5. Since then, I am struggling to use Swagger/OpenAPI. I see two issues:

when I navigate to http://localhost:8081/swagger-ui/index.html or http://localhost:8081/swagger-ui/index.html?configUrl=/api-docs/ I get a message: No API definition provided.

I am getting CORS errors on Swagger calls (browser and postman work fine), which I think is due to the call being http instead of https. The configuration seems quite a bit different but here is what I have:

Config:

@Configuration
@CrossOrigin
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedMethods("OPTIONS", "GET", "POST", "PUT","DELETE");
    }
}

application.yml:

springdoc:
  api-docs:
    path: /api-docs
  swagger-ui:
    path: /swagger.html
    operationsSorter: method
    disable-swagger-default-url: true

relevant gradle:

plugins {
    id 'org.springframework.boot' version '2.5.4'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java-library'
    id 'idea'
    id 'application'
}
implementation 'org.springdoc:springdoc-openapi-data-rest:1.5.11'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4'

When I use Swagger to make a call I get the error about http vs https: enter image description here

0 Answers
Related