Interface AnnotationScanner
-
- All Known Implementing Classes:
AbstractAnnotationScanner
public interface AnnotationScannerThis represent a scanner- Author:
- Phillip Kruger (phillip.kruger@redhat.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidaddApiReponseFromAnnotation(AnnotationScannerContext context, org.jboss.jandex.AnnotationInstance apiResponseAnnotation, org.eclipse.microprofile.openapi.models.Operation operation)Add api response to api responses using the annotation informationdefault voidaddApiReponseSchemaFromAnnotation(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 informationdefault voidclearJsonViewContext(AnnotationScannerContext context)booleancontainsScannerAnnotations(List<org.jboss.jandex.AnnotationInstance> instances, List<AnnotationScannerExtension> extensions)default voidcreateResponseFromRestMethod(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 booleangenerateResponse(String status, org.eclipse.microprofile.openapi.models.Operation operation)Determine if the default response information should be generated.default String[]getConsumes(AnnotationScannerContext context)default String[]getConsumesForRequestBody(AnnotationScannerContext context)String[]getDefaultConsumes(AnnotationScannerContext context, org.jboss.jandex.MethodInfo methodInfo, ResourceParameters params)String[]getDefaultProduces(AnnotationScannerContext context, org.jboss.jandex.MethodInfo methodInfo)default intgetDefaultStatus(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().default org.jboss.jandex.TypegetKotlinContinuationArgument(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)StringgetName()default StringgetReasonPhrase(int statusCode)Get the default description for a HTTP Status codedefault org.jboss.jandex.TypegetRequestBodyParameterClassType(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.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 indexdefault booleanhasKotlinContinuation(org.jboss.jandex.MethodInfo method)booleanisAsyncResponse(org.jboss.jandex.MethodInfo method)booleanisDeleteMethod(org.jboss.jandex.MethodInfo method)default booleanisEmptySecurityRequirements(org.jboss.jandex.AnnotationTarget target)Determines whether the target is annotated with an empty@SecurityRequirementsor@SecurityRequirementsSetsannotation.default booleanisFrameworkContextType(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.default booleanisKotlinContinuation(org.jboss.jandex.Type paramType)default booleanisMultipartInput(org.jboss.jandex.Type inputType)default booleanisMultipartOutput(org.jboss.jandex.Type returnType)default booleanisPathParameter(AnnotationScannerContext context, String name, ResourceParameters params)booleanisPostMethod(org.jboss.jandex.MethodInfo method)default booleanisScannerInternalParameter(org.jboss.jandex.Type parameterType)default booleanisScannerInternalResponse(org.jboss.jandex.Type returnType)default booleanisScannerInternalResponse(org.jboss.jandex.Type returnType, AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)default booleanisVoidResponse(org.jboss.jandex.MethodInfo method)default booleanisWrapperType(org.jboss.jandex.Type type)default org.eclipse.microprofile.openapi.models.media.SchemakotlinContinuationToSchema(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method)default voidprocessCallback(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)Process a callback annotationdefault voidprocessDefinitionAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)Process a certain class for OpenApiDefinition annotations.default voidprocessExtensions(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation)Process the Extensions annotationsdefault voidprocessJavaSecurity(AnnotationScannerContext context, 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 voidprocessOperationTags(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.RequestBodyprocessRequestBody(AnnotationScannerContext context, org.jboss.jandex.MethodInfo method, ResourceParameters params)Process the request bodydefault voidprocessResponse(AnnotationScannerContext context, org.jboss.jandex.ClassInfo resourceClass, org.jboss.jandex.MethodInfo method, org.eclipse.microprofile.openapi.models.Operation operation, Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> exceptionAnnotationMap)default voidprocessScannerExtensions(AnnotationScannerContext context, Collection<org.jboss.jandex.ClassInfo> applications)Scan for scanner extensionsdefault voidprocessSecurityRequirementAnnotation(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 voidprocessSecuritySchemeAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)Process a certain class for security annotations.default voidprocessServerAnnotation(AnnotationScannerContext context, org.jboss.jandex.ClassInfo targetClass, org.eclipse.microprofile.openapi.models.OpenAPI openApi)Process a certain class for server annotations.default voidprocessServerAnnotation(AnnotationScannerContext context, 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 anyTagorTagsannotations present on the annotation target and adds them to the OpenAPI model.default booleanresponseCodeExistInMethodAnnotations(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.OpenAPIscan(AnnotationScannerContext annotationScannerContext, org.eclipse.microprofile.openapi.models.OpenAPI oai)voidsetContextRoot(String path)default voidsetJsonViewContext(AnnotationScannerContext context, org.jboss.jandex.Type[] views)default voidsetOperationOnPathItem(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 voidsetRequestBodyConstraints(AnnotationScannerContext context, org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody, org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type requestBodyType)default org.jboss.jandex.TypeunwrapType(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)
-
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 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(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 annotationopenApi- 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:
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 anyTagorTagsannotations 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
-
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,List<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.- 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)
-
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 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@SecurityRequirementsor@SecurityRequirementsSetsannotation.- 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(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 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)
-
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 contextmethod- MethodInfoparams- 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
-
-