Package org.springdoc.api
Class AbstractOpenApiResource
- java.lang.Object
-
- io.swagger.v3.core.filter.SpecFilter
-
- org.springdoc.api.AbstractOpenApiResource
-
public abstract class AbstractOpenApiResource extends io.swagger.v3.core.filter.SpecFilterThe type Abstract open api resource.- Author:
- bnasslahsen, kevinraddatz
-
-
Field Summary
Fields Modifier and Type Field Description protected StringgroupNameThe Group name.protected OpenAPIServiceopenAPIServiceThe Open api builder.protected Optional<ActuatorProvider>optionalActuatorProviderThe Actuator provider.protected SpringDocConfigPropertiesspringDocConfigPropertiesThe Spring doc config properties.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOpenApiResource(String groupName, org.springframework.beans.factory.ObjectFactory<OpenAPIService> openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, OperationService operationParser, Optional<List<OperationCustomizer>> operationCustomizers, Optional<List<OpenApiCustomiser>> openApiCustomisers, SpringDocConfigProperties springDocConfigProperties, Optional<ActuatorProvider> actuatorProvider)Instantiates a new Abstract open api resource.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static voidaddHiddenRestControllers(Class<?>... classes)Add hidden rest controllers.static voidaddHiddenRestControllers(String... classes)Add hidden rest controllers.static voidaddRestControllers(Class<?>... classes)Add rest controllers.protected voidcalculatePath(List<RouterOperation> routerOperationList, Locale locale)Calculate path.protected voidcalculatePath(RouterOperation routerOperation, Locale locale)Calculate path.protected voidcalculatePath(org.springframework.web.method.HandlerMethod handlerMethod, String operationPath, Set<org.springframework.web.bind.annotation.RequestMethod> requestMethods, Locale locale)Calculate path.protected voidcalculatePath(org.springframework.web.method.HandlerMethod handlerMethod, RouterOperation routerOperation, Locale locale)Calculate path.static booleancontainsResponseBody(org.springframework.web.method.HandlerMethod handlerMethod)Contains response body boolean.protected io.swagger.v3.oas.models.OperationcustomiseOperation(io.swagger.v3.oas.models.Operation operation, org.springframework.web.method.HandlerMethod handlerMethod)Customise operation operation.protected Stringdecode(String requestURI)Decode string.protected URIgetActuatorURI(String scheme, String host)Gets actuator uri.protected Set<org.springframework.web.bind.annotation.RequestMethod>getDefaultAllowedHttpMethods()Gets default allowed http methods.protected io.swagger.v3.oas.models.OpenAPIgetOpenApi(Locale locale)Gets open api.protected abstract voidgetPaths(Map<String,Object> findRestControllers, Locale locale)Gets paths.protected voidgetRouterFunctionPaths(String beanName, AbstractRouterFunctionVisitor routerFunctionVisitor, Locale locale)Gets router function paths.protected voidinitOpenAPIBuilder(Locale locale)Init open api builder.protected booleanisActuatorRestController(String operationPath, org.springframework.web.method.HandlerMethod handlerMethod)Is actuator rest controller boolean.protected booleanisAdditionalRestController(Class<?> rawClass)Is additional rest controller boolean.protected booleanisConditionToMatch(String[] existingConditions, org.springdoc.api.AbstractOpenApiResource.ConditionType conditionType)Is condition to match boolean.protected booleanisFilterCondition(org.springframework.web.method.HandlerMethod handlerMethod, String operationPath, String[] produces, String[] consumes, String[] headers)Is filter condition boolean.static booleanisHiddenRestControllers(Class<?> rawClass)Is hidden rest controllers boolean.protected booleanisPackageToScan(Package aPackage)Is package to scan boolean.protected booleanisPathToMatch(String operationPath)Is path to match boolean.protected booleanisRestController(Map<String,Object> restControllers, org.springframework.web.method.HandlerMethod handlerMethod, String operationPath)Is rest controller boolean.protected booleanisShowActuator()Is show actuator boolean.protected voidmergeRouters(List<RouterFunctionData> routerFunctionDatas, List<RouterOperation> routerOperationList)Merge routers.protected StringwriteJsonValue(io.swagger.v3.oas.models.OpenAPI openAPI)Write json value string.protected StringwriteYamlValue(io.swagger.v3.oas.models.OpenAPI openAPI)Write yaml value string.
-
-
-
Field Detail
-
openAPIService
protected OpenAPIService openAPIService
The Open api builder.
-
springDocConfigProperties
protected final SpringDocConfigProperties springDocConfigProperties
The Spring doc config properties.
-
optionalActuatorProvider
protected final Optional<ActuatorProvider> optionalActuatorProvider
The Actuator provider.
-
groupName
protected final String groupName
The Group name.
-
-
Constructor Detail
-
AbstractOpenApiResource
protected AbstractOpenApiResource(String groupName, org.springframework.beans.factory.ObjectFactory<OpenAPIService> openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, OperationService operationParser, Optional<List<OperationCustomizer>> operationCustomizers, Optional<List<OpenApiCustomiser>> openApiCustomisers, SpringDocConfigProperties springDocConfigProperties, Optional<ActuatorProvider> actuatorProvider)
Instantiates a new Abstract open api resource.- Parameters:
groupName- the group nameopenAPIBuilderObjectFactory- the open api builder object factoryrequestBuilder- the request builderresponseBuilder- the response builderoperationParser- the operation parseroperationCustomizers- the operation customizersopenApiCustomisers- the open api customisersspringDocConfigProperties- the spring doc config propertiesactuatorProvider- the actuator provider
-
-
Method Detail
-
addRestControllers
public static void addRestControllers(Class<?>... classes)
Add rest controllers.- Parameters:
classes- the classes
-
addHiddenRestControllers
public static void addHiddenRestControllers(Class<?>... classes)
Add hidden rest controllers.- Parameters:
classes- the classes
-
addHiddenRestControllers
public static void addHiddenRestControllers(String... classes)
Add hidden rest controllers.- Parameters:
classes- the classes
-
getOpenApi
protected io.swagger.v3.oas.models.OpenAPI getOpenApi(Locale locale)
Gets open api.- Parameters:
locale- the locale- Returns:
- the open api
-
getPaths
protected abstract void getPaths(Map<String,Object> findRestControllers, Locale locale)
Gets paths.- Parameters:
findRestControllers- the find rest controllerslocale- the locale
-
calculatePath
protected void calculatePath(org.springframework.web.method.HandlerMethod handlerMethod, RouterOperation routerOperation, Locale locale)Calculate path.- Parameters:
handlerMethod- the handler methodrouterOperation- the router operationlocale- the locale
-
calculatePath
protected void calculatePath(List<RouterOperation> routerOperationList, Locale locale)
Calculate path.- Parameters:
routerOperationList- the router operation listlocale- the locale
-
calculatePath
protected void calculatePath(RouterOperation routerOperation, Locale locale)
Calculate path.- Parameters:
routerOperation- the router operationlocale- the locale
-
calculatePath
protected void calculatePath(org.springframework.web.method.HandlerMethod handlerMethod, String operationPath, Set<org.springframework.web.bind.annotation.RequestMethod> requestMethods, Locale locale)Calculate path.- Parameters:
handlerMethod- the handler methodoperationPath- the operation pathrequestMethods- the request methodslocale- the locale
-
getRouterFunctionPaths
protected void getRouterFunctionPaths(String beanName, AbstractRouterFunctionVisitor routerFunctionVisitor, Locale locale)
Gets router function paths.- Parameters:
beanName- the bean namerouterFunctionVisitor- the router function visitorlocale- the locale
-
isFilterCondition
protected boolean isFilterCondition(org.springframework.web.method.HandlerMethod handlerMethod, String operationPath, String[] produces, String[] consumes, String[] headers)Is filter condition boolean.- Parameters:
handlerMethod- the handler methodoperationPath- the operation pathproduces- the producesconsumes- the consumesheaders- the headers- Returns:
- the boolean
-
isConditionToMatch
protected boolean isConditionToMatch(String[] existingConditions, org.springdoc.api.AbstractOpenApiResource.ConditionType conditionType)
Is condition to match boolean.- Parameters:
existingConditions- the existing conditionsconditionType- the condition type- Returns:
- the boolean
-
isPackageToScan
protected boolean isPackageToScan(Package aPackage)
Is package to scan boolean.- Parameters:
aPackage- the a package- Returns:
- the boolean
-
isPathToMatch
protected boolean isPathToMatch(String operationPath)
Is path to match boolean.- Parameters:
operationPath- the operation path- Returns:
- the boolean
-
decode
protected String decode(String requestURI)
Decode string.- Parameters:
requestURI- the request uri- Returns:
- the string
-
isAdditionalRestController
protected boolean isAdditionalRestController(Class<?> rawClass)
Is additional rest controller boolean.- Parameters:
rawClass- the raw class- Returns:
- the boolean
-
containsResponseBody
public static boolean containsResponseBody(org.springframework.web.method.HandlerMethod handlerMethod)
Contains response body boolean.- Parameters:
handlerMethod- the handler method- Returns:
- the boolean
-
isRestController
protected boolean isRestController(Map<String,Object> restControllers, org.springframework.web.method.HandlerMethod handlerMethod, String operationPath)
Is rest controller boolean.- Parameters:
restControllers- the rest controllershandlerMethod- the handler methodoperationPath- the operation path- Returns:
- the boolean
-
isHiddenRestControllers
public static boolean isHiddenRestControllers(Class<?> rawClass)
Is hidden rest controllers boolean.- Parameters:
rawClass- the raw class- Returns:
- the boolean
-
getDefaultAllowedHttpMethods
protected Set<org.springframework.web.bind.annotation.RequestMethod> getDefaultAllowedHttpMethods()
Gets default allowed http methods.- Returns:
- the default allowed http methods
-
customiseOperation
protected io.swagger.v3.oas.models.Operation customiseOperation(io.swagger.v3.oas.models.Operation operation, org.springframework.web.method.HandlerMethod handlerMethod)Customise operation operation.- Parameters:
operation- the operationhandlerMethod- the handler method- Returns:
- the operation
-
mergeRouters
protected void mergeRouters(List<RouterFunctionData> routerFunctionDatas, List<RouterOperation> routerOperationList)
Merge routers.- Parameters:
routerFunctionDatas- the router function datasrouterOperationList- the router operation list
-
initOpenAPIBuilder
protected void initOpenAPIBuilder(Locale locale)
Init open api builder.
-
writeYamlValue
protected String writeYamlValue(io.swagger.v3.oas.models.OpenAPI openAPI) throws com.fasterxml.jackson.core.JsonProcessingException
Write yaml value string.- Parameters:
openAPI- the open api- Returns:
- the string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
getActuatorURI
protected URI getActuatorURI(String scheme, String host)
Gets actuator uri.- Parameters:
scheme- the schemehost- the host- Returns:
- the actuator uri
-
isShowActuator
protected boolean isShowActuator()
Is show actuator boolean.- Returns:
- the boolean
-
isActuatorRestController
protected boolean isActuatorRestController(String operationPath, org.springframework.web.method.HandlerMethod handlerMethod)
Is actuator rest controller boolean.- Parameters:
operationPath- the operation pathhandlerMethod- the handler method- Returns:
- the boolean
-
writeJsonValue
protected String writeJsonValue(io.swagger.v3.oas.models.OpenAPI openAPI) throws com.fasterxml.jackson.core.JsonProcessingException
Write json value string.- Parameters:
openAPI- the open api- Returns:
- the string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
-