Class SpincastOpenApiManagerDefault<R extends RequestContext<?>,W extends WebsocketContext<?>>
java.lang.Object
org.spincast.plugins.openapi.bottomup.SpincastOpenApiManagerDefault<R,W>
- All Implemented Interfaces:
SpincastOpenApiManager
public class SpincastOpenApiManagerDefault<R extends RequestContext<?>,W extends WebsocketContext<?>>
extends Object
implements SpincastOpenApiManager
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSpincastOpenApiManagerDefault
(Router<R, W> router, JsonManager jsonManager, SpincastOpenApiBottomUpPluginConfig spincastOpenApiBottomUpPluginConfig, SwaggerAnnotationsCreator annotationsCreator, DefaultRouteParamAliasesBinder<R, W> defaultRouteParamAliasesBinder) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addConsumesAnnotationToHandlerMethod
(List<Annotation> handlerMethodAnnotations, Specs specs, Route<R> route) protected void
addHttpMethodAnnotation
(List<Annotation> handlerMethodAnnotations, HttpMethod httpMethod) protected void
addOperationAnnotationToHandlerMethod
(List<Annotation> handlerMethodAnnotations, Specs specs) protected void
addParametersAnnotationToHandlerMethod
(List<Annotation> handlerMethodAnnotations, String routePath, Specs specs) protected void
addPathAnnotationToHandlerMethod
(List<Annotation> handlerMethodAannotations, String routePath) protected void
addProducesAnnotationToHandlerMethod
(List<Annotation> handlerMethodAnnotations, Specs specs) protected void
addYamlStringSpecifiedPaths
(io.swagger.v3.oas.models.OpenAPI openApi) void
Delete cache so the Open API object is computed from scratch.protected HttpMethod
convertHttpMethodToSpincast
(io.swagger.v3.oas.models.PathItem.HttpMethod httpMethod) protected String
convertSpincastRoutePathToOpenApiFormat
(String spincastRoutePath) Convert dynamic path parameters to Open API format.protected String
createHttpMethodAndPathKey
(HttpMethod method, String path) protected String
createOperationId
(Route<R> route, HttpMethod httpMethod) protected String
protected String
protected io.swagger.v3.oas.integration.api.OpenApiScanner
createScanner
(Set<Class<?>> classes) This method will dynamically create and annotate classes to simulate a JAX-RS application.protected SwaggerAnnotationsCreator
io.swagger.v3.oas.models.OpenAPI
protected DefaultRouteParamAliasesBinder<R,
W> protected Annotation
getHttpMethodAnnotation
(HttpMethod httpMethod) protected JsonManager
io.swagger.v3.oas.models.OpenAPI
The generated specifications as a OpenAPI object.The generated specifications as pretty formatted JSON.getOpenApiAsJson
(boolean prettyFormatted) The generated specifications as JSON.The generated specifications as pretty formatted YAML.getOpenApiAsYaml
(boolean prettyFormatted) The generated specifications as YAML.protected String
protected io.swagger.v3.oas.models.Paths
getPathsFromYamlString
(String routePath, String specs) protected Specs
getSpecsAnnotation
(Object specsObj) protected SpincastOpenApiBottomUpPluginConfig
void
ignoreRoutesByIds
(String... ids) Ignore routes using their ids.void
ignoreRouteUsingHttpMethodAndPath
(HttpMethod method, String path) Ignore a route using its HTTP method and path.protected boolean
isOperationAnnotationContainsParameter
(io.swagger.v3.oas.annotations.Operation operationAnnotation, String paramName) protected boolean
isSupportedHttpMethod
(HttpMethod httpMethod) protected boolean
isToHideFromHttpMethodAndPath
(Route<R> route, HttpMethod httpMethod) protected boolean
isToHideFromId
(Route<R> route) void
resetAll()
Reset everything : delete caches, delete ignored routes, etc.void
setOpenApiBase
(io.swagger.v3.oas.models.OpenAPI baseOpenApiInfo) The base OpenAPI informations for the generated specs file.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
SpincastOpenApiManagerDefault
@Inject public SpincastOpenApiManagerDefault(Router<R, W> router, JsonManager jsonManager, SpincastOpenApiBottomUpPluginConfig spincastOpenApiBottomUpPluginConfig, SwaggerAnnotationsCreator annotationsCreator, DefaultRouteParamAliasesBinder<R, W> defaultRouteParamAliasesBinder)
-
-
Method Details
-
getRouter
-
getJsonManager
-
getSpincastOpenApiBottomUpPluginConfig
-
getAnnotationsCreator
-
getDefaultRouteParamAliasesBinder
-
getRouteIdsToHide
-
getRouteHttpMethodAndPathToHide
-
clearCache
public void clearCache()Delete cache so the Open API object is computed from scratch.- Specified by:
clearCache
in interfaceSpincastOpenApiManager
-
resetAll
public void resetAll()Description copied from interface:SpincastOpenApiManager
Reset everything : delete caches, delete ignored routes, etc.- Specified by:
resetAll
in interfaceSpincastOpenApiManager
-
setOpenApiBase
public void setOpenApiBase(io.swagger.v3.oas.models.OpenAPI baseOpenApiInfo) Description copied from interface:SpincastOpenApiManager
The base OpenAPI informations for the generated specs file.This can be a full and standalone OpenAPI object, containing your paths, models, etc. Or it can be the base information to which specs specific to each routes will be added.
- Specified by:
setOpenApiBase
in interfaceSpincastOpenApiManager
-
getBaseOpenApiInfo
public io.swagger.v3.oas.models.OpenAPI getBaseOpenApiInfo() -
getOpenApi
public io.swagger.v3.oas.models.OpenAPI getOpenApi()Description copied from interface:SpincastOpenApiManager
The generated specifications as a OpenAPI object.- Specified by:
getOpenApi
in interfaceSpincastOpenApiManager
- Parameters:
force
- Iftrue
, cache will be bypassed on updated.
-
createScanner
-
generateJaxRsLikeClasses
This method will dynamically create and annotate classes to simulate a JAX-RS application. This way, we can reuse the logic from swagger-jaxrs2 to generate theOpenAPI
object. -
isSupportedHttpMethod
-
getPathsFromYamlString
-
getOpenApiPrefix
-
isToHideFromId
-
isToHideFromHttpMethodAndPath
-
createOperationId
-
addHttpMethodAnnotation
protected void addHttpMethodAnnotation(List<Annotation> handlerMethodAnnotations, HttpMethod httpMethod) -
getHttpMethodAnnotation
-
addPathAnnotationToHandlerMethod
protected void addPathAnnotationToHandlerMethod(List<Annotation> handlerMethodAannotations, String routePath) -
convertSpincastRoutePathToOpenApiFormat
Convert dynamic path parameters to Open API format./${param1}/${param3:\\d+}/${param4:<A>}
=>
/{param1}/{param2}/{param3}
-
getSpecsAnnotation
-
addOperationAnnotationToHandlerMethod
protected void addOperationAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs) -
addParametersAnnotationToHandlerMethod
protected void addParametersAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, String routePath, Specs specs) -
createParamDescriptionFromAlias
-
createParamPatternFromAlias
-
isOperationAnnotationContainsParameter
protected boolean isOperationAnnotationContainsParameter(io.swagger.v3.oas.annotations.Operation operationAnnotation, String paramName) -
addConsumesAnnotationToHandlerMethod
protected void addConsumesAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs, Route<R> route) -
addProducesAnnotationToHandlerMethod
protected void addProducesAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs) -
getOpenApiAsJson
Description copied from interface:SpincastOpenApiManager
The generated specifications as pretty formatted JSON.- Specified by:
getOpenApiAsJson
in interfaceSpincastOpenApiManager
-
getOpenApiAsJson
Description copied from interface:SpincastOpenApiManager
The generated specifications as JSON.- Specified by:
getOpenApiAsJson
in interfaceSpincastOpenApiManager
-
getOpenApiAsYaml
Description copied from interface:SpincastOpenApiManager
The generated specifications as pretty formatted YAML.- Specified by:
getOpenApiAsYaml
in interfaceSpincastOpenApiManager
-
getOpenApiAsYaml
Description copied from interface:SpincastOpenApiManager
The generated specifications as YAML.- Specified by:
getOpenApiAsYaml
in interfaceSpincastOpenApiManager
-
ignoreRoutesByIds
Description copied from interface:SpincastOpenApiManager
Ignore routes using their ids.- Specified by:
ignoreRoutesByIds
in interfaceSpincastOpenApiManager
-
createHttpMethodAndPathKey
-
ignoreRouteUsingHttpMethodAndPath
Description copied from interface:SpincastOpenApiManager
Ignore a route using its HTTP method and path.- Specified by:
ignoreRouteUsingHttpMethodAndPath
in interfaceSpincastOpenApiManager
- Parameters:
method
- Ifnull
, all HTTP methods will be used.
-
addYamlStringSpecifiedPaths
protected void addYamlStringSpecifiedPaths(io.swagger.v3.oas.models.OpenAPI openApi) -
convertHttpMethodToSpincast
protected HttpMethod convertHttpMethodToSpincast(io.swagger.v3.oas.models.PathItem.HttpMethod httpMethod)
-