Class SchemaDefinitionUtils

java.lang.Object
io.micronaut.openapi.visitor.SchemaDefinitionUtils

@Internal public final class SchemaDefinitionUtils extends Object
Methods to construct OpenPI schema definition.
Since:
6.12.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.swagger.v3.oas.models.media.Schema<?>
    bindArraySchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.ArraySchema> schemaAnn, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Binds the array schema for the given element.
    static io.swagger.v3.oas.models.media.Schema<?>
    bindSchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaAnn, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Binds the schema for the given element.
    static io.swagger.v3.oas.models.media.Schema<?>
    bindSchemaForElement(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.ast.ClassElement elementType, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass, boolean withProcessDeprecated)
    Binds the schema for the given element.
    static void
    Cleanup context.
    static String
    computeDefaultSchemaName(String defaultSchemaName, io.micronaut.inject.ast.Element definingElement, io.micronaut.inject.ast.Element type, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, io.micronaut.inject.visitor.VisitorContext context, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
     
    static List<Object>
    getEnumValues(io.micronaut.inject.ast.EnumElement type, String schemaType, String schemaFormat, io.micronaut.inject.visitor.VisitorContext context)
     
    static @Nullable io.swagger.v3.oas.models.media.Schema<?>
    getSchemaDefinition(io.swagger.v3.oas.models.OpenAPI openAPI, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.ClassElement type, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, @Nullable io.micronaut.inject.ast.Element definingElement, List<io.micronaut.http.MediaType> mediaTypes, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
     
    static Map<String,String>
     
    static void
    processSchemaProperty(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.ast.ClassElement elementType, @Nullable io.micronaut.inject.ast.ClassElement classElement, io.swagger.v3.oas.models.media.Schema<?> parentSchema, io.swagger.v3.oas.models.media.Schema<?> propertySchema)
    Processes a schema property.
    static 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, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, @Nullable io.micronaut.inject.ast.Element definingElement, List<io.micronaut.http.MediaType> mediaTypes, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Reads schema.
    resolveArraySchemaAnnotationValues(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.core.annotation.AnnotationValue<?> av, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
     
    static @Nullable io.swagger.v3.oas.models.media.Schema<?>
    resolveSchema(@Nullable io.micronaut.inject.ast.Element definingElement, @Nullable io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, List<io.micronaut.http.MediaType> mediaTypes, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Resolves the schema for the given type element.
    static @Nullable io.swagger.v3.oas.models.media.Schema<?>
    resolveSchema(io.swagger.v3.oas.models.OpenAPI openApi, @Nullable io.micronaut.inject.ast.Element definingElement, @Nullable io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, List<io.micronaut.http.MediaType> mediaTypes, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass, JavadocDescription fieldJavadoc, JavadocDescription classJavadoc)
    Resolves the schema for the given type element.
    static com.fasterxml.jackson.databind.JsonNode
    toJson(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Convert the given map to a JSON node.
    static <T> T
    toValue(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, Class<T> type, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Convert the given Map to a JSON node and then to the specified type.
    toValueMap(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    Convert the values to a map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • clean

      public static void clean()
      Cleanup context.
    • readSchema

      public static 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 @Nullable io.micronaut.inject.ast.Element type, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, @Nullable @Nullable io.micronaut.inject.ast.Element definingElement, List<io.micronaut.http.MediaType> mediaTypes, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Reads schema.
      Parameters:
      schemaValue - annotation value
      openAPI - The OpenApi
      context - The VisitorContext
      type - type element
      typeArgs - type arguments
      definingElement - defining element
      mediaTypes - The media types of schema
      jsonViewClass - Class from JsonView annotation
      Returns:
      New schema instance
    • getSchemaDefinition

      @Nullable public static @Nullable io.swagger.v3.oas.models.media.Schema<?> getSchemaDefinition(io.swagger.v3.oas.models.OpenAPI openAPI, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.ClassElement type, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, @Nullable @Nullable io.micronaut.inject.ast.Element definingElement, List<io.micronaut.http.MediaType> mediaTypes, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    • computeDefaultSchemaName

      public static String computeDefaultSchemaName(String defaultSchemaName, io.micronaut.inject.ast.Element definingElement, io.micronaut.inject.ast.Element type, Map<String,io.micronaut.inject.ast.ClassElement> typeArgs, io.micronaut.inject.visitor.VisitorContext context, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    • getEnumValues

      public static List<Object> getEnumValues(io.micronaut.inject.ast.EnumElement type, String schemaType, String schemaFormat, io.micronaut.inject.visitor.VisitorContext context)
    • resolveSchema

      @Nullable public static @Nullable io.swagger.v3.oas.models.media.Schema<?> resolveSchema(@Nullable @Nullable io.micronaut.inject.ast.Element definingElement, @Nullable @Nullable io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, List<io.micronaut.http.MediaType> mediaTypes, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Resolves the schema for the given type element.
      Parameters:
      definingElement - The defining element
      type - The type element
      context - The context
      mediaTypes - An optional media type
      jsonViewClass - Class from JsonView annotation
      Returns:
      The schema or null if it cannot be resolved
    • resolveSchema

      @Nullable public static @Nullable io.swagger.v3.oas.models.media.Schema<?> resolveSchema(io.swagger.v3.oas.models.OpenAPI openApi, @Nullable @Nullable io.micronaut.inject.ast.Element definingElement, @Nullable @Nullable io.micronaut.inject.ast.ClassElement type, io.micronaut.inject.visitor.VisitorContext context, List<io.micronaut.http.MediaType> mediaTypes, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass, JavadocDescription fieldJavadoc, JavadocDescription classJavadoc)
      Resolves the schema for the given type element.
      Parameters:
      openApi - The OpenAPI object
      definingElement - The defining element
      type - The type element
      context - The context
      mediaTypes - An optional media type
      fieldJavadoc - Field-level java doc
      classJavadoc - Class-level java doc
      jsonViewClass - Class from JsonView annotation
      Returns:
      The schema or null if it cannot be resolved
    • bindSchemaForElement

      public static io.swagger.v3.oas.models.media.Schema<?> bindSchemaForElement(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.ast.ClassElement elementType, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass, boolean withProcessDeprecated)
      Binds the schema for the given element.
      Parameters:
      context - The context
      element - The element
      elementType - The element type
      schemaToBind - The schema to bind
      jsonViewClass - Class from JsonView annotation
      withProcessDeprecated - Is need to process deprecates annotation
      Returns:
      The bound schema
    • bindArraySchemaAnnotationValue

      public static io.swagger.v3.oas.models.media.Schema<?> bindArraySchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.ArraySchema> schemaAnn, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Binds the array schema for the given element.
      Parameters:
      context - The context
      element - The element
      schemaToBind - The schema to bind
      schemaAnn - The schema annotation
      jsonViewClass - Class from JsonView annotation
      Returns:
      The bound schema
    • toValueMap

      public static Map<CharSequence,Object> toValueMap(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Convert the values to a map.
      Parameters:
      values - The values
      context - The visitor context
      jsonViewClass - Class from JsonView annotation
      Returns:
      The map
    • resolveArraySchemaAnnotationValues

      public static Map<CharSequence,Object> resolveArraySchemaAnnotationValues(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.core.annotation.AnnotationValue<?> av, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
    • bindSchemaAnnotationValue

      public static io.swagger.v3.oas.models.media.Schema<?> bindSchemaAnnotationValue(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.swagger.v3.oas.models.media.Schema<?> schemaToBind, io.micronaut.core.annotation.AnnotationValue<io.swagger.v3.oas.annotations.media.Schema> schemaAnn, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Binds the schema for the given element.
      Parameters:
      context - The context
      element - The element
      schemaToBind - The schema to bind
      schemaAnn - The schema annotation
      jsonViewClass - Class from JsonView annotation
      Returns:
      The bound schema
    • toValue

      public static <T> T toValue(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, Class<T> type, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Convert the given Map to a JSON node and then to the specified type.
      Type Parameters:
      T - The output class type
      Parameters:
      values - The values
      context - The visitor context
      type - The class
      jsonViewClass - Class from JsonView annotation
      Returns:
      The converted instance
    • toJson

      public static com.fasterxml.jackson.databind.JsonNode toJson(Map<CharSequence,Object> values, io.micronaut.inject.visitor.VisitorContext context, @Nullable @Nullable io.micronaut.inject.ast.ClassElement jsonViewClass)
      Convert the given map to a JSON node.
      Parameters:
      values - The values
      context - The visitor context
      jsonViewClass - Class from JsonView annotation
      Returns:
      The node
    • processSchemaProperty

      public static void processSchemaProperty(io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.ast.ClassElement elementType, @Nullable @Nullable io.micronaut.inject.ast.ClassElement classElement, io.swagger.v3.oas.models.media.Schema<?> parentSchema, io.swagger.v3.oas.models.media.Schema<?> propertySchema)
      Processes a schema property.
      Parameters:
      context - The visitor context
      element - The element
      elementType - The element type
      classElement - The class element
      parentSchema - The parent schema
      propertySchema - The property schema
    • getSchemaNameToClassNameMap

      public static Map<String,String> getSchemaNameToClassNameMap()