Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.1.10
-
None
-
None
Description
In Apache Sling we have been developing a draft-07 compliant schema to define Sling Feature files, which are in JSON format, and of course Johnzon is the de-facto standard choice to work with JSON structures.
If you want to have a look at the initial draft, have a look at https://gist.github.com/simonetripodi/c69d2ffebdbd2c4b1355df60568f1ab5
So, in our Feature we have so called extensions where users can define a custom data set, extensions keys are defined by patternProperties which related type, I noticed, are not correctly handled by the JsonSchemaValidator: the expected behaviour is that for an input like the one below:
{ "id":"test/artifacts-extension/1.0.0", "my-extension1:TEXT|false":{} }
an error is detected since type is invalid, string or array is expected but but got object, tested on https://www.jsonschemavalidator.net/, but JsonSchemaValidator passes all verifications.
I noticed that this behaviour is even present in Johnzon tests , i.e.JsonSchemaValidatorTest.java#L572 where number type is expected for keys identified by [0-9]+, but it succeeds for string type as well.
I think it is a bug, unless I misconfigured something, follows below a snippet of code where the validator is created:
private final JsonSchemaValidator validator; private FeatureSchemaValidatorProvider() { JsonReader reader = null; JsonSchemaValidatorFactory factory = null; try (InputStream schemaInput = FeatureJSONReader.class.getResourceAsStream("/META-INF/feature/Feature-1.0.0.schema.json")) { reader = Json.createReader(schemaInput); JsonObject schema = reader.readObject(); factory = new JsonSchemaValidatorFactory(); factory.setRegexFactory(JavaRegex::new); validator = factory.newInstance(schema); } catch (IOException ioe) { // should not happen, /META-INF/feature/Feature-1.0.0.schema.json is in the classpath throw new UncheckedIOException(ioe); } finally { if (reader != null) { reader.close(); } if (factory != null) { factory.close(); } } }
Could you kindly help us? Many thanks in advance!