Search in sources :

Example 1 with SwaggerBuilder

use of com.yahoo.elide.swagger.SwaggerBuilder in project elide by yahoo.

the class ElideAutoConfiguration method buildSwagger.

/**
 * Creates a singular swagger document for JSON-API.
 * @param elide Singleton elide instance.
 * @param settings Elide configuration settings.
 * @return An instance of a JPA DataStore.
 */
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "elide.swagger.enabled", havingValue = "true")
@RefreshScope
public SwaggerController.SwaggerRegistrations buildSwagger(RefreshableElide elide, ElideConfigProperties settings) {
    EntityDictionary dictionary = elide.getElide().getElideSettings().getDictionary();
    Info info = new Info().title(settings.getSwagger().getName()).version(settings.getSwagger().getVersion());
    SwaggerBuilder builder = new SwaggerBuilder(dictionary, info).withLegacyFilterDialect(false);
    return new SwaggerController.SwaggerRegistrations(builder.build().basePath(settings.getJsonApi().getPath()));
}
Also used : SwaggerBuilder(com.yahoo.elide.swagger.SwaggerBuilder) Info(io.swagger.models.Info) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 2 with SwaggerBuilder

use of com.yahoo.elide.swagger.SwaggerBuilder in project elide by yahoo.

the class ElideStandaloneSettings method buildSwagger.

/**
 * Creates a singular swagger document for JSON-API.
 * @param dictionary Contains the static metadata about Elide models. .
 * @return list of swagger registration objects.
 */
default List<DocEndpoint.SwaggerRegistration> buildSwagger(EntityDictionary dictionary) {
    Info info = new Info().title(getSwaggerName()).version(getSwaggerVersion());
    SwaggerBuilder builder = new SwaggerBuilder(dictionary, info);
    String moduleBasePath = getJsonApiPathSpec().replaceAll("/\\*", "");
    Swagger swagger = builder.build().basePath(moduleBasePath);
    List<DocEndpoint.SwaggerRegistration> docs = new ArrayList<>();
    docs.add(new DocEndpoint.SwaggerRegistration("test", swagger));
    return docs;
}
Also used : DocEndpoint(com.yahoo.elide.swagger.resources.DocEndpoint) SwaggerBuilder(com.yahoo.elide.swagger.SwaggerBuilder) Swagger(io.swagger.models.Swagger) ArrayList(java.util.ArrayList) Info(io.swagger.models.Info)

Aggregations

SwaggerBuilder (com.yahoo.elide.swagger.SwaggerBuilder)2 Info (io.swagger.models.Info)2 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 DocEndpoint (com.yahoo.elide.swagger.resources.DocEndpoint)1 Swagger (io.swagger.models.Swagger)1 ArrayList (java.util.ArrayList)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1