Skip to content

Commit b3d17a1

Browse files
committed
Update -validator to 2.1.0, update code accordingly
Remove ref expander for now. Signed-off-by: Francis Galiegue <[email protected]>
1 parent 0c7bf4a commit b3d17a1

18 files changed

+72
-271
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<dependency>
7171
<groupId>com.github.fge</groupId>
7272
<artifactId>json-schema-validator</artifactId>
73-
<version>2.0.1</version>
73+
<version>2.1.0</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>com.github.reinert</groupId>

src/main/java/com/github/fge/avro/Avro2JsonSchemaProcessor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
import com.github.fge.avro.translators.AvroTranslators;
55
import com.github.fge.jsonschema.exceptions.ProcessingException;
66
import com.github.fge.jsonschema.processing.Processor;
7-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
87
import com.github.fge.jsonschema.report.ProcessingReport;
98
import com.github.fge.jsonschema.tree.CanonicalSchemaTree;
109
import com.github.fge.jsonschema.tree.JsonTree;
10+
import com.github.fge.jsonschema.tree.SchemaTree;
1111
import com.github.fge.jsonschema.util.ValueHolder;
1212
import org.apache.avro.AvroRuntimeException;
1313
import org.apache.avro.Schema;
1414

1515
public final class Avro2JsonSchemaProcessor
16-
implements Processor<ValueHolder<JsonTree>, SchemaHolder>
16+
implements Processor<ValueHolder<JsonTree>, ValueHolder<SchemaTree>>
1717
{
1818
@Override
19-
public SchemaHolder process(final ProcessingReport report,
19+
public ValueHolder<SchemaTree> process(final ProcessingReport report,
2020
final ValueHolder<JsonTree> input)
2121
throws ProcessingException
2222
{
@@ -35,6 +35,8 @@ public SchemaHolder process(final ProcessingReport report,
3535
AvroTranslators.getTranslator(avroType)
3636
.translate(avroSchema, tree, report);
3737

38-
return new SchemaHolder(new CanonicalSchemaTree(tree.getBaseNode()));
38+
final SchemaTree schemaTree
39+
= new CanonicalSchemaTree(tree.getBaseNode());
40+
return ValueHolder.hold("schema", schemaTree);
3941
}
4042
}

src/main/java/com/github/fge/jjschema/JJSchemaFromSource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import com.github.fge.compiler.CompilingException;
66
import com.github.fge.jsonschema.exceptions.ProcessingException;
77
import com.github.fge.jsonschema.processing.Processor;
8-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
98
import com.github.fge.jsonschema.report.ProcessingReport;
9+
import com.github.fge.jsonschema.tree.SchemaTree;
10+
import com.github.fge.jsonschema.util.ValueHolder;
1011

1112
import java.io.File;
1213

1314
public final class JJSchemaFromSource
14-
implements Processor<SourceHolder, SchemaHolder>
15+
implements Processor<SourceHolder, ValueHolder<SchemaTree>>
1516
{
1617
private static final JJSchemaFromSource INSTANCE = new JJSchemaFromSource();
1718

@@ -28,7 +29,7 @@ private JJSchemaFromSource()
2829
}
2930

3031
@Override
31-
public SchemaHolder process(final ProcessingReport report,
32+
public ValueHolder<SchemaTree> process(final ProcessingReport report,
3233
final SourceHolder input)
3334
throws ProcessingException
3435
{

src/main/java/com/github/fge/jjschema/JJSchemaProcessor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.github.fge.jsonschema.exceptions.ProcessingException;
55
import com.github.fge.jsonschema.processing.Processor;
6-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
76
import com.github.fge.jsonschema.report.ProcessingMessage;
87
import com.github.fge.jsonschema.report.ProcessingReport;
98
import com.github.fge.jsonschema.tree.CanonicalSchemaTree;
9+
import com.github.fge.jsonschema.tree.SchemaTree;
10+
import com.github.fge.jsonschema.util.ValueHolder;
1011
import com.github.reinert.jjschema.JsonSchemaGenerator;
1112
import com.github.reinert.jjschema.SchemaGeneratorBuilder;
1213

1314
public final class JJSchemaProcessor
14-
implements Processor<ClassHolder, SchemaHolder>
15+
implements Processor<ClassHolder, ValueHolder<SchemaTree>>
1516
{
1617
private static final JsonSchemaGenerator GENERATOR
1718
= SchemaGeneratorBuilder.draftV4Schema().build();
1819

1920
@Override
20-
public SchemaHolder process(final ProcessingReport report,
21+
public ValueHolder<SchemaTree> process(final ProcessingReport report,
2122
final ClassHolder input)
2223
throws ProcessingException
2324
{
2425
final ProcessingMessage message = input.newMessage();
2526
report.debug(message.message("processing"));
2627
final JsonNode node = GENERATOR.generateSchema(input.getValue());
27-
return new SchemaHolder(new CanonicalSchemaTree(node));
28+
final SchemaTree tree = new CanonicalSchemaTree(node);
29+
return ValueHolder.hold("schema", tree);
2830
}
2931
}

src/main/java/com/github/fge/jjschema/JJSchemaValidator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package com.github.fge.jjschema;
22

33
import com.fasterxml.jackson.databind.JsonNode;
4-
import com.github.fge.jsonschema.cfg.LoadingConfiguration;
54
import com.github.fge.jsonschema.exceptions.ProcessingException;
65
import com.github.fge.jsonschema.library.DraftV4Library;
6+
import com.github.fge.jsonschema.load.RefResolver;
77
import com.github.fge.jsonschema.load.SchemaLoader;
8+
import com.github.fge.jsonschema.load.configuration.LoadingConfiguration;
89
import com.github.fge.jsonschema.processors.data.FullData;
9-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
10-
import com.github.fge.jsonschema.processors.ref.RefResolver;
1110
import com.github.fge.jsonschema.processors.validation.ValidationChain;
1211
import com.github.fge.jsonschema.processors.validation.ValidationProcessor;
1312
import com.github.fge.jsonschema.report.ConsoleProcessingReport;
1413
import com.github.fge.jsonschema.report.ProcessingReport;
1514
import com.github.fge.jsonschema.tree.JsonTree;
15+
import com.github.fge.jsonschema.tree.SchemaTree;
1616
import com.github.fge.jsonschema.tree.SimpleJsonTree;
17+
import com.github.fge.jsonschema.util.ValueHolder;
1718

1819
public final class JJSchemaValidator
1920
{
@@ -37,7 +38,7 @@ public void validate(final Class<?> c, final JsonNode instance)
3738
{
3839
final ProcessingReport report = new ConsoleProcessingReport();
3940
final ClassHolder classHolder = new ClassHolder(c);
40-
final SchemaHolder schemaHolder
41+
final ValueHolder<SchemaTree> schemaHolder
4142
= classToSchema.process(report, classHolder);
4243
final JsonTree tree = new SimpleJsonTree(instance);
4344
final FullData fullData = new FullData(schemaHolder.getValue(),

src/main/java/com/github/fge/jsonschema2avro/AvroWriterProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.github.fge.jsonschema.exceptions.ProcessingException;
44
import com.github.fge.jsonschema.processing.Processor;
55
import com.github.fge.jsonschema.processing.ProcessorSelector;
6-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
76
import com.github.fge.jsonschema.report.ProcessingReport;
7+
import com.github.fge.jsonschema.tree.SchemaTree;
88
import com.github.fge.jsonschema.util.ValueHolder;
99
import com.github.fge.jsonschema2avro.writers.ArrayWriter;
1010
import com.github.fge.jsonschema2avro.writers.EnumWriter;
@@ -18,7 +18,7 @@
1818
import static com.github.fge.jsonschema2avro.predicates.AvroPredicates.*;
1919

2020
public final class AvroWriterProcessor
21-
implements Processor<SchemaHolder, ValueHolder<Schema>>
21+
implements Processor<ValueHolder<SchemaTree>, ValueHolder<Schema>>
2222
{
2323
private final Processor<AvroPayload, ValueHolder<Schema>> processor;
2424

@@ -37,7 +37,7 @@ public AvroWriterProcessor()
3737

3838
@Override
3939
public ValueHolder<Schema> process(final ProcessingReport report,
40-
final SchemaHolder input)
40+
final ValueHolder<SchemaTree> input)
4141
throws ProcessingException
4242
{
4343
final AvroPayload payload = new AvroPayload(input.getValue(), this);

src/main/java/com/github/fge/jsonschema2avro/writers/ArrayWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.github.fge.jsonschema.exceptions.ProcessingException;
55
import com.github.fge.jsonschema.jsonpointer.JsonPointer;
6-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
76
import com.github.fge.jsonschema.report.ProcessingReport;
87
import com.github.fge.jsonschema.tree.SchemaTree;
8+
import com.github.fge.jsonschema.util.ValueHolder;
99
import com.github.fge.jsonschema2avro.AvroWriterProcessor;
1010
import org.apache.avro.Schema;
1111

@@ -33,7 +33,8 @@ protected Schema generate(final AvroWriterProcessor writer,
3333
: JsonPointer.of("additionalItems");
3434

3535
final SchemaTree subTree = tree.append(ptr);
36-
final SchemaHolder input = new SchemaHolder(subTree);
36+
final ValueHolder<SchemaTree> input
37+
= ValueHolder.hold("schema", subTree);
3738
final Schema itemsSchema = writer.process(report, input).getValue();
3839
return Schema.createArray(itemsSchema);
3940
}

src/main/java/com/github/fge/jsonschema2avro/writers/MapWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import com.github.fge.jsonschema.exceptions.ProcessingException;
44
import com.github.fge.jsonschema.jsonpointer.JsonPointer;
5-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
65
import com.github.fge.jsonschema.report.ProcessingReport;
76
import com.github.fge.jsonschema.tree.SchemaTree;
7+
import com.github.fge.jsonschema.util.ValueHolder;
88
import com.github.fge.jsonschema2avro.AvroWriterProcessor;
99
import org.apache.avro.Schema;
1010

@@ -30,7 +30,8 @@ protected Schema generate(final AvroWriterProcessor writer,
3030
final ProcessingReport report, final SchemaTree tree)
3131
throws ProcessingException
3232
{
33-
final SchemaHolder input = new SchemaHolder(tree.append(POINTER));
33+
final ValueHolder<SchemaTree> input
34+
= ValueHolder.hold("schema", tree.append(POINTER));
3435
final Schema valueSchema = writer.process(report, input).getValue();
3536
return Schema.createMap(valueSchema);
3637
}

src/main/java/com/github/fge/jsonschema2avro/writers/RecordWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import com.github.fge.jsonschema.exceptions.ProcessingException;
44
import com.github.fge.jsonschema.jsonpointer.JsonPointer;
5-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
65
import com.github.fge.jsonschema.report.ProcessingReport;
76
import com.github.fge.jsonschema.tree.SchemaTree;
7+
import com.github.fge.jsonschema.util.ValueHolder;
88
import com.github.fge.jsonschema2avro.AvroWriterProcessor;
99
import com.google.common.collect.Lists;
1010
import org.apache.avro.Schema;
@@ -33,12 +33,12 @@ protected Schema generate(final AvroWriterProcessor writer,
3333
final List<Schema.Field> fields = Lists.newArrayList();
3434

3535
JsonPointer ptr;
36-
SchemaHolder holder;
36+
ValueHolder<SchemaTree> holder;
3737
Schema fieldSchema;
3838

3939
for (final String name: list) {
4040
ptr = JsonPointer.of("properties", name);
41-
holder = new SchemaHolder(tree.append(ptr));
41+
holder = ValueHolder.hold("schema", tree.append(ptr));
4242
fieldSchema = writer.process(report, holder).getValue();
4343
fields.add(new Schema.Field(name, fieldSchema, null, null));
4444
}

src/main/java/com/github/fge/jsonschema2avro/writers/SimpleUnionWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.github.fge.jsonschema.exceptions.ProcessingException;
55
import com.github.fge.jsonschema.jsonpointer.JsonPointer;
6-
import com.github.fge.jsonschema.processors.data.SchemaHolder;
76
import com.github.fge.jsonschema.report.ProcessingReport;
87
import com.github.fge.jsonschema.tree.SchemaTree;
8+
import com.github.fge.jsonschema.util.ValueHolder;
99
import com.github.fge.jsonschema2avro.AvroWriterProcessor;
1010
import com.google.common.collect.Lists;
1111
import org.apache.avro.Schema;
@@ -36,14 +36,14 @@ protected Schema generate(final AvroWriterProcessor writer,
3636
final int size = node.get(keyword).size();
3737

3838
JsonPointer ptr;
39-
SchemaHolder holder;
39+
ValueHolder<SchemaTree> holder;
4040
Schema subSchema;
4141

4242
final List<Schema> schemas = Lists.newArrayList();
4343

4444
for (int index = 0; index < size; index++) {
4545
ptr = JsonPointer.of(keyword, index);
46-
holder = new SchemaHolder(tree.append(ptr));
46+
holder = ValueHolder.hold("schema", tree.append(ptr));
4747
subSchema = writer.process(report, holder).getValue();
4848
if (subSchema.getType() == Schema.Type.UNION)
4949
throw new ProcessingException("union within union is illegal");

0 commit comments

Comments
 (0)