Module: EasyTalk::SchemaMethods
- Included in:
- Model::ClassMethods, EasyTalk::Schema::ClassMethods
- Defined in:
- lib/easy_talk/schema_methods.rb
Overview
Note:
Classes including this module must define:
name- The class name (used in ref_template)schema- The built schema hash (used in json_schema)@schema_definition- Instance variable with schema metadata
Shared methods for JSON Schema generation.
This module provides common functionality for building JSON schemas, including $schema and $id resolution. It is included in both EasyTalk::Model and EasyTalk::Schema to avoid code duplication.
Instance Method Summary collapse
-
#json_schema ⇒ Hash
Returns the JSON schema for the model.
-
#ref_template ⇒ String
Returns the reference template for the model.
Instance Method Details
#json_schema ⇒ Hash
Returns the JSON schema for the model. This is the final output that includes the $schema keyword if configured.
27 28 29 |
# File 'lib/easy_talk/schema_methods.rb', line 27 def json_schema @json_schema ||= build_json_schema end |
#ref_template ⇒ String
Returns the reference template for the model.
19 20 21 |
# File 'lib/easy_talk/schema_methods.rb', line 19 def ref_template "#/$defs/#{name}" end |