Skip to content

Add schema composition keywords #37

Description

@crmne

Goal

Add support for the remaining JSON Schema composition keywords:

  • allOf
  • not

The gem already supports anyOf and oneOf.

Proposed DSL for allOf

all_of :payload do
  object { string :name }
  object { integer :age }
end

This means the value must satisfy all provided schemas.

Proposed DSL for not

not is a Ruby keyword, so avoid using it directly.

none_of :status do
  string enum: ["forbidden"]
end

This means status must not match the provided schema.

If multiple schemas are given, none_of can emit:

{
  "not": {
    "anyOf": [...]
  }
}

Acceptance criteria

  • API is consistent with existing any_of and one_of.
  • Behavior tests cover pass and fail cases.
  • Generated schemas validate against Draft 2020-12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions