S
S
smetannicPum2021-11-28 01:22:46
Java
smetannicPum, 2021-11-28 01:22:46

How to read swagger documentation from yaml file?

I have a small spring boot application and I want to create documentation for it in a yaml file and refer to it. To do this, I created a config class:

@Configuration
public class SwaggerSpecConfig {

@Primary
@Bean
public SwaggerResourcesProvider swaggerResourcesProvider(InMemorySwaggerResourcesProvider defaultResourcesProvider) {
    return () -> {
        SwaggerResource wsResource = new SwaggerResource();
        wsResource.setName("Bank Swagger Spec");
        wsResource.setSwaggerVersion("3.0");
        wsResource.setLocation("/swagger_specs/BankSwagger.yaml");

        List<SwaggerResource> resources = new ArrayList<>(defaultResourcesProvider.get());
        resources.add(wsResource);
        return resources;
    };
}


Added a dependency file to the pom:

<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>3.0.0</version>
    </dependency>


The swagger file is on the path:
src/main/resources/swagger_specs/BankSwagger.yaml

When I start, I get an error: sp1Mc.png

What could be the problem?
I’ll say in advance that the application starts normally and creates auto-documentation without any problems, but there is an error with reading

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question