Interface JsonSchemaBuilder
- All Known Implementing Classes:
VictoolsJsonSchemaBuilder
public interface JsonSchemaBuilder
Creates Json Schema from (annotated) class files. Considered annotations depend on the
implementation.
-
Method Summary
-
Method Details
-
toJsonSchema
- Parameters:
type
- the java type, usually aClass
, for which the Json Schema should be created.- Returns:
- A
Map
with the Json Schemas of all types needed to describe the giventype
. The key of the map qualifies as definition key as used in/components/schemas/<key>
for the respective Json Schema. One key exactly matches theClass.getSimpleName()
of the giventype
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
Creates Json Schema (in version Draft 07 as required by AsyncAPI) for all giventypes
. 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 anIllegalStateException
is thrown.- Parameters:
types
- the java types, usuallyClass
es, 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 giventypes
. The key of the map qualifies as definition key as used in/components/schemas/<key>
for the respective Json Schemas. One key exactly matches theClass.getSimpleName()
of the giventypes
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:
-