public class OpenApiEndpointVisitor
extends java.lang.Object
implements io.micronaut.inject.visitor.TypeElementVisitor<io.micronaut.management.endpoint.annotation.Endpoint,java.lang.Object>
TypeElementVisitor
the builds the Swagger model from Micronaut
controllers at compile time.Modifier and Type | Field and Description |
---|---|
protected java.util.List<io.swagger.v3.oas.models.tags.Tag> |
classTags |
protected io.micronaut.context.env.PropertyPlaceholderResolver |
propertyPlaceholderResolver |
Constructor and Description |
---|
OpenApiEndpointVisitor() |
OpenApiEndpointVisitor(boolean enabled) |
OpenApiEndpointVisitor(boolean enabled,
java.util.List<io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.tags.Tag>> additionalTags,
java.util.List<io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.security.SecurityRequirement>> additionalSecurityRequirements) |
Modifier and Type | Method and Description |
---|---|
protected io.swagger.v3.oas.models.media.Schema |
bindArraySchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context,
io.micronaut.inject.ast.Element element,
io.swagger.v3.oas.models.media.Schema schemaToBind,
io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.ArraySchema> schemaAnn)
Binds the array schema for the given element.
|
protected io.swagger.v3.oas.models.media.Schema |
bindSchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context,
io.micronaut.inject.ast.Element element,
io.swagger.v3.oas.models.media.Schema schemaToBind,
io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaAnn)
Binds the schema for the given element.
|
protected io.swagger.v3.oas.models.media.Schema |
bindSchemaForElement(io.micronaut.inject.visitor.VisitorContext context,
io.micronaut.inject.ast.Element element,
io.micronaut.inject.ast.ClassElement elementType,
io.swagger.v3.oas.models.media.Schema schemaToBind)
Binds the schema for the given element.
|
protected java.util.List<io.swagger.v3.oas.models.tags.Tag> |
classTags(io.micronaut.inject.ast.ClassElement element,
io.micronaut.inject.visitor.VisitorContext context)
Returns the class tags.
|
protected java.util.List<io.micronaut.http.MediaType> |
consumesMediaTypes(io.micronaut.inject.ast.MethodElement element)
Returns the consumes media types.
|
protected java.lang.String |
description(io.micronaut.inject.ast.MethodElement element)
Returns the description for the element.
|
protected io.micronaut.http.HttpMethod |
httpMethod(io.micronaut.inject.ast.MethodElement element)
Returns the HttpMethod of the element.
|
protected 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 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 io.swagger.v3.oas.models.security.SecurityRequirement |
mapToSecurityRequirement(io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.security.SecurityRequirement> r)
Maps annotation value to
SecurityRequirement . |
protected java.util.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 java.util.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 void |
normalizeEnumValues(java.util.Map<java.lang.CharSequence,java.lang.Object> paramValues,
java.util.Map<java.lang.String,java.lang.Class<? extends java.lang.Enum>> enumTypes)
Normalizes enum values stored in the map.
|
protected void |
processSchemaProperty(io.micronaut.inject.visitor.VisitorContext context,
io.micronaut.inject.ast.Element element,
io.micronaut.inject.ast.ClassElement elementType,
io.micronaut.inject.ast.Element classElement,
io.swagger.v3.oas.models.media.Schema parentSchema,
io.swagger.v3.oas.models.media.Schema propertySchema)
Processes a schema property.
|
protected void |
processSecuritySchemes(io.micronaut.inject.ast.ClassElement element,
io.micronaut.inject.visitor.VisitorContext context)
Processes
SecurityScheme
annotations. |
protected java.util.List<io.micronaut.http.MediaType> |
producesMediaTypes(io.micronaut.inject.ast.MethodElement element)
Returns the produces media types.
|
protected io.swagger.v3.oas.models.media.Schema |
readSchema(io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaValue,
io.swagger.v3.oas.models.OpenAPI openAPI,
io.micronaut.inject.visitor.VisitorContext context,
io.micronaut.inject.ast.Element type,
java.util.List<io.micronaut.http.MediaType> mediaTypes)
Reads schema.
|
protected io.swagger.v3.oas.models.Components |
resolveComponents(io.swagger.v3.oas.models.OpenAPI openAPI)
Resolve the components.
|
protected io.swagger.v3.oas.models.media.Schema |
resolveSchema(io.micronaut.inject.ast.Element definingElement,
io.micronaut.inject.ast.ClassElement type,
io.micronaut.inject.visitor.VisitorContext context,
java.util.List<io.micronaut.http.MediaType> mediaTypes)
Resolves the schema for the given type element.
|
protected io.swagger.v3.oas.models.media.Schema |
resolveSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.micronaut.inject.ast.Element definingElement,
io.micronaut.inject.ast.ClassElement type,
io.micronaut.inject.visitor.VisitorContext context,
java.util.List<io.micronaut.http.MediaType> mediaTypes)
Resolves the schema for the given type element.
|
protected java.util.Map<java.lang.CharSequence,java.lang.Object> |
toValueMap(java.util.Map<java.lang.CharSequence,java.lang.Object> values,
io.micronaut.inject.visitor.VisitorContext context)
Convert the values to a map.
|
protected <T> T |
treeToValue(com.fasterxml.jackson.databind.JsonNode jn,
java.lang.Class<T> clazz)
Converts Json node into a class' instance or throws 'com.fasterxml.jackson.core.JsonProcessingException', adds extensions if present.
|
protected java.util.List<io.micronaut.http.uri.UriMatchTemplate> |
uriMatchTemplates(io.micronaut.inject.ast.MethodElement element)
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
|
void |
visitMethod(io.micronaut.inject.ast.MethodElement element,
io.micronaut.inject.visitor.VisitorContext context)
Executed when a method is encountered that matches the
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected java.util.List<io.swagger.v3.oas.models.tags.Tag> classTags
protected io.micronaut.context.env.PropertyPlaceholderResolver propertyPlaceholderResolver
public OpenApiEndpointVisitor()
public OpenApiEndpointVisitor(boolean enabled)
public OpenApiEndpointVisitor(boolean enabled, java.util.List<io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.tags.Tag>> additionalTags, java.util.List<io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.security.SecurityRequirement>> additionalSecurityRequirements)
public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
visitClass
in interface io.micronaut.inject.visitor.TypeElementVisitor<io.micronaut.management.endpoint.annotation.Endpoint,java.lang.Object>
element
- The elementcontext
- The visitor contextprotected boolean ignore(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The ClassElement.context
- The context.protected boolean ignore(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The ClassElement.context
- The context.protected io.micronaut.http.HttpMethod httpMethod(io.micronaut.inject.ast.MethodElement element)
element
- The MethodElement.protected java.util.List<io.micronaut.http.uri.UriMatchTemplate> uriMatchTemplates(io.micronaut.inject.ast.MethodElement element)
element
- The MethodElement.protected java.util.List<io.micronaut.http.MediaType> consumesMediaTypes(io.micronaut.inject.ast.MethodElement element)
element
- The MethodElement.protected java.util.List<io.micronaut.http.MediaType> producesMediaTypes(io.micronaut.inject.ast.MethodElement element)
element
- The MethodElement.protected java.lang.String description(io.micronaut.inject.ast.MethodElement element)
element
- The MethodElement.protected java.util.List<io.swagger.v3.oas.models.tags.Tag> classTags(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The ClassElement.context
- The context.protected java.util.List<io.swagger.v3.oas.models.servers.Server> methodServers(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The MethodElement.context
- The context.protected java.util.List<io.swagger.v3.oas.models.security.SecurityRequirement> methodSecurityRequirements(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The MethodElement.context
- The context.public void visitMethod(io.micronaut.inject.ast.MethodElement element, io.micronaut.inject.visitor.VisitorContext context)
element
- The elementcontext
- The visitor contextprotected <T> T treeToValue(com.fasterxml.jackson.databind.JsonNode jn, java.lang.Class<T> clazz) throws com.fasterxml.jackson.core.JsonProcessingException
T
- The output class typejn
- The json nodeclazz
- The output class instancecom.fasterxml.jackson.core.JsonProcessingException
- if errorprotected java.util.Map<java.lang.CharSequence,java.lang.Object> toValueMap(java.util.Map<java.lang.CharSequence,java.lang.Object> values, io.micronaut.inject.visitor.VisitorContext context)
values
- The valuescontext
- The visitor context@Nullable protected io.swagger.v3.oas.models.media.Schema resolveSchema(@Nullable io.micronaut.inject.ast.Element definingElement, io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, java.util.List<io.micronaut.http.MediaType> mediaTypes)
definingElement
- The defining elementtype
- The type elementcontext
- The contextmediaTypes
- An optional media type@Nullable protected io.swagger.v3.oas.models.media.Schema resolveSchema(io.swagger.v3.oas.models.OpenAPI openAPI, @Nullable io.micronaut.inject.ast.Element definingElement, io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, java.util.List<io.micronaut.http.MediaType> mediaTypes)
openAPI
- The OpenAPI objectdefiningElement
- The defining elementtype
- The type elementcontext
- The contextmediaTypes
- An optional media typeprotected io.swagger.v3.oas.models.Components resolveComponents(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI
- The open APIprotected void processSchemaProperty(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element element, io.micronaut.inject.ast.ClassElement elementType, @Nullable io.micronaut.inject.ast.Element classElement, io.swagger.v3.oas.models.media.Schema parentSchema, io.swagger.v3.oas.models.media.Schema propertySchema)
context
- The visitor contextelement
- The elementelementType
- The element typeclassElement
- The class elementparentSchema
- The parent schemapropertySchema
- The property schemaprotected io.swagger.v3.oas.models.media.Schema bindSchemaForElement(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element element, io.micronaut.inject.ast.ClassElement elementType, io.swagger.v3.oas.models.media.Schema schemaToBind)
context
- The contextelement
- The elementelementType
- The element typeschemaToBind
- The schema to bindprotected io.swagger.v3.oas.models.media.Schema bindSchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element element, io.swagger.v3.oas.models.media.Schema schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaAnn)
context
- The contextelement
- The elementschemaToBind
- The schema to bindschemaAnn
- The schema annotationprotected io.swagger.v3.oas.models.media.Schema bindArraySchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element element, io.swagger.v3.oas.models.media.Schema schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.ArraySchema> schemaAnn)
context
- The contextelement
- The elementschemaToBind
- The schema to bindschemaAnn
- The schema annotationprotected io.swagger.v3.oas.models.media.Schema readSchema(io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaValue, io.swagger.v3.oas.models.OpenAPI openAPI, io.micronaut.inject.visitor.VisitorContext context, @Nullable io.micronaut.inject.ast.Element type, java.util.List<io.micronaut.http.MediaType> mediaTypes) throws com.fasterxml.jackson.core.JsonProcessingException
schemaValue
- annotation valueopenAPI
- The OpenApicontext
- The VisitorContexttype
- The elementmediaTypes
- The media types of schemacom.fasterxml.jackson.core.JsonProcessingException
- when Json parsing failsprotected void processSecuritySchemes(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
SecurityScheme
annotations.element
- The elementcontext
- The visitor contextprotected void normalizeEnumValues(java.util.Map<java.lang.CharSequence,java.lang.Object> paramValues, java.util.Map<java.lang.String,java.lang.Class<? extends java.lang.Enum>> enumTypes)
paramValues
- The valuesenumTypes
- The enum types.protected io.swagger.v3.oas.models.security.SecurityRequirement mapToSecurityRequirement(io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.security.SecurityRequirement> r)
SecurityRequirement
.
Correct format is:
custom_name:
- custom_scope1
- custom_scope2r
- The value of SecurityRequirement
.