Class JsonSchemaVisitor

java.lang.Object
io.micronaut.jsonschema.visitor.JsonSchemaVisitor
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.core.util.Toggleable, io.micronaut.inject.visitor.TypeElementVisitor<JsonSchema,Object>

@Internal public final class JsonSchemaVisitor extends Object implements io.micronaut.inject.visitor.TypeElementVisitor<JsonSchema,Object>
A visitor for creating JSON schemas for beans. The bean must have a JsonSchema annotation.
Since:
1.0.0
Author:
Andriy Dmytruk
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Schema
    createSchema(io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)
    A method for creating a property of the schema.
    static Schema
    createTopLevelSchema(io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)
    A method for creating a JSON schema.
     
    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
     
    static void
    setBeanSchemaProperties(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context, Schema schema)
     
    void
    visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext visitorContext)
     
    static void
    writeSchema(Schema schema, io.micronaut.inject.ast.ClassElement originatingElement, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder

    Methods inherited from interface io.micronaut.core.util.Toggleable

    isEnabled

    Methods inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    finish, getClassType, getElementType, getSupportedAnnotationNames, start, visitConstructor, visitEnumConstant, visitField, visitMethod
  • Constructor Details

    • JsonSchemaVisitor

      public JsonSchemaVisitor()
  • Method Details

    • getVisitorKind

      @NonNull public io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind getVisitorKind()
      Specified by:
      getVisitorKind in interface io.micronaut.inject.visitor.TypeElementVisitor<JsonSchema,Object>
    • getSupportedOptions

      public Set<String> getSupportedOptions()
      Specified by:
      getSupportedOptions in interface io.micronaut.inject.visitor.TypeElementVisitor<JsonSchema,Object>
    • visitClass

      public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext visitorContext)
      Specified by:
      visitClass in interface io.micronaut.inject.visitor.TypeElementVisitor<JsonSchema,Object>
    • createTopLevelSchema

      public static Schema createTopLevelSchema(io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)
      A method for creating a JSON schema. The schema will always a top-level schema and never a reference.
      Parameters:
      element - The element
      visitorContext - The visitor context
      context - The JSON schema creation context
      Returns:
      The schema
    • createSchema

      public static Schema createSchema(io.micronaut.inject.ast.TypedElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)
      A method for creating a property of the schema. In case the property references another schema, it will create a reference.
      Parameters:
      element - The element
      visitorContext - The visitor context
      context - The JSON schema creation context
      Returns:
      The schema
    • setBeanSchemaProperties

      public static void setBeanSchemaProperties(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context, Schema schema)
    • writeSchema

      public static void writeSchema(Schema schema, io.micronaut.inject.ast.ClassElement originatingElement, io.micronaut.inject.visitor.VisitorContext visitorContext, JsonSchemaContext context)