Class ExpandedTypeDescription


public class ExpandedTypeDescription extends org.yaml.snakeyaml.TypeDescription
Extension of TypeDescription that handles:
  • nested enums,
  • extensible types,
  • references, and
  • additional properties (which can be either Boolean or Schema).

The OpenAPI document format uses lower-case enum names and values, while the SmallRye definitions use upper-case. This class simplifies adding the special handling for enums declared within a particular class.

Some of the MP OpenAPI items are extensible, meaning they accept sub-item keys with the "x-" prefix. This class supports extensions. For scalars it delegates to the normal SnakeYAML processing to correctly type and parse the scalar. For sequences it creates Lists. For mappings it creates Maps. The sub-nodes of the lists and maps are handled by the normal SnakeYAML parsing, so the resulting elements in lists and maps are of the SnakeYAML-inferred types.

A sub-node $ref maps to the ref property on the MP OpenAPI types. This type description simplifies defining the $ref property to those types that support it.

In schemas, the additionalProperties value can be either a boolean or a schema. The MicroProfile Schema type exposes getAdditionalPropertiesBoolean, setAdditionalPropertiesBoolean, getAdditionalPropertiesSchema, and setAdditionalPropertiesSchema methods. We do not know until runtime and the value is available for each additionalProperties instance which type (Boolean or Schema) to use, so we cannot just prepare a smart SnakeYAML Property implementation. Instead we augment the schema-specific TypeDescription so it knows how to decide, at runtime, what to do.

We use this expanded version of TypeDescription with the generated SnakeYAMLParserHelper class.

  • Method Details

    • create

      public static ExpandedTypeDescription create(Class<?> clazz, Class<?> impl)
      Factory method for ease of chaining other method invocations.
      clazz - interface type to describe
      impl - implementation class for the interface
      resulting TypeDescription
    • addRef

      public ExpandedTypeDescription addRef()
      Adds property handling for a $ref reference.
      this type description
    • addExtensions

      public ExpandedTypeDescription addExtensions()
      Adds property handling for extensions.
      this type description
    • getProperty

      public org.yaml.snakeyaml.introspector.Property getProperty(String name)
      getProperty in class org.yaml.snakeyaml.TypeDescription
    • setupPropertyType

      public boolean setupPropertyType(String key, org.yaml.snakeyaml.nodes.Node valueNode)
      setupPropertyType in class org.yaml.snakeyaml.TypeDescription
    • newInstance

      public Object newInstance(String propertyName, org.yaml.snakeyaml.nodes.Node node)
      newInstance in class org.yaml.snakeyaml.TypeDescription
    • addExcludes

      public void addExcludes(String... propNames)
      Add property names excludes.
      propNames - names to exclude
    • impl

      public Class<?> impl()
      Returns the implementation class associated with this type descr.
      implementation class
    • hasDefaultProperty

      public boolean hasDefaultProperty()
      Whether a default value exists.
      true if default value property is defined