Interface JsonSchemaBuilder

All Known Implementing Classes:
VictoolsJsonSchemaBuilder

public interface JsonSchemaBuilder
Creates Json Schema from (annotated) class files. Considered annotations depend on the implementation.
  • Method Details

    • toJsonSchema

      Map<String,com.fasterxml.jackson.databind.JsonNode> toJsonSchema(Type type)
      Creates Json Schema (in version Draft 07 as required by AsyncAPI) for the given type.
      Parameters:
      type - the java type, usually a Class, for which the Json Schema should be created.
      Returns:
      A Map with the Json Schemas of all types needed to describe the given type. The key of the map qualifies as definition key as used in /components/schemas/<key> for the respective Json Schema. One key exactly matches the Class.getSimpleName() of the given type and refers to the Json Schema of that type. All references to other generated schemas in the returned map are qualified as $ref: "#/components/messages/<map-entry-key> when referenced.
      See Also:
    • toJsonSchema

      default Map<String,com.fasterxml.jackson.databind.JsonNode> toJsonSchema(Iterable<Type> types)
      Creates Json Schema (in version Draft 07 as required by AsyncAPI) for all given types. It may happen, that schemas are generated multiple times if types required to describe the given types are needed multiple times. In this case the last generated schema takes precedence.

      In the default implementation, conflicting schemas may be created if classes with the same simple name are involved, e.g. a Status enum from different packages, when used in different given types. These conflicts are not resolved unless the resulting schema is equal, but an IllegalStateException is thrown.

      Parameters:
      types - the java types, usually Classes, for which the Json Schema should be created. Types given multiple times are only considered once.
      Returns:
      A Map with the Json Schemas of all types needed to describe the given types. The key of the map qualifies as definition key as used in /components/schemas/<key> for the respective Json Schemas. One key exactly matches the Class.getSimpleName() of the given types and refers to the Json Schema of that type. All references to other generated schemas in the returned map are qualified as $ref: "#/components/messages/<map-entry-key> when referenced.
      Throws:
      IllegalStateException - if conflicting schemas are produced.
      See Also: