Skip to content

Combining unevaluatedProperties and ref: # #375

Answered by jdesrosiers
bquinn asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is "additionalProperties": false at the top level. Once you do this, you can no longer add properties using schema composition. We sometimes call this a "closed" schema. The way around this is to define your base schema as a definition ($defs) allowing additional/unevaluated properties and then using schema composition at the top level to "close" the schema with unevaluatedProperties.

{
  "$ref": "#/$defs/base",
  "unevaluatedProperties": false,

  "$defs": {
    "base": { ... }
  }
}

Now, the top level can be "closed" while still having an "open" schema available at #/$defs/base that can be extended.

{
  "$ref": "#/$defs/base",
  "properties": {
    "newProp": { "type": "string"

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bquinn
Comment options

@jdesrosiers
Comment options

Answer selected by bquinn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants