0

I'm developing an SpringBoot REST project which runs perfectly. I'm trying to implement the OpenApi-ui in the project. It's working fine by default but I'd like to use my own yaml/json information file instead the default info.

I have been following the F.A.Q SpringDoc documentation , but nothing is working for me. It's throwing FAILED TO LOAD API DEFINITION : Fetch error undefined /open-api.yaml in the UI. Am I missing something in my configuration? Thanks in advance.

Implementation

implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.5.9'

App config (route yaml = src/main/resources)

springdoc:api-docs:enabled: false
         swagger-ui:url: /open-api.yaml

Configuration

    @Bean
public OpenAPI customOpenAPI() {
    return new OpenAPI()
            .components(new Components().addSecuritySchemes("basicScheme",
                    new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")))
            .info(new Info().title("MyApp").version("1.0")
                    .license(new License().name("Apache 2.0").url("http://springdoc.org")));
}

@Bean
public SpringDocConfiguration springDocConfiguration(){
    return new SpringDocConfiguration();
}
@Bean
public SpringDocConfigProperties springDocConfigProperties() {
    return new SpringDocConfigProperties();
}

Yaml file

    openapi: 3.0.3
info:
  title: MyApp
  description: MyApp Description
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: Local server
{...more}

Access URL to OpenApi UI http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config

OpenApi UI Image

RubenEs
  • 31
  • 4

1 Answers1

0

Just if someone is looking for something similar, we finally created a new class, extending SwaggerIndexPageTransformer and implementing by SwaggerIndexTransformer , which led us to use @override method to change the url.

You can follow > https://github.com/springdoc/springdoc-openapi/issues/763

RubenEs
  • 31
  • 4