rest-guide
rest-guide copied to clipboard
Required properties should be explicitly defined
I often find that the names of properties used in the "required" array haven't been kept in sync with their defined names.
For example:
type: object
properties:
nameNew:
type: string
required: [nameOld]
To avoid this, we could define a rule that required properties MUST be explicitly listed in the object's properties (or in a referenced schema within an allOf or the like).
Strictly, according to JSON Schema, specifying the property is not required; it would be a required property then without content restriction. It is still possible to list it then in the object's properties without a type.
WG is okay to add this new rule, I'll work out a PR.