Class: Kabk::SchemaRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/kabk/schema_renderer.rb

Overview

Renders the JSON Schema manifest for the protocol v1.6.0

Instance Method Summary collapse

Constructor Details

#initialize(system_config: nil, validation_schema_url: nil) ⇒ SchemaRenderer

Initializes the schema renderer

Parameters:

  • system_config (Hash, nil) (defaults to: nil)

    Optional system config overrides (e.g., title, logo_url, endpoints)

  • validation_schema_url (String, nil) (defaults to: nil)

    Custom URL for the validation schema



12
13
14
15
# File 'lib/kabk/schema_renderer.rb', line 12

def initialize(system_config: nil, validation_schema_url: nil)
  @system_config = system_config ? default_system_config.merge(system_config) : default_system_config
  @validation_schema_url = validation_schema_url || "/schemas/admin-protocol-1.6.0.json"
end

Instance Method Details

#renderObject



17
18
19
20
21
22
23
24
# File 'lib/kabk/schema_renderer.rb', line 17

def render
  {
    "$schema_version": "1.6.0",
    system: @system_config,
    validation_schema_url: @validation_schema_url,
    resources: Registry.instance.all.map(&:to_h)
  }
end