Class OpenApiDataObjectScanner


  • public class OpenApiDataObjectScanner
    extends Object
    Explores the class graph from the provided root, creating an OpenAPI Schema from the entities encountered.

    A depth first search is performed, with the following precedence (high to low):

    1. Explicitly provided attributes/overrides on @Schema annotated elements. Note that some attributes have special behaviours: for example, ref is mutually exclusive, and implementation replaces the implementation entirely.
    2. Unannotated fields unless property openapi.infer-unannotated-types set false
    3. Inferred attributes, such as name, type, format, etc.

    Well-known types, such as Collection, Map, Date, etc, are handled in a custom manner. Jandex-indexed objects from the user's deployment are traversed until a terminal type is met (such as a primitive, boxed primitive, date, etc), or an entity is encountered that is not well-known or is not in the Jandex IndexView. Current Limitations: If a type is not available in the provided IndexView then it is not accessible. Excepting well-known types, this means non-deployment objects may not be scanned.

    Future work could consider making the user's deployment classes available to this classloader, with additional code to traverse non-Jandex types reachable from this classloader. But, this is troublesome for performance, security and initialisation reasons -- particular caution would be needed to avoid accidental initialisation of classes that may have externally visible side-effects.

    Author:
    Marc Savy <[email protected]>
    See Also:
    Schema Annotation, Schema Object
    • Field Detail

      • OBJECT_TYPE

        public static final org.jboss.jandex.Type OBJECT_TYPE
      • COLLECTION_INTERFACE_NAME

        public static final org.jboss.jandex.DotName COLLECTION_INTERFACE_NAME
      • COLLECTION_TYPE

        public static final org.jboss.jandex.Type COLLECTION_TYPE
      • ITERABLE_INTERFACE_NAME

        public static final org.jboss.jandex.DotName ITERABLE_INTERFACE_NAME
      • ITERABLE_TYPE

        public static final org.jboss.jandex.Type ITERABLE_TYPE
      • MAP_INTERFACE_NAME

        public static final org.jboss.jandex.DotName MAP_INTERFACE_NAME
      • MAP_TYPE

        public static final org.jboss.jandex.Type MAP_TYPE
      • SET_INTERFACE_NAME

        public static final org.jboss.jandex.DotName SET_INTERFACE_NAME
      • SET_TYPE

        public static final org.jboss.jandex.Type SET_TYPE
      • ENUM_INTERFACE_NAME

        public static final org.jboss.jandex.DotName ENUM_INTERFACE_NAME
      • ENUM_TYPE

        public static final org.jboss.jandex.Type ENUM_TYPE
      • STRING_TYPE

        public static final org.jboss.jandex.Type STRING_TYPE
      • ARRAY_TYPE_OBJECT

        public static final org.jboss.jandex.Type ARRAY_TYPE_OBJECT
    • Constructor Detail

      • OpenApiDataObjectScanner

        public OpenApiDataObjectScanner​(AnnotationScannerContext context,
                                        org.jboss.jandex.Type classType)
        Constructor for data object scanner.

        Call process() to build and return the Schema.

        Parameters:
        context - scanning context
        classType - root to begin scan
      • OpenApiDataObjectScanner

        public OpenApiDataObjectScanner​(AnnotationScannerContext context,
                                        org.jboss.jandex.AnnotationTarget annotationTarget,
                                        org.jboss.jandex.Type classType)
    • Method Detail

      • process

        public static org.eclipse.microprofile.openapi.models.media.Schema process​(AnnotationScannerContext context,
                                                                                   org.jboss.jandex.Type type)
        Build a Schema with ClassType as root.
        Parameters:
        context - scanning context
        type - root to begin scan
        Returns:
        the OAI schema
      • process

        public static org.eclipse.microprofile.openapi.models.media.Schema process​(org.jboss.jandex.PrimitiveType primitive)
        Build a Schema with PrimitiveType as root.
        Parameters:
        primitive - root to begin scan
        Returns:
        the OAI schema