Skip to content

Add content annotation keywords #41

Description

@crmne

Goal

Add support for Draft 2020-12 content annotation keywords:

  • contentEncoding
  • contentMediaType
  • contentSchema

These describe strings that contain encoded content.

Example JSON Schema:

{
  "type": "string",
  "contentEncoding": "base64",
  "contentMediaType": "application/json",
  "contentSchema": { "type": "object" }
}

Proposed DSL

Simple content annotations can be keyword arguments:

string :payload,
  content_encoding: "base64",
  content_media_type: "application/json"

With contentSchema:

string :payload, content_encoding: "base64", content_media_type: "application/json" do
  content_schema do
    object do
      string :name
    end
  end
end

This means payload is a base64-encoded JSON document whose decoded content should match the nested schema.

DSL direction

contentEncoding and contentMediaType are usually compact enough as keyword arguments, but contentSchema is block-heavy and should follow the same current-node block conventions as #40.

The nested content_schema body should support normal schema DSL features, including metadata annotations once #40 is implemented:

string :payload, content_encoding: "base64", content_media_type: "application/json" do
  content_schema do
    object do
      title "Payload"
      description "Decoded JSON payload"

      string :name
    end
  end
end

Acceptance criteria

  • Correct keyword output.
  • contentSchema supports nested schema DSL.
  • Nested content_schema blocks are compatible with the current-node annotation/modifier design from Add metadata annotation keywords #40.
  • 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