iptc / newsinjson

Home of the IPTC ninjs standard
https://iptc.org/standards/ninjs/
Other
34 stars 9 forks source link

additionalproperties issue #143

Closed jolla56 closed 1 year ago

jolla56 commented 1 year ago

We might have an issue with associations and additional properties = false. When I created a sample from a ver 1.3 ninjs it still accepted the description_text thing but should really have complained because in 2.x it should be descriptions: [array].

My quick googling gave the answer that it is hard to combine anyOf with additionalProperties=false.

jolla56 commented 1 year ago

The issue seemed solved in json schema 2019-09

jolla56 commented 1 year ago

Alternative proposal in earlier schema versions: { "anyOf": [ { "type": "object", "properties": { "a": { "type": "string" } } }, { "type": "object", "properties": { "x": { "type": "string" } } } ], "properties": { "a": true, "x": true }, "additionalProperties": false }

jolla56 commented 1 year ago

But I suspect this implies listing all the properties in the bottom part.

jolla56 commented 1 year ago

https://stackoverflow.com/questions/73843324/how-to-merge-two-json-schema-without-additional-properties

jolla56 commented 1 year ago

Another alternative would be to add name to the core schema, but I don't like that either. We have talked about moving to a newer schema version, so this might be the reason to do so.

jolla56 commented 1 year ago

And now when I test I can't repeat the problem.

jolla56 commented 1 year ago

Brendan could replicate the bug in unit tests. And when working more with oXygen I can verify that the problem is there. oXygen seem to demand that you have a validated copy before testing. Because if it is marked as wrong it seems to stay that way even if you switch schema to validate against.

bquinn commented 1 year ago

@jolla56 has tried to get this working using unevaluatedProperties:false which is a feature of JSON SChema 2019 and onwards. But it doesn't seem to be working - hopefully with some advice we can get it going.

After looking at this at today's meeting, we concluded that we have three alternatives, and this is our preferred order of solving the problem:

  1. Try to get the JSON Schema approach using unevaluatedProperties:false to work
  2. Add the "name" property to the main schema so we can just do $ref: # in the associations definition
  3. Change the associations definition so we have "name": "...", "newsitem": {} - but this is a breaking change so would require bumping the version number to 3.0.
bquinn commented 1 year ago

Update: after the meeting, @jeremybrooks solved the JSON Schema problem so we can go with solution 1 above!