Package com.github.chhorz.openapi.common
Class OpenAPIProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.github.chhorz.openapi.common.OpenAPIProcessor
- All Implemented Interfaces:
Processor
- Direct Known Subclasses:
JaxRSOpenApiProcessor,SchemaOpenApiProcessor,SpringWebOpenApiProcessor
Abstract annotation processor to provide some common functionality for all specific OpenAPI annotation processors.
- Author:
- chhorz
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Elementsprotected com.github.chhorz.javadoc.JavaDocParserprotected LogUtilsprotected OpenAPIprotected ParserPropertiesprotected ProcessingUtilsprotected GeneratorPropertyLoaderprotected ResponseUtilsprotected SchemaUtilsFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.github.chhorz.javadoc.JavaDocParserInitializes a new instance of the external JavaDocParser.protected booleanexclude(ExecutableElement executableElement) Checks if the given method should be excluded from the generated OpenAPI file.protected StringgetOperationId(ExecutableElement executableElement) Creates an OpenAPI operation id from a java method executableElement.protected StringgetOperationId(ExecutableElement executableElement, OpenAPI openAPI) getSecurityInformation(ExecutableElement executableElement, OpenAPI openAPI, com.github.chhorz.javadoc.JavaDoc javaDoc, OpenAPI openApiAnnotation) Creates a map of security information for a give method.protected abstract Stream<Class<? extends Annotation>>Create a stream of all supported annotation classesReturns a set of all annotation processor options that will be recognized by the implementations of this interface.Creates a list of tags from the given input sources.protected voidinit(ProcessingEnvironment processingEnv, List<Class<?>> baseClasses) protected OpenAPIinitializeFromProperties(GeneratorPropertyLoader propertyLoader) Initializes a new OpenAPI domain object with the information from the configuration file.static booleanisClassAvailable(String className) Check if the given class is available on the classpath.readOpenApiFile(ParserProperties parserProperties) Loads an existing OpenAPI schema file.protected voidrunPostProcessors(ParserProperties parserProperties, OpenAPI openApi) Runs all registered post processors from the service loader.Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, init, isInitialized, process
-
Field Details
-
elements
-
propertyLoader
-
parserProperties
-
logUtils
-
schemaUtils
-
processingUtils
-
responseUtils
-
javaDocParser
protected com.github.chhorz.javadoc.JavaDocParser javaDocParser -
openApi
-
-
Constructor Details
-
OpenAPIProcessor
public OpenAPIProcessor()
-
-
Method Details
-
init
-
getSupportedAnnotationClasses
Create a stream of all supported annotation classes- Returns:
- stream of class elements.
-
getSupportedAnnotationTypes
- Specified by:
getSupportedAnnotationTypesin interfaceProcessor- Overrides:
getSupportedAnnotationTypesin classAbstractProcessor
-
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-
getSupportedOptions
Returns a set of all annotation processor options that will be recognized by the implementations of this interface.- Specified by:
getSupportedOptionsin interfaceProcessor- Overrides:
getSupportedOptionsin classAbstractProcessor- Returns:
- a set of annotation processor compiler options
-
initializeFromProperties
Initializes a new OpenAPI domain object with the information from the configuration file.- Parameters:
propertyLoader- the property loader that loads the properties from the configuration file- Returns:
- a new instance of an OpenAPI domain object
-
createJavadocParser
protected com.github.chhorz.javadoc.JavaDocParser createJavadocParser()Initializes a new instance of the external JavaDocParser. The parser will be configured with additional Javadoc tags and the Markdown converter.- Returns:
- a new instance of the JavaDocParser
-
getOperationId
Creates an OpenAPI operation id from a java method executableElement.- Parameters:
executableElement- the executable executableElement that defines a specific method- Returns:
- the OpenAPI operation id (should be unique)
-
getOperationId
-
exclude
Checks if the given method should be excluded from the generated OpenAPI file.- Parameters:
executableElement- the executable executableElement that defines a specific method- Returns:
- a flag if the given method should be excluded
-
getTags
protected List<String> getTags(com.github.chhorz.javadoc.JavaDoc javaDoc, OpenAPI openApiAnnotation) Creates a list of tags from the given input sources.- Parameters:
javaDoc- the Javadoc from the executable elementopenApiAnnotation- theOpenAPIannotation from the executable element- Returns:
- a list of tags
-
getSecurityInformation
protected List<Map<String,List<String>>> getSecurityInformation(ExecutableElement executableElement, OpenAPI openAPI, com.github.chhorz.javadoc.JavaDoc javaDoc, OpenAPI openApiAnnotation) Creates a map of security information for a give method.- Parameters:
executableElement- the current methodopenAPI- the openapi object with the current parsed datajavaDoc- the javadoc comment from the current methodopenApiAnnotation- the annotation from the current method- Returns:
- map of security information
-
runPostProcessors
Runs all registered post processors from the service loader.- Parameters:
parserProperties- the configuration properties form the configuration fileopenApi- the generated OpenAPI domain object
-
readOpenApiFile
Loads an existing OpenAPI schema file.- Parameters:
parserProperties- the loaded configuration properties- Returns:
- an OpenAPI domain object of the configured schema file from the properties
- See Also:
-
isClassAvailable
Check if the given class is available on the classpath. This check is required for optional maven dependencies.- Parameters:
className- the full qualified class name- Returns:
trueif the class is available on the classpath
-