Class OpenApiDataObjectScanner
- java.lang.Object
-
- io.smallrye.openapi.runtime.scanner.OpenApiDataObjectScanner
-
public class OpenApiDataObjectScanner extends Object
Explores the class graph from the provided root, creating an OpenAPISchemafrom the entities encountered.A depth first search is performed, with the following precedence (high to low):
- 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.
- Unannotated fields unless property openapi.infer-unannotated-types set false
- 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 <marc@rhymewithgravy.com>
- See Also:
Schema Annotation,Schema Object
-
-
Field Summary
Fields Modifier and Type Field Description static org.jboss.jandex.TypeARRAY_TYPE_OBJECTstatic org.jboss.jandex.DotNameENUM_INTERFACE_NAMEstatic org.jboss.jandex.TypeENUM_TYPEstatic org.jboss.jandex.DotNameITERABLE_INTERFACE_NAMEstatic org.jboss.jandex.TypeITERABLE_TYPEstatic org.jboss.jandex.DotNameMAP_INTERFACE_NAMEstatic org.jboss.jandex.TypeMAP_TYPEstatic org.jboss.jandex.DotNameSET_INTERFACE_NAMEstatic org.jboss.jandex.TypeSET_TYPEstatic org.jboss.jandex.DotNameSTREAM_INTERFACE_NAMEstatic org.jboss.jandex.TypeSTREAM_TYPEstatic org.jboss.jandex.TypeSTRING_TYPE
-
Constructor Summary
Constructors Constructor Description OpenApiDataObjectScanner(AnnotationScannerContext context, org.jboss.jandex.AnnotationTarget annotationTarget, org.jboss.jandex.Type classType)OpenApiDataObjectScanner(AnnotationScannerContext context, org.jboss.jandex.Type classType)Constructor for data object scanner.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.eclipse.microprofile.openapi.models.media.Schemaprocess(AnnotationScannerContext context, org.jboss.jandex.Type type)Build a Schema with ClassType as root.static org.eclipse.microprofile.openapi.models.media.Schemaprocess(org.jboss.jandex.PrimitiveType primitive)Build a Schema with PrimitiveType as root.
-
-
-
Field Detail
-
ITERABLE_INTERFACE_NAME
public static final org.jboss.jandex.DotName ITERABLE_INTERFACE_NAME
-
ITERABLE_TYPE
public static final org.jboss.jandex.Type ITERABLE_TYPE
-
STREAM_INTERFACE_NAME
public static final org.jboss.jandex.DotName STREAM_INTERFACE_NAME
-
STREAM_TYPE
public static final org.jboss.jandex.Type STREAM_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 theSchema.- Parameters:
context- scanning contextclassType- 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 contexttype- 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
-
-