Skip to content

Extending properties #321

Closed
Closed
@epoberezkin

Description

@epoberezkin

Allow adding property schemas in referenced schemas.

That's one more solution to solving additionalProperties problem, somewhat similar to $params discussed with @handrews (#322). Also can be seen as implementation of a more generic #313.

Example:

Schema 2 explicitly allows extension (maybe it should be allowed by default and to prohibit extension you have to explicitly use "$extend": false (to prohibit extension of any keyword) or "$extend": {"properties": false} (to prohibit extension of properties only).

Schema 1 references schema 2 and extends properties.

{
  "$id": "schema1",
  "allOf": [{
    "$ref": "schema2",
    "$extend": {
      "properties": {
        "bar": {"type": "string"}
      }
    }
  }]
}
  "$id": "schema2",
  "$extend": {"properties": true},
  "properties": {
    "foo": {"type": "string"}
  },
  "additionalProperties": false
}

Probably other keywords can be extended in a similar way: patternProperties, required, dependencies, enum, type (with array syntax? more for consistency), items (with array syntax), anyOf, etc. - essentially any keyword that takes a structured value but not a schema.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions