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.SpecFilter
The type Abstract open api resource.
Author:
bnasslahsen, kevinraddatz, hyeonisism, doljae
  • Field Details

    • springDocConfigProperties

      protected final SpringDocConfigProperties springDocConfigProperties
      The Spring doc config properties.
    • groupName

      protected final String groupName
      The Group name.
    • springDocProviders

      protected final SpringDocProviders springDocProviders
      The Spring doc providers.
    • openAPIService

      protected OpenAPIService openAPIService
      The Open api builder.
    • springDocCustomizers

      protected final SpringDocCustomizers springDocCustomizers
      The Spring doc customizers.
  • Constructor Details

    • AbstractOpenApiResource

      protected AbstractOpenApiResource(String groupName, org.springframework.beans.factory.ObjectFactory<OpenAPIService> openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, OperationService operationParser, SpringDocConfigProperties springDocConfigProperties, SpringDocProviders springDocProviders, SpringDocCustomizers springDocCustomizers)
      Instantiates a new Abstract open api resource.
      Parameters:
      groupName - the group name
      openAPIBuilderObjectFactory - the open api builder object factory
      requestBuilder - the request builder
      responseBuilder - the response builder
      operationParser - the operation parser
      springDocConfigProperties - the spring doc config properties
      springDocProviders - the spring doc providers
      springDocCustomizers - the spring doc customizers
  • Method Details

    • 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
    • containsResponseBody

      public static boolean containsResponseBody(org.springframework.web.method.HandlerMethod handlerMethod)
      Contains response body boolean.
      Parameters:
      handlerMethod - the handler method
      Returns:
      the boolean
    • isHiddenRestControllers

      public static boolean isHiddenRestControllers(Class<?> rawClass)
      Is hidden rest controllers boolean.
      Parameters:
      rawClass - the raw class
      Returns:
      the boolean
    • setModelAndViewClass

      public static void setModelAndViewClass(Class<?> modelAndViewClass)
      Sets model and view class.
      Parameters:
      modelAndViewClass - the model and view class
    • 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, io.swagger.v3.oas.models.OpenAPI openAPI)
      Gets paths.
      Parameters:
      findRestControllers - the find rest controllers
      locale - the locale
      openAPI - the open api
    • calculatePath

      protected void calculatePath(org.springframework.web.method.HandlerMethod handlerMethod, RouterOperation routerOperation, Locale locale, io.swagger.v3.oas.models.OpenAPI openAPI)
      Calculate path.
      Parameters:
      handlerMethod - the handler method
      routerOperation - the router operation
      locale - the locale
      openAPI - the open api
    • calculatePath

      protected void calculatePath(List<RouterOperation> routerOperationList, Locale locale, io.swagger.v3.oas.models.OpenAPI openAPI)
      Calculate path.
      Parameters:
      routerOperationList - the router operation list
      locale - the locale
      openAPI - the open api
    • calculatePath

      protected void calculatePath(RouterOperation routerOperation, Locale locale, io.swagger.v3.oas.models.OpenAPI openAPI)
      Calculate path.
      Parameters:
      routerOperation - the router operation
      locale - the locale
    • calculatePath

      protected void calculatePath(org.springframework.web.method.HandlerMethod handlerMethod, String operationPath, Set<org.springframework.web.bind.annotation.RequestMethod> requestMethods, String[] consumes, String[] produces, String[] headers, String[] params, Locale locale, io.swagger.v3.oas.models.OpenAPI openAPI)
      Calculate path.
      Parameters:
      handlerMethod - the handler method
      operationPath - the operation path
      requestMethods - the request methods
      consumes - the consumes
      produces - the produces
      headers - the headers
      locale - the locale
    • getRouterFunctionPaths

      protected void getRouterFunctionPaths(String beanName, AbstractRouterFunctionVisitor routerFunctionVisitor, Locale locale, io.swagger.v3.oas.models.OpenAPI openAPI)
      Gets router function paths.
      Parameters:
      beanName - the bean name
      routerFunctionVisitor - the router function visitor
      locale - the locale
      openAPI - the open api
    • 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 method
      operationPath - the operation path
      produces - the produces
      consumes - the consumes
      headers - the headers
      Returns:
      the boolean
    • isMethodToFilter

      protected boolean isMethodToFilter(org.springframework.web.method.HandlerMethod handlerMethod)
      Is target method suitable for inclusion in current documentation/
      Parameters:
      handlerMethod - the method to check
      Returns:
      whether the method should be included in the current OpenAPI definition
    • isConditionToMatch

      protected boolean isConditionToMatch(String[] existingConditions, org.springdoc.api.AbstractOpenApiResource.ConditionType conditionType)
      Is condition to match boolean.
      Parameters:
      existingConditions - the existing conditions
      conditionType - 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
    • isRestController

      protected boolean isRestController(Map<String,Object> restControllers, org.springframework.web.method.HandlerMethod handlerMethod, String operationPath)
      Is rest controller boolean.
      Parameters:
      restControllers - the rest controllers
      handlerMethod - the handler method
      operationPath - the operation path
      Returns:
      the boolean
    • getDefaultAllowedHttpMethods

      protected Set<org.springframework.web.bind.annotation.RequestMethod> getDefaultAllowedHttpMethods()
      Gets default allowed http methods.
      Returns:
      the default allowed http methods
    • customizeOperation

      protected io.swagger.v3.oas.models.Operation customizeOperation(io.swagger.v3.oas.models.Operation operation, org.springframework.web.method.HandlerMethod handlerMethod)
      Customise operation.
      Parameters:
      operation - the operation
      handlerMethod - the handler method
      Returns:
      the operation
    • customizeRouterOperation

      protected RouterOperation customizeRouterOperation(RouterOperation routerOperation, org.springframework.web.method.HandlerMethod handlerMethod)
      Customise router operation
      Parameters:
      routerOperation - the router operation
      handlerMethod - the handler method
      Returns:
      the router operation
    • mergeRouters

      protected void mergeRouters(List<RouterFunctionData> routerFunctionDatas, List<RouterOperation> routerOperationList)
      Merge routers.
      Parameters:
      routerFunctionDatas - the router function datas
      routerOperationList - the router operation list
    • initOpenAPIBuilder

      protected void initOpenAPIBuilder(Locale locale)
      Init open api builder.
      Parameters:
      locale - the locale
    • writeYamlValue

      protected byte[] 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 scheme
      host - the host
      Returns:
      the actuator uri
    • isActuatorRestController

      protected boolean isActuatorRestController(String operationPath, org.springframework.web.method.HandlerMethod handlerMethod)
      Is actuator rest controller boolean.
      Parameters:
      operationPath - the operation path
      handlerMethod - the handler method
      Returns:
      the boolean
    • writeJsonValue

      protected byte[] 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