Interface AnnotationScanner

All Known Implementing Classes:
AbstractAnnotationScanner

public interface AnnotationScanner
This represent a scanner
Author:
Phillip Kruger (phillip.kruger@redhat.com)
  • Method Details

    • getName

      String getName()
    • scan

      org.eclipse.microprofile.openapi.models.OpenAPI scan(AnnotationScannerContext annotationScannerContext, org.eclipse.microprofile.openapi.models.OpenAPI oai)
    • isAsyncResponse

      boolean isAsyncResponse(org.jboss.jandex.MethodInfo method)
    • isPostMethod

      boolean isPostMethod(org.jboss.jandex.MethodInfo method)
    • isDeleteMethod

      boolean isDeleteMethod(org.jboss.jandex.MethodInfo method)
    • containsScannerAnnotations

      boolean containsScannerAnnotations(List<org.jboss.jandex.AnnotationInstance> instances, List<AnnotationScannerExtension> extensions)
    • setContextRoot

      void setContextRoot(String path)
    • getDefaultConsumes

      String[] getDefaultConsumes(AnnotationScannerContext context, org.jboss.jandex.MethodInfo methodInfo, ResourceParameters params)
    • getDefaultProduces

      String[] getDefaultProduces(AnnotationScannerContext context, org.jboss.jandex.MethodInfo methodInfo)
    • isMultipartOutput

      default boolean isMultipartOutput(org.jboss.jandex.Type returnType)
    • isMultipartInput

      default boolean isMultipartInput(org.jboss.jandex.Type inputType)
    • isScannerInternalResponse

      default boolean isScannerInternalResponse(org.jboss.jandex.Type returnType)
    • isScannerInternalParameter

      default boolean isScannerInternalParameter(org.jboss.jandex.Type parameterType)
    • isWrapperType

      default boolean isWrapperType(org.jboss.jandex.Type type)
    • unwrapType

      default org.jboss.jandex.Type unwrapType(org.jboss.jandex.Type type)
    • processDefinitionAnnotation

      default org.eclipse.microprofile.openapi.models.OpenAPI processDefinitionAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass)
      Process a certain class for OpenApiDefinition annotations.
      Parameters:
      context - the scanning context
      targetClass - the class that contain the server annotation
    • processSecuritySchemeAnnotation

      default void processSecuritySchemeAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
      Process a certain class for security annotations.
      Parameters:
      targetClass - the class that contain the security annotation
      openApi - the current OpenApi model being created
    • processServerAnnotation

      default void processServerAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
      Process a certain class for server annotations.
      Parameters:
      targetClass - the class that contain the server annotation
      openApi - the current OpenApi model being created
    • processJavaSecurity

      default void processJavaSecurity(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resourceClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
      Process Java security (roles allowed and declared roles)
      Parameters:
      resourceClass - the Class being scanned
      openApi - the OpenAPI Model
    • processOperationTags

      default void processOperationTags(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.OpenAPI openApi, Set<String> resourceTags, org.eclipse.microprofile.openapi.models.Operation operation)
      Process tags. Tag and Tags annotations combines with the resource tags we've already found (passed in)
      Parameters:
      method - the REST method
      openApi - the OpenApi model
      resourceTags - tags passed in
      operation - the current operation
    • processTags

      default Set<String> processTags(AnnotationScannerContext context, org.jboss.jandex.AnnotationTarget target, org.eclipse.microprofile.openapi.models.OpenAPI openApi, boolean nullWhenMissing)
      Processes any Tag or Tags annotations present on the annotation target and adds them to the OpenAPI model. The set of tag names found (with iteration order preserved) is returned.
      Parameters:
      target - a MethodInfo or ClassInfo to read for tag annotations
      openApi - OpenAPI model
      nullWhenMissing - determines if an empty set or a null value is returned when no annotations are found.
      Returns:
      the set of tag names found
    • getResourceMethods

      default List<org.jboss.jandex.MethodInfo> getResourceMethods(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resource)
      Extracts all methods from the provided class and its ancestors that are known to the instance's index
      Parameters:
      context - the scanning context
      resource - the resource class
      Returns:
      all methods from the provided class and its ancestors
    • processOperation

      default Optional<org.eclipse.microprofile.openapi.models.Operation> processOperation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resourceClass, org.jboss.jandex.MethodInfo method)
      While scanning JAX-RS/Spring method, find the operations
      Parameters:
      context - the scanning context
      resourceClass - the JAX-RS/Spring concrete resource class
      method - the JAX-RS/Spring method
      Returns:
      Maybe an Operation model
    • setJsonViewContext

      default void setJsonViewContext(AnnotationScannerContext context, org.jboss.jandex.Type[] views)
    • clearJsonViewContext

      default void clearJsonViewContext(AnnotationScannerContext context)
    • processResponse

      default void processResponse(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resourceClass, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation, Map<org.jboss.jandex.DotName,Map<String,org.eclipse.microprofile.openapi.models.responses.APIResponse>> exceptionResponseMap)
    • addResponses

      default void addResponses(org.eclipse.microprofile.openapi.models.Operation operation, Optional<org.eclipse.microprofile.openapi.models.responses.APIResponses> responses, Map<String,org.eclipse.microprofile.openapi.models.responses.APIResponse> singleResponse, boolean includeExtensions)
    • createResponseFromRestMethod

      default void createResponseFromRestMethod(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Called when a scanner (jax-rs, spring) method's APIResponse annotations have all been processed but no response was actually created for the operation.This method will create a response from the method information and add it to the given operation. It will try to do this by examining the method's return value and the type of operation (GET, PUT, POST, DELETE). If there is a return value of some kind (a non-void return type) then the response code is assumed to be 200. If there not a return value (void return type) then either a 201 or 204 is returned, depending on the type of request.
      Parameters:
      context - the scanning context
      method - the current method
      operation - the current operation
    • getDefaultStatus

      default int getDefaultStatus(org.jboss.jandex.MethodInfo method)
      Derives a default HTTP status code for the provided REST endpoint implementation method using the rules defined by @APIResponseSchema#responseCode().
      Parameters:
      method - the endpoint method
      Returns:
      the derived HTTP status
    • isVoidResponse

      default boolean isVoidResponse(org.jboss.jandex.MethodInfo method)
    • isVoidType

      default boolean isVoidType(org.jboss.jandex.Type type)
    • isScannerInternalResponse

      default boolean isScannerInternalResponse(org.jboss.jandex.Type returnType, AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)
    • hasKotlinContinuation

      default boolean hasKotlinContinuation(org.jboss.jandex.MethodInfo method)
    • isKotlinContinuation

      default boolean isKotlinContinuation(org.jboss.jandex.Type paramType)
    • getKotlinContinuationArgument

      default org.jboss.jandex.Type getKotlinContinuationArgument(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)
    • kotlinContinuationToSchema

      default org.eclipse.microprofile.openapi.models.media.Schema kotlinContinuationToSchema(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)
    • generateResponse

      default boolean generateResponse(String status, org.eclipse.microprofile.openapi.models.Operation operation)
      Determine if the default response information should be generated. It should be done when no responses have been declared or if the default response already exists and is missing information (e.g. content).
      Parameters:
      status - the status determined to be the generated default
      operation - current operation
      Returns:
      true if a default response should be generated, otherwise false.
    • addApiReponseSchemaFromAnnotation

      default void addApiReponseSchemaFromAnnotation(Map<String,org.eclipse.microprofile.openapi.models.responses.APIResponse> responseSchema, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Add API response to API responses using the annotation information
      Parameters:
      responseSchema - The APIResponseSchema created from a APIResponseSchema annotation
      method - the current method
      operation - the method operation
    • processSecurityRequirementAnnotation

      default void processSecurityRequirementAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resourceClass, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Get the security requirements on method and class and add them to the openapi model
      Parameters:
      resourceClass - the class
      method - the method
      operation - the operation to add them to
    • isEmptySecurityRequirements

      default boolean isEmptySecurityRequirements(AnnotationScannerContext context, org.jboss.jandex.AnnotationTarget target)
      Determines whether the target is annotated with an empty @SecurityRequirements or @SecurityRequirementsSets annotation.
      Parameters:
      target -
      Returns:
      true if an empty annotation is present, otherwise false
    • processCallback

      default void processCallback(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Process a callback annotation
      Parameters:
      context - the scanning context
      method - the method
      operation - the operation to add this to
    • processServerAnnotation

      default void processServerAnnotation(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Process a certain method for server annotations.
      Parameters:
      method - the method that contain the server annotation
      operation - the current Operation model being created
    • processExtensions

      default void processExtensions(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
      Process the Extensions annotations
      Parameters:
      context - the scanning context
      method - the current REST method
      operation - the current operation
    • processScannerExtensions

      default void processScannerExtensions(AnnotationScannerContext context, Collection<org.jboss.jandex.ClassInfo> applications)
      Scan for scanner extensions
      Parameters:
      context - the scanning context
      applications - the scanner applications
    • processRequestBody

      default org.eclipse.microprofile.openapi.models.parameters.RequestBody processRequestBody(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, ResourceParameters params)
      Process the request body
      Parameters:
      context - the current scanning context
      method - the resource method
      params - the params
      Returns:
      RequestBody model
    • getConsumes

      default String[] getConsumes(AnnotationScannerContext context)
    • getConsumesForRequestBody

      default String[] getConsumesForRequestBody(AnnotationScannerContext context)
    • getRequestBodyParameterClassType

      default org.jboss.jandex.Type getRequestBodyParameterClassType(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, ResourceParameters params)
      Go through the method parameters looking for one that is not a Kotlin Continuation, is not annotated with a jax-rs/spring annotation, and is not a known path parameter. That will be the one that is the request body.
      Parameters:
      context - the scanning context
      method - MethodInfo
      params - the current parameters
      Returns:
      Type
    • setRequestBodyConstraints

      default void setRequestBodyConstraints(AnnotationScannerContext context, org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody, org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type requestBodyType)
    • isPathParameter

      default boolean isPathParameter(AnnotationScannerContext context, String name, ResourceParameters params)
    • isFrameworkContextType

      default boolean isFrameworkContextType(org.jboss.jandex.Type type)
      Determines whether the given type is a special "context" type of the current web/REST framework and should not be considered as a request body type. This method should be overridden by framework-specific annotation scanners.
      Parameters:
      type - the type to consider
      Returns:
      true if the type is a framework-specific special/context type, otherwise false.
    • getReasonPhrase

      default String getReasonPhrase(int statusCode)
      Get the default description for a HTTP Status code
      Parameters:
      statusCode -
      Returns:
      the reason