json-schema-spec icon indicating copy to clipboard operation
json-schema-spec copied to clipboard

description of readOnly is ambiguous and refers to property when it should be instance

Open DavidBiesack opened this issue 2 years ago • 6 comments

The 2020-12 validation spec reads

attempts by an application to modify the value of this property This should be changed to attempts by an application to modify the value of this instance since readOnly can apply to an object or array or primitive schema, not just properties on an object.

(I'd also like more clarity here when readOnly: true appears on a container instance - i.e. explicitly state whether this constraint does or does not extend to containers within the container. I believe it is local and only applies to the container)

DavidBiesack avatar Jan 25 '23 14:01 DavidBiesack

(I haven't read the description here carefully to see if I agree, but this belongs on the spec repo regardless, so going to move this there).

Julian avatar Apr 26 '23 21:04 Julian

Since readOnly is merely an annotation, JSON Schema is intentionally non-prescriptive on what its meaning is. That is for the consuming application to decide.

If two applications are sharing a schema that contains readOnly, then they need to agree on its usage.

gregsdennis avatar Apr 26 '23 21:04 gregsdennis

@DavidBiesack I agree that this wording is awkward at best. The current wording makes it sound like the keyword is only allowed on schemas that describe properties, which is not true. I'd approve a PR with the proposed change.

(I'd also like more clarity here when readOnly: true appears on a container instance - i.e. explicitly state whether this constraint does or does not extend to containers within the container. I believe it is local and only applies to the container)

I've always thought of it as extending to the entire value. For example, you could put it at the root of your schema to indicate that the entire document is read only.

jdesrosiers avatar Apr 26 '23 23:04 jdesrosiers

PR submitted

DavidBiesack avatar Jun 19 '24 01:06 DavidBiesack

The PR build failed though I don't know what that rule is, what it means, or how to correct it.

DavidBiesack avatar Jun 19 '24 01:06 DavidBiesack

We have a two-week minimum open time for spec changes. That GH Action just keeps us from violating it.

gregsdennis avatar Jun 19 '24 01:06 gregsdennis