io.vertx.json.schema

## Interface SchemaRouter

- All Known Implementing Classes:
    SchemaRouterImpl

      public interface SchemaRouter

  Represents a pool where parsed schemas are addressed and cached.

  It also contains a cache of `JsonObject` including on top or inner level some json schemas that could eventually parsed later.

  You should not share this object between different threads

  Author:
    slinkydeveloper

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default SchemaRouter` | `addJson(String uri, JsonObject object)` Add one or more json documents including schemas on top or inner levels.
    `SchemaRouter` | `addJson(URI uri, JsonObject object)` Add one or more json documents including schemas on top or inner levels.
    `SchemaRouter` | `addSchema(Schema schema, JsonPointer... aliasScopes)` Add a parsed schema to this router.
    `SchemaRouter` | `addSchemaAlias(Schema schema, String alias)` Add an alias to a schema already registered in this router (this alias can be solved only from schema scope).
    `SchemaRouter` | `addSchemaWithScope(Schema schema, JsonPointer scope)` Add a parsed schema to this router.
    `static SchemaRouter` | `create(HttpClient client, FileSystem fs, SchemaRouterOptions schemaRouterOptions)` Create a new `SchemaRouter`
    `static SchemaRouter` | `create(Vertx vertx, SchemaRouterOptions schemaRouterOptions)` Create a new `SchemaRouter`
    `List<Schema>` | `registeredSchemas()`
    `Schema` | `resolveCachedSchema(JsonPointer refPointer, JsonPointer schemaScope, SchemaParser parser)` Resolve cached schema based on refPointer.
    `Future<Schema>` | `resolveRef(JsonPointer pointer, JsonPointer scope, SchemaParser schemaParser)` Resolve $ref.
    `void` | `resolveRef(JsonPointer pointer, JsonPointer scope, SchemaParser schemaParser, Handler<AsyncResult<Schema>> handler)` Like `resolveRef(JsonPointer, JsonPointer, SchemaParser)` but with a direct callback.

- - ### Method Detail

    - #### resolveCachedSchema

          Schema resolveCachedSchema(JsonPointer refPointer,
                                     JsonPointer schemaScope,
                                     SchemaParser parser)
                              throws SchemaException

      Resolve cached schema based on refPointer. If a schema isn't cached, it returns null
      Parameters:
        `refPointer` -
        `schemaScope` -
        `parser` -
      Returns:
        the resolved schema, or null if no schema was found
      Throws:
        `SchemaException` - If was found an unparsed schema that is an invalid json schema

    - #### resolveRef

          void resolveRef(JsonPointer pointer,
                          JsonPointer scope,
                          SchemaParser schemaParser,
                          Handler<AsyncResult<Schema>> handler)

      Like `resolveRef(JsonPointer, JsonPointer, SchemaParser)` but with a direct callback.

    - #### resolveRef

          Future<Schema> resolveRef(JsonPointer pointer,
                                    JsonPointer scope,
                                    SchemaParser schemaParser)

      Resolve $ref.
      This method tries to resolve schema from local cache. If it's not found, it solve external references. It can solve external references on filesystem and remote references using http. When you pass a relative reference without protocol, it tries to infer the absolute path from scope and cached schemas
      Returns a future that can contain Schema or be null or can fail with a `SchemaException` or an `IllegalArgumentException`
      Parameters:
        `pointer` -
        `scope` -
        `schemaParser` -
      Returns:
        a succeeded future that contains the resolved `Schema` or failed with a `SchemaException` or an `IllegalArgumentException`

    - #### addSchema

          SchemaRouter addSchema(Schema schema,
                                 JsonPointer... aliasScopes)

      Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for `Schema.getScope()` and, if you provide additional aliasScopes, this method register links to this schema with these scopes. This method is automatically called by `SchemaParser` when a new schema is parsed
      Parameters:
        `schema` - schema to add
      Returns:
        a reference to this
      Throws:
        `IllegalStateException` - if the schema contains a scope with a relative `URI` or one of the aliasScopes has a relative `URI`

    - #### addSchemaWithScope

          SchemaRouter addSchemaWithScope(Schema schema,
                                          JsonPointer scope)

      Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for the provided scope, but NOT for `Schema.getScope()`. This may be useful to register links to singleton schemas. This method is automatically called by `SchemaParser` when a new schema is parsed
      Parameters:
        `schema` - schema to add
      Returns:
        a reference to this
      Throws:
        `IllegalStateException` - if the provided scope contains a relative `URI`

    - #### addSchemaAlias

          SchemaRouter addSchemaAlias(Schema schema,
                                      String alias)

      Add an alias to a schema already registered in this router (this alias can be solved only from schema scope).
      Parameters:
        `schema` - schema to add
        `alias` - the schema alias
      Returns:
        a reference to this

    - #### addJson

          SchemaRouter addJson(URI uri,
                               JsonObject object)

      Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing

      You can use this schema if you have externally loaded some json document and you want to register to the schema router. You can later parse and retrieve a schema from this json structure using `this#resolveCachedSchema(JsonPointer, JsonPointer, SchemaParser)`, providing the correct `refPointer`

      Parameters:
        `uri` -
        `object` -
      Returns:
        a reference to this

    - #### addJson

          default SchemaRouter addJson(String uri,
                                       JsonObject object)

      Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing

      You can use this schema if you have externally loaded some json document and you want to register to the schema router. You can later parse and retrieve a schema from this json structure using `this#resolveCachedSchema(JsonPointer, JsonPointer, SchemaParser)`, providing the correct `refPointer`

      Parameters:
        `uri` -
        `object` -
      Returns:
        a reference to this

    - #### registeredSchemas

          List<Schema> registeredSchemas()

      Returns:
        a list of all registered schemas

    - #### create

          static SchemaRouter create(Vertx vertx,
                                     SchemaRouterOptions schemaRouterOptions)

      Create a new `SchemaRouter`
      Parameters:
        `vertx` -
        `schemaRouterOptions` -
      Returns:

    - #### create

          static SchemaRouter create(HttpClient client,
                                     FileSystem fs,
                                     SchemaRouterOptions schemaRouterOptions)

      Create a new `SchemaRouter`
      Parameters:
        `client` -
        `fs` -
        `schemaRouterOptions` -
      Returns:

Copyright © 2021 Eclipse. All rights reserved.