Forum Discussion

garimanatany's avatar
garimanatany
New Contributor
4 years ago

Swagger yaml and annotation combination - Java

I would like to have a combination of yaml and annotation based swagger ui. I want my code to have flexibility to add controllers with annotations and yaml both. I am able to get it running for yaml and annotation separately.As for some UIs I would like to skip the overhead of writing a lot of annotations with examples. I don't want the developers to miss out the entry that's why the annotation functionality is needed. Is there any approach that works for the hybrid ? Here is what I tried :

 

    @Primary
    @Bean
    public SwaggerResourcesProvider swaggerResourcesProvider(InMemorySwaggerResourcesProvider defaultResourcesProvider) {
        return () -> {
            SwaggerResource wsResource = new SwaggerResource();
            wsResource.setName("Documentation");
            wsResource.setSwaggerVersion("2.0");
            wsResource.setLocation("/swagger.yml");

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

 

No RepliesBe the first to reply