Interface AnnotationScanner
-
- All Known Implementing Classes:
AbstractAnnotationScanner
public interface AnnotationScanner
This represent a scanner- Author:
- Phillip Kruger ([email protected])
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
addApiReponseFromAnnotation(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance apiResponseAnnotation, org.eclipse.microprofile.openapi.models.Operation operation)
Add api response to api responses using the annotation informationdefault void
addApiReponseSchemaFromAnnotation(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
Add api response to api responses using the annotation informationboolean
containsScannerAnnotations(List<org.jboss.jandex.AnnotationInstance> instances, List<AnnotationScannerExtension> extensions)
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.default boolean
generateResponse(String status, org.eclipse.microprofile.openapi.models.Operation operation)
Determine if the default response information should be generated.default String[]
getConsumes(AnnotationScannerContext context)
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().String
getName()
default String
getReasonPhrase(int statusCode)
Get the default description for a HTTP Status codedefault org.jboss.jandex.Type
getRequestBodyParameterClassType(org.jboss.jandex.MethodInfo method, List<AnnotationScannerExtension> extensions)
Go through the method parameters looking for one that is not annotated with a jax-rs/spring annotation.That will be the one that is the request body.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 indexboolean
isAsyncResponse(org.jboss.jandex.MethodInfo method)
boolean
isDeleteMethod(org.jboss.jandex.MethodInfo method)
default boolean
isEmptySecurityRequirements(org.jboss.jandex.AnnotationTarget target)
Determines whether the target is annotated with an empty@SecurityRequirements
annotation.default boolean
isKotlinContinuation(org.jboss.jandex.MethodInfo method)
default boolean
isMultipartInput(org.jboss.jandex.Type inputType)
default boolean
isMultipartOutput(org.jboss.jandex.Type returnType)
boolean
isPostMethod(org.jboss.jandex.MethodInfo method)
default boolean
isScannerInternalParameter(org.jboss.jandex.Type parameterType)
default boolean
isScannerInternalResponse(org.jboss.jandex.Type returnType)
default boolean
isVoidResponse(org.jboss.jandex.MethodInfo method)
default boolean
isWrapperType(org.jboss.jandex.Type type)
default org.eclipse.microprofile.openapi.models.media.Schema
kotlinContinuationToSchema(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)
default void
processCallback(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
Process a callback annotationdefault void
processDefinitionAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process a certain class for OpenApiDefinition annotations.default void
processExtensions(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
Process the Extensions annotationsdefault void
processJavaSecurity(org.jboss.jandex.ClassInfo resourceClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process Java security (roles allowed and declared roles)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 operationsdefault 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.default org.eclipse.microprofile.openapi.models.parameters.RequestBody
processRequestBody(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, ResourceParameters params)
Process the request bodydefault void
processResponse(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation, Map<org.jboss.jandex.DotName,org.jboss.jandex.AnnotationInstance> exceptionAnnotationMap)
default void
processScannerExtensions(AnnotationScannerContext context, Collection<org.jboss.jandex.ClassInfo> applications)
Scan for scanner extensionsdefault void
processSecurityRequirementAnnotation(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 modeldefault void
processSecuritySchemeAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process a certain class for security annotations.default void
processServerAnnotation(org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process a certain class for server annotations.default void
processServerAnnotation(org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
Process a certain method for server annotations.default Set<String>
processTags(AnnotationScannerContext context, org.jboss.jandex.AnnotationTarget target, org.eclipse.microprofile.openapi.models.OpenAPI openApi, boolean nullWhenMissing)
Processes anyTag
orTags
annotations present on the annotation target and adds them to the OpenAPI model.default boolean
responseCodeExistInMethodAnnotations(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance exMapperApiResponseAnnotation, List<org.jboss.jandex.AnnotationInstance> methodApiResponseAnnotations)
Check if the response code declared in the ExceptionMapper already defined in one of the ApiReponse annotations of the method.org.eclipse.microprofile.openapi.models.OpenAPI
scan(AnnotationScannerContext annotationScannerContext, org.eclipse.microprofile.openapi.models.OpenAPI oai)
void
setContextRoot(String path)
default void
setOperationOnPathItem(org.eclipse.microprofile.openapi.models.PathItem.HttpMethod methodType, org.eclipse.microprofile.openapi.models.PathItem pathItem, org.eclipse.microprofile.openapi.models.Operation operation)
Set the created operation to the pathItemdefault org.jboss.jandex.Type
unwrapType(org.jboss.jandex.Type type)
-
-
-
Method Detail
-
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)
-
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 void processDefinitionAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process a certain class for OpenApiDefinition annotations.- Parameters:
context
- the scanning contexttargetClass
- the class that contain the server annotationopenApi
- the current OpenApi model being created
-
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 annotationopenApi
- the current OpenApi model being created
-
processServerAnnotation
default void processServerAnnotation(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 annotationopenApi
- the current OpenApi model being created
-
processJavaSecurity
default void processJavaSecurity(org.jboss.jandex.ClassInfo resourceClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Process Java security (roles allowed and declared roles)- Parameters:
openApi
- the OpenAPI ModelresourceClass
- the Class being scanned
-
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 methodopenApi
- the OpenApi modelresourceTags
- tags passed inoperation
- 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 anyTag
orTags
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:
openApi
- OpenAPI modeltarget
- a MethodInfo or ClassInfo to read for tag annotationsnullWhenMissing
- 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 contextresource
- 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 contextresourceClass
- the JAX-RS/Spring concrete resource classmethod
- the JAX-RS/Spring method- Returns:
- Maybe an Operation model
-
processResponse
default void processResponse(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation, Map<org.jboss.jandex.DotName,org.jboss.jandex.AnnotationInstance> exceptionAnnotationMap)
-
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. TODO: generate responses for each checked exception?- Parameters:
context
- the scanning contextmethod
- the current methodoperation
- 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)
-
isKotlinContinuation
default boolean isKotlinContinuation(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 defaultoperation
- current operation- Returns:
- true if a default response should be generated, otherwise false.
-
addApiReponseFromAnnotation
default void addApiReponseFromAnnotation(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance apiResponseAnnotation, org.eclipse.microprofile.openapi.models.Operation operation)
Add api response to api responses using the annotation information- Parameters:
context
- The current scanning contextapiResponseAnnotation
- The api response annotationoperation
- The method operation
-
addApiReponseSchemaFromAnnotation
default void addApiReponseSchemaFromAnnotation(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)
Add api response to api responses using the annotation information- Parameters:
context
- the scanning contextannotation
- The APIResponseSchema annotationmethod
- the current methodoperation
- the method operation
-
responseCodeExistInMethodAnnotations
default boolean responseCodeExistInMethodAnnotations(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance exMapperApiResponseAnnotation, List<org.jboss.jandex.AnnotationInstance> methodApiResponseAnnotations)
Check if the response code declared in the ExceptionMapper already defined in one of the ApiReponse annotations of the method. If the response code already exists then ignore the exception mapper annotation.- Parameters:
exMapperApiResponseAnnotation
- ApiResponse annotation declared in the exception mappermethodApiResponseAnnotations
- List of ApiResponse annotations declared in the jax-rs/spring method.- Returns:
- response code exist or not
-
processSecurityRequirementAnnotation
default void processSecurityRequirementAnnotation(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 classmethod
- the methodoperation
- the operation to add them to
-
isEmptySecurityRequirements
default boolean isEmptySecurityRequirements(org.jboss.jandex.AnnotationTarget target)
Determines whether the target is annotated with an empty@SecurityRequirements
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 contextmethod
- the methodoperation
- the operation to add this to
-
processServerAnnotation
default void processServerAnnotation(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 annotationoperation
- 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 contextmethod
- the current REST methodoperation
- the current operation
-
setOperationOnPathItem
default void setOperationOnPathItem(org.eclipse.microprofile.openapi.models.PathItem.HttpMethod methodType, org.eclipse.microprofile.openapi.models.PathItem pathItem, org.eclipse.microprofile.openapi.models.Operation operation)
Set the created operation to the pathItem- Parameters:
methodType
- the HTTP method typepathItem
- the pathItem to setoperation
- the operation
-
processScannerExtensions
default void processScannerExtensions(AnnotationScannerContext context, Collection<org.jboss.jandex.ClassInfo> applications)
Scan for scanner extensions- Parameters:
context
- the scanning contextapplications
- 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 contextmethod
- the resource methodparams
- the params- Returns:
- RequestBody model
-
getConsumes
default String[] getConsumes(AnnotationScannerContext context)
-
getRequestBodyParameterClassType
default org.jboss.jandex.Type getRequestBodyParameterClassType(org.jboss.jandex.MethodInfo method, List<AnnotationScannerExtension> extensions)
Go through the method parameters looking for one that is not annotated with a jax-rs/spring annotation.That will be the one that is the request body.- Parameters:
method
- MethodInfoextensions
- available extensions- Returns:
- Type
-
getReasonPhrase
default String getReasonPhrase(int statusCode)
Get the default description for a HTTP Status code- Parameters:
statusCode
-- Returns:
- the reason
-
-