johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Tripodi (JIRA)" <>
Subject [jira] [Commented] (JOHNZON-191) [Schema] "patternProperties" does not correctly handle related property type
Date Fri, 05 Oct 2018 21:47:01 GMT


Simone Tripodi commented on JOHNZON-191:

Thank you so much [~romain.manni-bucau] for the prompt reply, very appreciated! :)

I forked the repo already and started having a look at the source code, to see if I am able
to provide any patch, I'll try to have a deeper look at it during the weekend.

IIUC, jsonschema Regex _should_ support , at least according to

bq schema authors SHOULD limit themselves to the following regular expression tokens:
the beginning-of-input ("^") and end-of-input ("$") anchors;

this shouldn't be a problema anyway, the more interesting part is we are able to validate
input data against the schema :)

many thanks in advance for your help and keep up the good work!

> [Schema] "patternProperties" does not correctly handle related property type
> ----------------------------------------------------------------------------
>                 Key: JOHNZON-191
>                 URL:
>             Project: Johnzon
>          Issue Type: Bug
>    Affects Versions: 1.1.10
>            Reporter: Simone Tripodi
>            Priority: Major
>             Fix For: 1.1.11
> 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
> 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:
> {noformat}
> {
>   "id":"test/artifacts-extension/1.0.0",
>   "my-extension1:TEXT|false":{}
> }
> {noformat}
> an error is detected since type is invalid, _string_ or _array_ is expected but  but
got _object_, tested on, but {{JsonSchemaValidator}}
passes all verifications.
> I noticed that this behaviour is even present in Johnzon tests , i.e.[|]
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:
> {noformat}
>     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
>             throw new UncheckedIOException(ioe);
>         } finally {
>             if (reader != null) {
>                 reader.close();
>             }
>             if (factory != null) {
>                 factory.close();
>             }
>         }
>     }
> {noformat}
> Could you kindly help us? Many thanks in advance!

This message was sent by Atlassian JIRA

View raw message