Package io.micronaut.openapi.visitor
Class AbstractOpenApiEndpointVisitor
java.lang.Object
io.micronaut.openapi.visitor.AbstractOpenApiEndpointVisitor
- Direct Known Subclasses:
OpenApiControllerVisitor
,OpenApiEndpointVisitor
A
TypeElementVisitor
the builds the Swagger model from Micronaut controllers at compile time.- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected io.swagger.v3.oas.models.ExternalDocumentation
protected List<io.swagger.v3.oas.models.tags.Tag>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract List<io.micronaut.http.MediaType>
consumesMediaTypes
(io.micronaut.inject.ast.MethodElement element) Returns the consumes media types.protected abstract String
description
(io.micronaut.inject.ast.MethodElement element) Returns the description for the element.protected abstract List<io.swagger.v3.oas.models.tags.Tag>
getUserDefinedClassTags
(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the class tags.protected abstract io.micronaut.http.HttpMethod
httpMethod
(io.micronaut.inject.ast.MethodElement element) Returns the HttpMethod of the element.protected abstract boolean
ignore
(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Returns true if the specified element should not be processed.protected abstract boolean
ignore
(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns true if the specified element should not be processed.protected abstract List<io.swagger.v3.oas.models.security.SecurityRequirement>
methodSecurityRequirements
(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the security requirements at method level.protected abstract List<io.swagger.v3.oas.models.servers.Server>
methodServers
(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the servers at method level.protected <T,
A extends Annotation>
List<T>processOpenApiAnnotation
(io.micronaut.inject.ast.Element element, io.micronaut.inject.visitor.VisitorContext context, Class<A> annotationType, Class<T> modelType, List<T> tagList) Converts annotation to model.protected void
processSecuritySchemes
(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) ProcessesSecurityScheme
annotations.protected abstract List<io.micronaut.http.MediaType>
producesMediaTypes
(io.micronaut.inject.ast.MethodElement element) Returns the produces media types.protected abstract List<io.micronaut.http.uri.UriMatchTemplate>
uriMatchTemplates
(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the uri paths of the element.void
visitClass
(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Executed when a class is encountered that matches the generic class.void
visitMethod
(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Executed when a method is encountered that matches the generic element.
-
Field Details
-
classTags
-
classExternalDocs
protected io.swagger.v3.oas.models.ExternalDocumentation classExternalDocs
-
-
Constructor Details
-
AbstractOpenApiEndpointVisitor
public AbstractOpenApiEndpointVisitor()
-
-
Method Details
-
visitClass
public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Executed when a class is encountered that matches the generic class.- Parameters:
element
- The elementcontext
- The visitor context
-
methodSecurityRequirements
protected abstract List<io.swagger.v3.oas.models.security.SecurityRequirement> methodSecurityRequirements(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the security requirements at method level.- Parameters:
element
- The MethodElement.context
- The context.- Returns:
- The security requirements.
-
methodServers
protected abstract List<io.swagger.v3.oas.models.servers.Server> methodServers(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the servers at method level.- Parameters:
element
- The MethodElement.context
- The context.- Returns:
- The servers.
-
getUserDefinedClassTags
protected abstract List<io.swagger.v3.oas.models.tags.Tag> getUserDefinedClassTags(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the class tags.- Parameters:
element
- The ClassElement.context
- The context.- Returns:
- The class tags.
-
ignore
protected abstract boolean ignore(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) Returns true if the specified element should not be processed.- Parameters:
element
- The ClassElement.context
- The context.- Returns:
- true if the specified element should not be processed.
-
ignore
protected abstract boolean ignore(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns true if the specified element should not be processed.- Parameters:
element
- The ClassElement.context
- The context.- Returns:
- true if the specified element should not be processed.
-
httpMethod
protected abstract io.micronaut.http.HttpMethod httpMethod(io.micronaut.inject.ast.MethodElement element) Returns the HttpMethod of the element.- Parameters:
element
- The MethodElement.- Returns:
- The HttpMethod of the element.
-
uriMatchTemplates
protected abstract List<io.micronaut.http.uri.UriMatchTemplate> uriMatchTemplates(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Returns the uri paths of the element.- Parameters:
element
- The MethodElement.context
- The context- Returns:
- The uri paths of the element.
-
consumesMediaTypes
protected abstract List<io.micronaut.http.MediaType> consumesMediaTypes(io.micronaut.inject.ast.MethodElement element) Returns the consumes media types.- Parameters:
element
- The MethodElement.- Returns:
- The consumes media types.
-
producesMediaTypes
protected abstract List<io.micronaut.http.MediaType> producesMediaTypes(io.micronaut.inject.ast.MethodElement element) Returns the produces media types.- Parameters:
element
- The MethodElement.- Returns:
- The produces media types.
-
description
Returns the description for the element.- Parameters:
element
- The MethodElement.- Returns:
- The description for the element.
-
visitMethod
public void visitMethod(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context) Executed when a method is encountered that matches the generic element.- Parameters:
element
- The elementcontext
- The visitor context
-
processSecuritySchemes
protected void processSecuritySchemes(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context) ProcessesSecurityScheme
annotations.- Parameters:
element
- The elementcontext
- The visitor context
-
processOpenApiAnnotation
protected <T,A extends Annotation> List<T> processOpenApiAnnotation(io.micronaut.inject.ast.Element element, io.micronaut.inject.visitor.VisitorContext context, Class<A> annotationType, Class<T> modelType, List<T> tagList) Converts annotation to model.- Type Parameters:
T
- The model type.A
- The annotation type.- Parameters:
element
- The element to process.context
- The context.annotationType
- The annotation type.modelType
- The model type.tagList
- The initial list of models.- Returns:
- A list of model objects.
-