@SupportedOptions(value={"micronaut.openapi.server.context.path","micronaut.openapi.property.naming.strategy","micronaut.openapi.views.spec","micronaut.openapi.target.file","micronaut.openapi.additional.files","micronaut.openapi.config.file"})
public class OpenApiApplicationVisitor
extends java.lang.Object
implements io.micronaut.inject.visitor.TypeElementVisitor<io.swagger.v3.oas.annotations.OpenAPIDefinition,java.lang.Object>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MICRONAUT_OPENAPI_ADDITIONAL_FILES
System property that specifies the location of additional swagger YAML files to read from.
|
static java.lang.String |
MICRONAUT_OPENAPI_CONFIG_FILE
System property that enables setting the open api config file.
|
static java.lang.String |
MICRONAUT_OPENAPI_CONTEXT_SERVER_PATH
System property for server context path.
|
static java.lang.String |
MICRONAUT_OPENAPI_ENDPOINT_CLASS_TAGS
The name of the entry for Endpoint class tags in the context.
|
static java.lang.String |
MICRONAUT_OPENAPI_ENDPOINT_SECURITY_REQUIREMENTS
The name of the entry for Endpoint security requirements in the context.
|
static java.lang.String |
MICRONAUT_OPENAPI_ENDPOINT_SERVERS
The name of the entry for Endpoint servers in the context.
|
static java.lang.String |
MICRONAUT_OPENAPI_EXPAND_PREFIX
Prefix for expandable properties.
|
static java.lang.String |
MICRONAUT_OPENAPI_PROPERTY_NAMING_STRATEGY
System property for naming strategy.
|
static java.lang.String |
MICRONAUT_OPENAPI_TARGET_FILE
System property that enables setting the target file to write to.
|
static java.lang.String |
MICRONAUT_OPENAPI_VIEWS_SPEC
System property for views specification.
|
static java.lang.String |
OPENAPI_CONFIG_FILE
Default openapi config file.
|
Constructor and Description |
---|
OpenApiApplicationVisitor() |
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.
|
void |
finish(io.micronaut.inject.visitor.VisitorContext visitorContext) |
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 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 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.
|
void |
visitClass(io.micronaut.inject.ast.ClassElement element,
io.micronaut.inject.visitor.VisitorContext context) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static final java.lang.String MICRONAUT_OPENAPI_CONFIG_FILE
public static final java.lang.String MICRONAUT_OPENAPI_EXPAND_PREFIX
public static final java.lang.String MICRONAUT_OPENAPI_CONTEXT_SERVER_PATH
public static final java.lang.String MICRONAUT_OPENAPI_PROPERTY_NAMING_STRATEGY
public static final java.lang.String MICRONAUT_OPENAPI_VIEWS_SPEC
public static final java.lang.String MICRONAUT_OPENAPI_TARGET_FILE
public static final java.lang.String MICRONAUT_OPENAPI_ADDITIONAL_FILES
public static final java.lang.String OPENAPI_CONFIG_FILE
public static final java.lang.String MICRONAUT_OPENAPI_ENDPOINT_CLASS_TAGS
public static final java.lang.String MICRONAUT_OPENAPI_ENDPOINT_SERVERS
public static final java.lang.String MICRONAUT_OPENAPI_ENDPOINT_SECURITY_REQUIREMENTS
public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
visitClass
in interface io.micronaut.inject.visitor.TypeElementVisitor<io.swagger.v3.oas.annotations.OpenAPIDefinition,java.lang.Object>
public void finish(io.micronaut.inject.visitor.VisitorContext visitorContext)
finish
in interface io.micronaut.inject.visitor.TypeElementVisitor<io.swagger.v3.oas.annotations.OpenAPIDefinition,java.lang.Object>
protected <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
.