Class SchemaRegistry
- java.lang.Object
-
- io.smallrye.openapi.runtime.scanner.SchemaRegistry
-
public class SchemaRegistry extends Object
A simple registry used to track schemas that have been generated and inserted into the #/components section of the- Author:
- eric.wittmann@gmail.com
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.eclipse.microprofile.openapi.models.media.SchemacheckRegistration(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)Check if the entityType is eligible for registration using the typeResolver.static SchemaRegistrycurrentInstance()Retrieve theSchemaRegistrypreviously created bynewInstancefor the current thread, ornullif none has yet been created.booleanhasRef(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)booleanhasSchema(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)static booleanhasSchema(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver)Convenience method to check if the current thread'sSchemaRegistrycontains a schema for the given type (which may require type resolution using resolver).booleanisTypeRegistrationSupported(org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema)org.eclipse.microprofile.openapi.models.media.SchemalookupRef(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)org.eclipse.microprofile.openapi.models.media.SchemalookupSchema(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)static SchemaRegistrynewInstance(AnnotationScannerContext context)Create a new instance of aSchemaRegistryon this thread.org.eclipse.microprofile.openapi.models.media.Schemaregister(org.jboss.jandex.Type entityType, Set<org.jboss.jandex.Type> views, org.eclipse.microprofile.openapi.models.media.Schema schema)Register the providedSchemafor the providedType.static org.eclipse.microprofile.openapi.models.media.SchemaregisterReference(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)Attempt to register ONLY a reference to entityType using the typeResolver.static voidremove()
-
-
-
Method Detail
-
newInstance
public static SchemaRegistry newInstance(AnnotationScannerContext context)
Create a new instance of aSchemaRegistryon this thread. The registry returned by this method may also be obtained by subsequent calls tocurrentInstance(). Additional calls of this method will replace the registry in the current thread context with a new instance.- Parameters:
context- current scanner context- Returns:
- the registry
-
currentInstance
public static SchemaRegistry currentInstance()
Retrieve theSchemaRegistrypreviously created bynewInstancefor the current thread, ornullif none has yet been created.- Returns:
- a
SchemaRegistryinstance or null
-
remove
public static void remove()
-
checkRegistration
public static org.eclipse.microprofile.openapi.models.media.Schema checkRegistration(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)Check if the entityType is eligible for registration using the typeResolver. The eligible kinds of types areCLASSPARAMETERIZED_TYPETYPE_VARIABLEWILDCARD_TYPE
mp.openapi.extensions.smallrye.schema-references.enable, and the resolved type is available in the registry'sIndexViewthen the schema can be registered. Only if the type has not already been registered earlier will it be added.- Parameters:
type- theTypetheSchemaapplies toresolver- aTypeResolverthat will be used to resolve parameterized and wildcard typesschema-Schemato add to the registry- Returns:
- the same schema if not eligible for registration, or a reference to the schema registered for the given Type
-
registerReference
public static org.eclipse.microprofile.openapi.models.media.Schema registerReference(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)Attempt to register ONLY a reference to entityType using the typeResolver. The eligible kinds of types areCLASSPARAMETERIZED_TYPETYPE_VARIABLEWILDCARD_TYPE
mp.openapi.extensions.smallrye.schema-references.enable, and the resolved type is available in the registry'sIndexViewthen the schema reference can be registered. Only if the type has not already been registered earlier will it be added.- Parameters:
type- theTypetheSchemaapplies toresolver- aTypeResolverthat will be used to resolve parameterized and wildcard typesschema-Schemato add to the registry- Returns:
- the same schema if not eligible for registration, or a reference to the schema registered for the given Type
-
hasSchema
public static boolean hasSchema(org.jboss.jandex.Type type, Set<org.jboss.jandex.Type> views, TypeResolver resolver)Convenience method to check if the current thread'sSchemaRegistrycontains a schema for the given type (which may require type resolution using resolver).- Parameters:
type- type to check for existence of schemaresolver- resolver for type parameter- Returns:
- true when schema references are enabled and the type is present in the registry, otherwise false
-
register
public org.eclipse.microprofile.openapi.models.media.Schema register(org.jboss.jandex.Type entityType, Set<org.jboss.jandex.Type> views, org.eclipse.microprofile.openapi.models.media.Schema schema)Register the providedSchemafor the providedType. If an existing schema has already been registered for the type, it will be replaced by the schema given in this method.- Parameters:
entityType- the type theSchemaapplies toviews-schema-Schemato add to the registry- Returns:
- a reference to the newly registered
Schema
-
lookupRef
public org.eclipse.microprofile.openapi.models.media.Schema lookupRef(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)
-
hasRef
public boolean hasRef(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)
-
lookupSchema
public org.eclipse.microprofile.openapi.models.media.Schema lookupSchema(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)
-
hasSchema
public boolean hasSchema(org.jboss.jandex.Type instanceType, Set<org.jboss.jandex.Type> views)
-
isTypeRegistrationSupported
public boolean isTypeRegistrationSupported(org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema)
-
-