diff --git a/src/main/java/io/vertx/json/schema/SchemaRepository.java b/src/main/java/io/vertx/json/schema/SchemaRepository.java index 362156e8..f11574cc 100644 --- a/src/main/java/io/vertx/json/schema/SchemaRepository.java +++ b/src/main/java/io/vertx/json/schema/SchemaRepository.java @@ -18,7 +18,7 @@ /** * A repository is a holder of dereferenced schemas, it can be used to create validator instances for a specific schema. - * + *
* This is to be used when multiple schema objects compose the global schema to be used for validation. * * @author Paulo Lopes @@ -28,6 +28,7 @@ public interface SchemaRepository { /** * Create a repository with some initial configuration. + * * @param options the initial configuration * @return a repository */ @@ -39,8 +40,8 @@ static SchemaRepository create(JsonSchemaOptions options) { * Dereferences a schema to the repository. * * @param schema a new schema to list - * @throws SchemaException when a schema is already present for the same id * @return a repository + * @throws SchemaException when a schema is already present for the same id */ @Fluent SchemaRepository dereference(JsonSchema schema) throws SchemaException; @@ -48,18 +49,30 @@ static SchemaRepository create(JsonSchemaOptions options) { /** * Dereferences a schema to the repository. * - * @param uri the source of the schema used for de-referencing, optionally relative to - * {@link JsonSchemaOptions#getBaseUri()}. + * @param uri the source of the schema used for de-referencing, optionally relative to + * {@link JsonSchemaOptions#getBaseUri()}. * @param schema a new schema to list - * @throws SchemaException when a schema is already present for the same id * @return a repository + * @throws SchemaException when a schema is already present for the same id */ @Fluent SchemaRepository dereference(String uri, JsonSchema schema) throws SchemaException; /** - * Preloads the repository with the meta schemas for the related draft version. + * Preloads the repository with the meta schemas for the related @link {@link Draft} version. The related draft version + * is determined from the {@link JsonSchemaOptions}, in case that no draft is set in the options an + * {@link IllegalStateException} is thrown. + * * @param fs The Vert.x file system to load the related schema meta files from classpath + * @return a repository + */ + @Fluent + SchemaRepository preloadMetaSchema(FileSystem fs); + + /** + * Preloads the repository with the meta schemas for the related draft version. + * + * @param fs The Vert.x file system to load the related schema meta files from classpath * @param draft The draft version of the meta files to load * @return a repository */ @@ -85,7 +98,7 @@ static SchemaRepository create(JsonSchemaOptions options) { /** * A new validator instance overriding this repository options. * - * @param schema the start validation schema + * @param schema the start validation schema * @param options the options to be using on the validator instance * @return the validator */ @@ -94,7 +107,7 @@ static SchemaRepository create(JsonSchemaOptions options) { /** * A new validator instance overriding this repository options. * - * @param ref the start validation reference in JSON pointer format + * @param ref the start validation reference in JSON pointer format * @param options the options to be using on the validator instance * @return the validator */ @@ -102,7 +115,7 @@ static SchemaRepository create(JsonSchemaOptions options) { /** * Tries to resolve all internal and repository local references. External references are not resolved. - * + *
* The result is an object where all references have been resolved. Resolution of references is shallow. This * should normally not be a problem for this use case. * @@ -113,7 +126,7 @@ static SchemaRepository create(JsonSchemaOptions options) { /** * Tries to resolve all internal and repository local references. External references are not resolved. - * + *
* The result is an object where all references have been resolved. Resolution of references is shallow. This
* should normally not be a problem for this use case.
*
@@ -125,6 +138,7 @@ static SchemaRepository create(JsonSchemaOptions options) {
/**
* Look up a schema using a JSON pointer notation
+ *
* @param pointer the JSON pointer
* @return the schema
*/
diff --git a/src/main/java/io/vertx/json/schema/impl/SchemaRepositoryImpl.java b/src/main/java/io/vertx/json/schema/impl/SchemaRepositoryImpl.java
index 41198240..c2f157aa 100644
--- a/src/main/java/io/vertx/json/schema/impl/SchemaRepositoryImpl.java
+++ b/src/main/java/io/vertx/json/schema/impl/SchemaRepositoryImpl.java
@@ -118,7 +118,16 @@ public SchemaRepository dereference(String uri, JsonSchema schema) throws Schema
return this;
}
- @Override public SchemaRepository preloadMetaSchema(FileSystem fs, Draft draft) {
+ @Override
+ public SchemaRepository preloadMetaSchema(FileSystem fs) {
+ if (options.getDraft() == null) {
+ throw new IllegalStateException("No draft version is defined in the options of the repository");
+ }
+ return preloadMetaSchema(fs, options.getDraft());
+ }
+
+ @Override
+ public SchemaRepository preloadMetaSchema(FileSystem fs, Draft draft) {
List