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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpincastOpenApiManagerDefault(Router<R, W> router, JsonManager jsonManager, SpincastOpenApiBottomUpPluginConfig spincastOpenApiBottomUpPluginConfig, SwaggerAnnotationsCreator annotationsCreator, DefaultRouteParamAliasesBinder<R, W> defaultRouteParamAliasesBinder) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConsumesAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs, Route<R> route) protected voidaddHttpMethodAnnotation(List<Annotation> handlerMethodAnnotations, HttpMethod httpMethod) protected voidaddOperationAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs) protected voidaddParametersAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, String routePath, Specs specs) protected voidaddPathAnnotationToHandlerMethod(List<Annotation> handlerMethodAannotations, String routePath) protected voidaddProducesAnnotationToHandlerMethod(List<Annotation> handlerMethodAnnotations, Specs specs) protected voidaddYamlStringSpecifiedPaths(io.swagger.v3.oas.models.OpenAPI openApi) voidDelete cache so the Open API object is computed from scratch.protected HttpMethodconvertHttpMethodToSpincast(io.swagger.v3.oas.models.PathItem.HttpMethod httpMethod) protected StringconvertSpincastRoutePathToOpenApiFormat(String spincastRoutePath) Convert dynamic path parameters to Open API format.protected StringcreateHttpMethodAndPathKey(HttpMethod method, String path) protected StringcreateOperationId(Route<R> route, HttpMethod httpMethod) protected Stringprotected Stringprotected io.swagger.v3.oas.integration.api.OpenApiScannercreateScanner(Set<Class<?>> classes) This method will dynamically create and annotate classes to simulate a JAX-RS application.protected SwaggerAnnotationsCreatorio.swagger.v3.oas.models.OpenAPIprotected DefaultRouteParamAliasesBinder<R,W> protected AnnotationgetHttpMethodAnnotation(HttpMethod httpMethod) protected JsonManagerio.swagger.v3.oas.models.OpenAPIThe 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 Stringprotected io.swagger.v3.oas.models.PathsgetPathsFromYamlString(String routePath, String specs) protected SpecsgetSpecsAnnotation(Object specsObj) protected SpincastOpenApiBottomUpPluginConfigvoidignoreRoutesByIds(String... ids) Ignore routes using their ids.voidignoreRouteUsingHttpMethodAndPath(HttpMethod method, String path) Ignore a route using its HTTP method and path.protected booleanisOperationAnnotationContainsParameter(io.swagger.v3.oas.annotations.Operation operationAnnotation, String paramName) protected booleanisSupportedHttpMethod(HttpMethod httpMethod) protected booleanisToHideFromHttpMethodAndPath(Route<R> route, HttpMethod httpMethod) protected booleanisToHideFromId(Route<R> route) voidresetAll()Reset everything : delete caches, delete ignored routes, etc.voidsetOpenApiBase(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:
clearCachein interfaceSpincastOpenApiManager
-
resetAll
public void resetAll()Description copied from interface:SpincastOpenApiManagerReset everything : delete caches, delete ignored routes, etc.- Specified by:
resetAllin interfaceSpincastOpenApiManager
-
setOpenApiBase
public void setOpenApiBase(io.swagger.v3.oas.models.OpenAPI baseOpenApiInfo) Description copied from interface:SpincastOpenApiManagerThe 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:
setOpenApiBasein interfaceSpincastOpenApiManager
-
getBaseOpenApiInfo
public io.swagger.v3.oas.models.OpenAPI getBaseOpenApiInfo() -
getOpenApi
public io.swagger.v3.oas.models.OpenAPI getOpenApi()Description copied from interface:SpincastOpenApiManagerThe generated specifications as a OpenAPI object.- Specified by:
getOpenApiin 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 theOpenAPIobject. -
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:SpincastOpenApiManagerThe generated specifications as pretty formatted JSON.- Specified by:
getOpenApiAsJsonin interfaceSpincastOpenApiManager
-
getOpenApiAsJson
Description copied from interface:SpincastOpenApiManagerThe generated specifications as JSON.- Specified by:
getOpenApiAsJsonin interfaceSpincastOpenApiManager
-
getOpenApiAsYaml
Description copied from interface:SpincastOpenApiManagerThe generated specifications as pretty formatted YAML.- Specified by:
getOpenApiAsYamlin interfaceSpincastOpenApiManager
-
getOpenApiAsYaml
Description copied from interface:SpincastOpenApiManagerThe generated specifications as YAML.- Specified by:
getOpenApiAsYamlin interfaceSpincastOpenApiManager
-
ignoreRoutesByIds
Description copied from interface:SpincastOpenApiManagerIgnore routes using their ids.- Specified by:
ignoreRoutesByIdsin interfaceSpincastOpenApiManager
-
createHttpMethodAndPathKey
-
ignoreRouteUsingHttpMethodAndPath
Description copied from interface:SpincastOpenApiManagerIgnore a route using its HTTP method and path.- Specified by:
ignoreRouteUsingHttpMethodAndPathin 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)
-