Search in sources :

Example 1 with ApiRegistrationContext

use of com.webcohesion.enunciate.api.ApiRegistrationContext in project enunciate by stoicflame.

the class SwaggerModule method getApiRegistry.

@Override
public ApiRegistry getApiRegistry() {
    return new ApiRegistry() {

        @Override
        public List<ServiceApi> getServiceApis(ApiRegistrationContext context) {
            return Collections.emptyList();
        }

        @Override
        public List<ResourceApi> getResourceApis(ApiRegistrationContext context) {
            return Collections.emptyList();
        }

        @Override
        public Set<Syntax> getSyntaxes(ApiRegistrationContext context) {
            return Collections.emptySet();
        }

        @Override
        public InterfaceDescriptionFile getSwaggerUI() {
            Set<String> facetIncludes = new TreeSet<String>(enunciate.getConfiguration().getFacetIncludes());
            facetIncludes.addAll(getFacetIncludes());
            Set<String> facetExcludes = new TreeSet<String>(enunciate.getConfiguration().getFacetExcludes());
            facetExcludes.addAll(getFacetExcludes());
            FacetFilter facetFilter = new FacetFilter(facetIncludes, facetExcludes);
            ApiRegistrationContext context = new SwaggerRegistrationContext(facetFilter);
            List<ResourceApi> resourceApis = apiRegistry.getResourceApis(context);
            if (resourceApis == null || resourceApis.isEmpty()) {
                info("No resource APIs registered: Swagger UI will not be generated.");
            }
            return new SwaggerInterfaceDescription(resourceApis, context);
        }
    };
}
Also used : ResourceApi(com.webcohesion.enunciate.api.resources.ResourceApi) FacetFilter(com.webcohesion.enunciate.facets.FacetFilter) ServiceApi(com.webcohesion.enunciate.api.services.ServiceApi) ApiRegistrationContext(com.webcohesion.enunciate.api.ApiRegistrationContext) Syntax(com.webcohesion.enunciate.api.datatype.Syntax) ApiRegistry(com.webcohesion.enunciate.api.ApiRegistry)

Aggregations

ApiRegistrationContext (com.webcohesion.enunciate.api.ApiRegistrationContext)1 ApiRegistry (com.webcohesion.enunciate.api.ApiRegistry)1 Syntax (com.webcohesion.enunciate.api.datatype.Syntax)1 ResourceApi (com.webcohesion.enunciate.api.resources.ResourceApi)1 ServiceApi (com.webcohesion.enunciate.api.services.ServiceApi)1 FacetFilter (com.webcohesion.enunciate.facets.FacetFilter)1