danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
699 stars 158 forks source link

Remove fragment from URI #423

Closed Bordovsky closed 1 year ago

Bordovsky commented 1 year ago

Hi,

I am trying to use jsoncons for json document validation, and I stumbled upon an odd behaviour around URI for schema.

It looks like jsoncons/jsonschema requires the schema URI to contain a fragment.

When browsing jsonschema examples the schema URI is provided with an empty fragment. It is legal for URI to contain an empty fragment, but it is a bit unusual (and semantically redundant).

As far as I was able to find at json-schema.org it seems that the URI should/could be provided without any fragment, but current validation does not accept such URI.

I am wondering if the pound sign (#) is necessary for some reason, but if not, I would suggest to remove it from the schema_version validation.

danielaparker commented 1 year ago

I am wondering if the pound sign (#) is necessary for some reason, but if not, I would suggest to remove it from the schema_version validation.

As far as I can tell, the identifier for Draft 7 is always given as "http://json-schema.org/draft-07/schema#", as attested to by a google search on "json-schema.org/draft-07/schema". Earlier versions followed a similar convention, later versions starting with 2019-09 dropped the # and substituted https. See https://json-schema.org/understanding-json-schema/UnderstandingJSONSchema.pdf

Bordovsky commented 1 year ago

Thanks for the reference. I should have searched more thoughtfully and not trust our old schemas.

You are right and I have even found identifiers for each draft and the # is listed there.

I am closing this now.