Module: EasyTalk::Schema

Defined in:
lib/easy_talk/schema.rb

Overview

A lightweight module for schema generation without ActiveModel validations.

Use this module when you need JSON Schema generation without the overhead of ActiveModel validations. This is ideal for:

  • API documentation and OpenAPI spec generation
  • Schema-first design where validation happens elsewhere
  • High-performance scenarios where validation overhead is unwanted
  • Generating schemas for external systems

Unlike EasyTalk::Model, this module does NOT include ActiveModel::API or ActiveModel::Validations, so instances will not respond to valid? or have validation errors.

Examples:

Basic usage

class ApiContract
  include EasyTalk::Schema

  define_schema do
    title 'API Contract'
    property :name, String, min_length: 2
    property :age, Integer, minimum: 0
  end
end

ApiContract.json_schema  # => { "type" => "object", ... }
contract = ApiContract.new(name: 'Test', age: 25)
contract.name # => 'Test'
contract.valid? # => NoMethodError (no ActiveModel)

See Also:

Defined Under Namespace

Modules: ClassMethods, InstanceMethods