Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple swagger JSON's in swagger-ui.html #1954

Closed
dreambrother opened this issue Jul 28, 2017 · 2 comments

Comments

@dreambrother
Copy link

commented Jul 28, 2017

Hello, I have a question. Looks like springfox doesn't automatically document spring-ws endpoints (websocket). I didn't find any solution how to document it manually, so I decided to write Swagger JSON doc manually, serve it as a static content and add it to Springfox's swagger-ui.html page. I was able to do this by adding another tag directly in a browser image
Now I want to add it in the application the code. Could you tell me how to do this? Or how to add endpoints to existing generated documentation manually?

Thanks :)

@dreambrother dreambrother changed the title Multiple swagger JSON's in Swagger UI Multiple swagger JSON's in swagger-ui.html Jul 28, 2017

@dilipkrish

This comment has been minimized.

Copy link
Member

commented Jul 30, 2017

You need to create a bean that implements the SwaggerResourcesProvider interface. You'd have to make a composite bean that uses the InMemorySwaggerResourcesProvider.java and adds your own json file to it as well. Keep in mind you need to make this new bean a @Primary bean.

@dreambrother

This comment has been minimized.

Copy link
Author

commented Jul 31, 2017

This works! Thank you!

@Configuration
public class SwaggerWsEndpointsConfig {

    @Primary
    @Bean
    public SwaggerResourcesProvider swaggerResourcesProvider(InMemorySwaggerResourcesProvider defaultResourcesProvider) {
        return () -> {
            SwaggerResource wsResource = new SwaggerResource();
            wsResource.setName("ws endpoints");
            wsResource.setSwaggerVersion("2.0");
            wsResource.setLocation("/v2/websockets.json");

            List<SwaggerResource> resources = new ArrayList<>(defaultResourcesProvider.get());
            resources.add(wsResource);
            return resources;
        };
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.