Package com.yahoo.elide.swagger
Class SwaggerBuilder
- java.lang.Object
-
- com.yahoo.elide.swagger.SwaggerBuilder
-
public class SwaggerBuilder extends Object
Builds a 'Swagger' object from Swagger-Core by walking the static Elide entity metadata contained in the 'EntityDictionary'. The 'Swagger' object can be used to generate a Swagger document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSwaggerBuilder.PathMetaDataMetadata for constructing URLs and Swagger 'Path' objects.
-
Field Summary
Fields Modifier and Type Field Description protected Set<com.yahoo.elide.core.type.Type<?>>allClassesprotected com.yahoo.elide.core.dictionary.EntityDictionarydictionaryprotected Set<com.yahoo.elide.core.filter.Operator>filterOperatorsstatic io.swagger.models.ResponseFORBIDDEN_RESPONSEprotected Set<io.swagger.models.parameters.Parameter>globalParamsprotected Map<Integer,io.swagger.models.Response>globalResponsesstatic io.swagger.models.ResponseNOT_FOUND_RESPONSEstatic io.swagger.models.ResponseREQUEST_TIMEOUT_RESPONSEprotected Set<com.yahoo.elide.core.type.Type<?>>rootClassesprotected booleansupportLegacyDialectprotected booleansupportRSQLDialectprotected io.swagger.models.Swaggerswaggerstatic io.swagger.models.ResponseTOO_MANY_REQUESTS_RESPONSEstatic io.swagger.models.ResponseUNAUTHORIZED_RESPONSE
-
Constructor Summary
Constructors Constructor Description SwaggerBuilder(com.yahoo.elide.core.dictionary.EntityDictionary dictionary, io.swagger.models.Info info)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.swagger.models.Swaggerbuild()Builds a swagger object.protected Set<SwaggerBuilder.PathMetaData>find(com.yahoo.elide.core.type.Type<?> rootClass)Finds all the paths by navigating the entity relationship graph - starting at the given root entity.static StringgetDocument(io.swagger.models.Swagger swagger)Converts a swagger document to human-formatted JSON.SwaggerBuilderwithExplicitClassList(Set<com.yahoo.elide.core.type.Type<?>> classes)The classes for which API paths will be generated.SwaggerBuilderwithFilterOps(Set<com.yahoo.elide.core.filter.Operator> ops)Assigns a subset of the complete set of filter operations to support for each GET operation.SwaggerBuilderwithGlobalParameter(io.swagger.models.parameters.Parameter param)Decorates every path with the given parameter.SwaggerBuilderwithGlobalResponse(int code, io.swagger.models.Response response)Decorates every operation on every path with the given response.SwaggerBuilderwithLegacyFilterDialect(boolean enableLegacyDialect)Turns on or off the legacy filter dialect.SwaggerBuilderwithRSQLFilterDialect(boolean enableRSQLDialect)Turns on or off the RSQL filter dialect.
-
-
-
Field Detail
-
dictionary
protected com.yahoo.elide.core.dictionary.EntityDictionary dictionary
-
rootClasses
protected Set<com.yahoo.elide.core.type.Type<?>> rootClasses
-
allClasses
protected Set<com.yahoo.elide.core.type.Type<?>> allClasses
-
swagger
protected io.swagger.models.Swagger swagger
-
globalParams
protected Set<io.swagger.models.parameters.Parameter> globalParams
-
filterOperators
protected Set<com.yahoo.elide.core.filter.Operator> filterOperators
-
supportLegacyDialect
protected boolean supportLegacyDialect
-
supportRSQLDialect
protected boolean supportRSQLDialect
-
UNAUTHORIZED_RESPONSE
public static final io.swagger.models.Response UNAUTHORIZED_RESPONSE
-
FORBIDDEN_RESPONSE
public static final io.swagger.models.Response FORBIDDEN_RESPONSE
-
NOT_FOUND_RESPONSE
public static final io.swagger.models.Response NOT_FOUND_RESPONSE
-
REQUEST_TIMEOUT_RESPONSE
public static final io.swagger.models.Response REQUEST_TIMEOUT_RESPONSE
-
TOO_MANY_REQUESTS_RESPONSE
public static final io.swagger.models.Response TOO_MANY_REQUESTS_RESPONSE
-
-
Method Detail
-
withGlobalResponse
public SwaggerBuilder withGlobalResponse(int code, io.swagger.models.Response response)
Decorates every operation on every path with the given response.- Parameters:
code- The HTTP status code to associate with the responseresponse- The global response to add to every operation- Returns:
- the builder
-
withLegacyFilterDialect
public SwaggerBuilder withLegacyFilterDialect(boolean enableLegacyDialect)
Turns on or off the legacy filter dialect.- Parameters:
enableLegacyDialect- Whether or not to enable the legacy filter dialect.- Returns:
- the builder
-
withRSQLFilterDialect
public SwaggerBuilder withRSQLFilterDialect(boolean enableRSQLDialect)
Turns on or off the RSQL filter dialect.- Parameters:
enableRSQLDialect- Whether or not to enable the RSQL filter dialect.- Returns:
- the builder
-
withGlobalParameter
public SwaggerBuilder withGlobalParameter(io.swagger.models.parameters.Parameter param)
Decorates every path with the given parameter.- Parameters:
param- the parameter to decorate- Returns:
- the builder
-
withExplicitClassList
public SwaggerBuilder withExplicitClassList(Set<com.yahoo.elide.core.type.Type<?>> classes)
The classes for which API paths will be generated. All paths that include other entities are dropped.- Parameters:
classes- A subset of the entities in the entity dictionary.- Returns:
- the builder
-
withFilterOps
public SwaggerBuilder withFilterOps(Set<com.yahoo.elide.core.filter.Operator> ops)
Assigns a subset of the complete set of filter operations to support for each GET operation.- Parameters:
ops- The subset of filter operations to support.- Returns:
- the builder
-
build
public io.swagger.models.Swagger build()
Builds a swagger object.- Returns:
- the constructed 'Swagger' object
-
find
protected Set<SwaggerBuilder.PathMetaData> find(com.yahoo.elide.core.type.Type<?> rootClass)
Finds all the paths by navigating the entity relationship graph - starting at the given root entity. Cycles are avoided.- Parameters:
rootClass- the starting node of the graph- Returns:
- set of discovered paths.
-
getDocument
public static String getDocument(io.swagger.models.Swagger swagger)
Converts a swagger document to human-formatted JSON.- Parameters:
swagger- Swagger-Core swagger POJO- Returns:
- Pretty printed 'Swagger' document in JSON.
-
-