Sets configuration by default

This commit is contained in:
Muhammad Nawzad 2023-11-10 19:50:26 +03:00
parent b480c82361
commit 0118d57cb7
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2
2 changed files with 4 additions and 4 deletions

View File

@ -2,10 +2,10 @@ module Schemable
class AttributeSchemaGenerator class AttributeSchemaGenerator
attr_accessor :model_definition, :configuration, :model, :schema_modifier, :response attr_accessor :model_definition, :configuration, :model, :schema_modifier, :response
def initialize(model_definition, configuration) def initialize(model_definition)
@model_definition = model_definition @model_definition = model_definition
@model = model_definition.model @model = model_definition.model
@configuration = configuration @configuration = Schemable.configuration
@schema_modifier = SchemaModifier.new @schema_modifier = SchemaModifier.new
@response = nil @response = nil
end end
@ -14,7 +14,7 @@ module Schemable
def generate_attributes_schema def generate_attributes_schema
schema = { schema = {
type: :object, type: :object,
properties: @model_definition.attributes&.index_with do |attr| properties: @model_definition.attributes.index_with do |attr|
generate_attribute_schema(attr) generate_attribute_schema(attr)
end end
} }

View File

@ -6,7 +6,7 @@ module Schemable
attr_accessor response: Hash[Symbol, any]? attr_accessor response: Hash[Symbol, any]?
attr_accessor schema_modifier: SchemaModifier attr_accessor schema_modifier: SchemaModifier
def initialize: (Definition, Configuration) -> void def initialize: (Definition) -> void
def generate_attributes_schema: -> (Hash[Symbol, any] | Array[any]) def generate_attributes_schema: -> (Hash[Symbol, any] | Array[any])
def generate_attribute_schema: (Symbol) -> Hash[Symbol, any] def generate_attribute_schema: (Symbol) -> Hash[Symbol, any]
end end