Class JsonSchemaNaming

java.lang.Object
io.micronaut.jsonschema.naming.JsonSchemaNaming

@Internal public final class JsonSchemaNaming extends Object
The naming of the JSON schemas generated for JsonSchema types.

The annotation processor names the generated META-INF/<outputLocation>/<name>.schema.json files and their $id with these methods, and the runtime uses the same methods to find the schema of a type.

Since:
2.3.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The scheme of the default base URI, which NetworkNT and other validators resolve from the classpath.
    static final String
    The folder of the generated schemas on the classpath.
    static final String
    The suffix of the generated schema files.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Convert from camel case to kebab case, skipping the dots between the names of nested types.
    static String
    defaultBaseUri(String outputLocation)
    The default base URI of the schemas: classpath:META-INF/<outputLocation>, so that the $refs between generated schemas resolve from the classpath.
    static String
    fileName(String id, @Nullable String baseUri, String outputLocation)
    The path of a schema file inside the output location.
    static String
    id(String uri, @Nullable String baseUri)
    The $id of a schema.
    static boolean
    Whether a schema URI is absolute.
    static String
    simpleName(Class<?> type)
    The simple name of a class including the names of the classes it is nested in, for example Outer$Inner, as the annotation processor sees it.
    static String
    title(@Nullable String title, String simpleName)
    The title of a schema.
    static String
    uri(String title, @Nullable String uri)
    The URI of a schema, relative to the base URI unless the uri member of the annotation is absolute.

    Methods inherited from class Object

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

    • SUFFIX

      public static final String SUFFIX
      The suffix of the generated schema files.
      See Also:
    • CLASSPATH_SCHEME

      public static final String CLASSPATH_SCHEME
      The scheme of the default base URI, which NetworkNT and other validators resolve from the classpath.
      See Also:
    • META_INF

      public static final String META_INF
      The folder of the generated schemas on the classpath.
      See Also:
  • Method Details

    • defaultBaseUri

      public static String defaultBaseUri(String outputLocation)
      The default base URI of the schemas: classpath:META-INF/<outputLocation>, so that the $refs between generated schemas resolve from the classpath.
      Parameters:
      outputLocation - The location of the schemas inside the META-INF/ directory
      Returns:
      The base URI, without a trailing slash
    • title

      public static String title(@Nullable String title, String simpleName)
      The title of a schema.
      Parameters:
      title - The title of the JsonSchema annotation, if any
      simpleName - The simple name of the type, where nested types are separated by $ or ., for example Outer$Inner
      Returns:
      The title
    • simpleName

      public static String simpleName(Class<?> type)
      The simple name of a class including the names of the classes it is nested in, for example Outer$Inner, as the annotation processor sees it.
      Parameters:
      type - The type
      Returns:
      The simple name
    • uri

      public static String uri(String title, @Nullable String uri)
      The URI of a schema, relative to the base URI unless the uri member of the annotation is absolute.
      Parameters:
      title - The title of the schema, see title(String, String)
      uri - The URI of the JsonSchema annotation, if any
      Returns:
      The URI
    • id

      public static String id(String uri, @Nullable String baseUri)
      The $id of a schema.
      Parameters:
      uri - The URI of the schema, see uri(String, String)
      baseUri - The base URI, if any
      Returns:
      The $id
    • isAbsolute

      public static boolean isAbsolute(String uri)
      Whether a schema URI is absolute.
      Parameters:
      uri - The URI
      Returns:
      Whether it is absolute
    • fileName

      public static String fileName(String id, @Nullable String baseUri, String outputLocation)
      The path of a schema file inside the output location.
      Parameters:
      id - The $id or the URI of the schema
      baseUri - The base URI, if known
      outputLocation - The location of the schemas inside the META-INF/ directory
      Returns:
      The path, for example llama.schema.json
    • camelCaseToKebabCase

      public static String camelCaseToKebabCase(String value)
      Convert from camel case to kebab case, skipping the dots between the names of nested types.
      Parameters:
      value - The value
      Returns:
      The converted value