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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    This class is used as the key when storing Schemas in the registry.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.microprofile.openapi.models.media.Schema
    checkRegistration(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)
    Check if the entityType is eligible for registration using the typeResolver.
    boolean
    hasRef(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
     
    boolean
    hasSchema(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
     
    boolean
    hasSchema(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver)
    Convenience method to check if the current thread's SchemaRegistry contains a schema for the given type (which may require type resolution using resolver).
    boolean
     
    boolean
    isTypeRegistrationSupported(org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema)
     
    org.eclipse.microprofile.openapi.models.media.Schema
    lookupRef(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
     
    org.eclipse.microprofile.openapi.models.media.Schema
    lookupSchema(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
     
    org.eclipse.microprofile.openapi.models.media.Schema
    register(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema, BiFunction<SchemaRegistry,SchemaRegistry.TypeKey,org.eclipse.microprofile.openapi.models.media.Schema> registrationAction)
     
    org.eclipse.microprofile.openapi.models.media.Schema
    register(org.jboss.jandex.Type entityType, Map<org.jboss.jandex.Type,Boolean> views, org.eclipse.microprofile.openapi.models.media.Schema schema)
    Register the provided Schema for the provided Type.
    org.eclipse.microprofile.openapi.models.media.Schema
    registerReference(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema)
    Attempt to register ONLY a reference to entityType using the typeResolver.
    void
    setDisabled(boolean disabled)
     

    Methods inherited from class java.lang.Object

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

  • Method Details

    • checkRegistration

      public org.eclipse.microprofile.openapi.models.media.Schema checkRegistration(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> 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 are
      • CLASS
      • PARAMETERIZED_TYPE
      • TYPE_VARIABLE
      • WILDCARD_TYPE
      If eligible, schema references are enabled by MP Config property mp.openapi.extensions.smallrye.schema-references.enable, and the resolved type is available in the registry's IndexView then the schema can be registered. Only if the type has not already been registered earlier will it be added.
      Parameters:
      type - the Type the Schema applies to
      views - types applied to the currently-active JsonView (Jackson annotation)
      resolver - a TypeResolver that will be used to resolve parameterized and wildcard types
      schema - Schema to 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 org.eclipse.microprofile.openapi.models.media.Schema registerReference(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> 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 are
      • CLASS
      • PARAMETERIZED_TYPE
      • TYPE_VARIABLE
      • WILDCARD_TYPE
      If eligible, schema references are enabled by MP Config property mp.openapi.extensions.smallrye.schema-references.enable, and the resolved type is available in the registry's IndexView then the schema reference can be registered. Only if the type has not already been registered earlier will it be added.
      Parameters:
      type - the Type the Schema applies to
      views - types applied to the currently-active JsonView (Jackson annotation)
      resolver - a TypeResolver that will be used to resolve parameterized and wildcard types
      schema - Schema to add to the registry
      Returns:
      the same schema if not eligible for registration, or a reference to the schema registered for the given Type
    • register

      public org.eclipse.microprofile.openapi.models.media.Schema register(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver, org.eclipse.microprofile.openapi.models.media.Schema schema, BiFunction<SchemaRegistry,SchemaRegistry.TypeKey,org.eclipse.microprofile.openapi.models.media.Schema> registrationAction)
    • hasSchema

      public boolean hasSchema(org.jboss.jandex.Type type, Map<org.jboss.jandex.Type,Boolean> views, TypeResolver resolver)
      Convenience method to check if the current thread's SchemaRegistry contains a schema for the given type (which may require type resolution using resolver).
      Parameters:
      type - type to check for existence of schema
      views - types applied to the currently-active JsonView (Jackson annotation)
      resolver - 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, Map<org.jboss.jandex.Type,Boolean> views, org.eclipse.microprofile.openapi.models.media.Schema schema)
      Register the provided Schema for the provided Type. 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 the Schema applies to
      views -
      schema - Schema to 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, Map<org.jboss.jandex.Type,Boolean> views)
    • hasRef

      public boolean hasRef(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
    • lookupSchema

      public org.eclipse.microprofile.openapi.models.media.Schema lookupSchema(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
    • hasSchema

      public boolean hasSchema(org.jboss.jandex.Type instanceType, Map<org.jboss.jandex.Type,Boolean> views)
    • isTypeRegistrationSupported

      public boolean isTypeRegistrationSupported(org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema)
    • isDisabled

      public boolean isDisabled()
    • setDisabled

      public void setDisabled(boolean disabled)