open-feature / flagd

A feature flag daemon with a Unix philosophy
https://openfeature.dev
Apache License 2.0
569 stars 67 forks source link

[BUG] Wrong $defs keyword used in JSON schemas #1309

Closed dt-rendstrasser closed 6 months ago

dt-rendstrasser commented 6 months ago

Observed behavior

docs/schema/v0/flags.json and docs/schema/v0/targeting.json use the $defs keyword.

Both JSON schemas use version draft-07 based on the $schema setting.

A quick look at Google shows that the $defs keyword is not part of the draft-07 version. Back then, it was named definitions. E.g., see https://opis.io/json-schema/2.x/definitions.html.

Some json-schema-validators like com.networknt.json-schema-validator write warning logs by default if unknown keywords are encountered. This is exactly what happens in this case with this validator:

c.n.schema.UnknownKeywordFactory         : Unknown keyword $defs - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword or if it should generate annotations AnnotationKeyword

Expected Behavior

Would it be possible to use definitions instead of $defs for as long as the JSON schema version is draft-07? Affected JSON schemas:

Steps to reproduce

No response

beeme1mr commented 6 months ago

Thanks for bringing this up, @dt-rendstrasser. Here's a direct link to the spec that confirms that definitions is still valid in newer versions of the spec but $defs has superseded it.

toddbaert commented 6 months ago

I will confirm and implement this and if all works as expected I will release a fix. Standby.

toddbaert commented 6 months ago

Pulling this into the flagd provider for Java: https://github.com/open-feature/java-sdk-contrib/pull/789