Skip to content

Commit 22dd182

Browse files
committed
introduce settings object
1 parent 1b6c02f commit 22dd182

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

json-schema-validator/src/main/java/io/openapiprocessor/jsonschema/schema/SchemaStore.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ public class SchemaStore {
2525

2626
private final Map<URI, JsonSchema> schemaCache = new HashMap<> ();
2727

28+
private final Settings settings;
2829
private final DocumentStore documents;
2930
private final DocumentLoader loader;
3031

31-
public SchemaStore (DocumentLoader loader) {
32-
this.documents = new DocumentStore ();
32+
public SchemaStore(DocumentLoader loader) {
33+
this.settings = new Settings().version(SchemaVersion.getLatest());
34+
this.documents = new DocumentStore();
35+
this.loader = loader;
36+
}
37+
38+
public SchemaStore(DocumentLoader loader, Settings settings) {
39+
this.settings = settings;
40+
this.documents = new DocumentStore();
3341
this.loader = loader;
3442
}
3543

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2024 https://github.com/openapi-processor/openapi-parser
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.jsonschema.schema;
7+
8+
import org.checkerframework.checker.nullness.qual.Nullable;
9+
10+
public class Settings {
11+
private @Nullable SchemaVersion version;
12+
private boolean loadSchemas;
13+
14+
public Settings() {
15+
version = null;
16+
loadSchemas = false;
17+
}
18+
19+
public Settings version(SchemaVersion version) {
20+
this.version = version;
21+
return this;
22+
}
23+
24+
public Settings loadSchemas(boolean load) {
25+
this.loadSchemas = load;
26+
return this;
27+
}
28+
29+
public @Nullable SchemaVersion getVersion() {
30+
return version;
31+
}
32+
33+
public boolean isLoadSchemas() {
34+
return loadSchemas;
35+
}
36+
}

0 commit comments

Comments
 (0)