Skip to content

How to render specific yaml file via url? #3179

@metalpalo

Description

@metalpalo

Hi,

My application is based on spring boot 2.7.x. So I add following dependency on classpath:

<dependency>
			<groupId>org.springdoc</groupId>
			<artifactId>springdoc-openapi-ui</artifactId>
			<version>1.7.0</version>
		</dependency>

It seems that /swagger-ui-index.html and /v3/api-docs endpoints works well and swagger-ui(4.18.2) is rendered and contains all my controllers, explore field filled with /v3/api-docs

But what I want is to have additionally is possibility to paint also concrete yaml files via some urls.

In my project:

  • I have multiple yaml files like myapi1.yml, myapi2.yml ...

  • based on this yamls the controller stubs are generated via openapi-generator-maven-plugin

  • dedicated controller with endpoint returning links on my specifications via simply html table
    /api-docs/ui/index.html?url=/api-docs/specifications/myapi1.yml
    /api-docs/ui/index.html?url=/api-docs/specifications/myapi2.yml

  • dedicated WebMvcCustomizer registering

@Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
            .addResourceHandler("/api-docs/ui/**")
            .addResourceLocations(
                "classpath:/META-INF/resources/webjars/swagger-ui/" + swaggerUiVersion + "/");
      }

Everything worked fine before migration from springfox, we had swagger-ui web jar 3.52.1 accepting url query and after click on link yaml file was rendered.
Because 1.7.0 contains dependecy on swagger-ui 4.18.2 I 've upgrade it and now I see Petstore swagger

What I know that springdoc use some explicit js initializer and does some stuff standalone, so I ask is possible to show only specific file something like this:

swagger-ui/index.html?url=/swagger-ui/specifications/myapip1.yml

I still get webpage with all endpoint and prefilled /ve/api-docs, so does exist some solution for my case? override swagger-config or something else?

I just need to keep this functionality for customers clicking on link in the html table.

thanks
brmetalpalo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions