From dc89944058be4bd702a1edd1ca9aebef7a832349 Mon Sep 17 00:00:00 2001 From: Muhammad Nawzad Date: Fri, 17 Nov 2023 15:59:52 +0300 Subject: [PATCH] Fixes typos and ensures type safety --- lib/schemable/attribute_schema_generator.rb | 4 ++-- lib/schemable/configuration.rb | 4 ++-- lib/schemable/definition.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/schemable/attribute_schema_generator.rb b/lib/schemable/attribute_schema_generator.rb index 33eca63..27a149d 100644 --- a/lib/schemable/attribute_schema_generator.rb +++ b/lib/schemable/attribute_schema_generator.rb @@ -62,7 +62,7 @@ module Schemable attribute_hash = @model.fields[attribute.to_s] # Check if this attribute has a custom JSON Schema definition - return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute) + return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute.to_sym) return @model_definition.additional_response_attributes[attribute] if @model_definition.additional_response_attributes.keys.include?(attribute) # Check if this is an array attribute @@ -81,7 +81,7 @@ module Schemable attribute_hash = @model.columns_hash[attribute.to_s] # Check if this attribute has a custom JSON Schema definition - return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute) + return @model_definition.array_types[attribute] if @model_definition.array_types.keys.include?(attribute.to_sym) return @model_definition.additional_response_attributes[attribute] if @model_definition.additional_response_attributes.keys.include?(attribute) # Check if this is an array attribute diff --git a/lib/schemable/configuration.rb b/lib/schemable/configuration.rb index f90be88..df06993 100644 --- a/lib/schemable/configuration.rb +++ b/lib/schemable/configuration.rb @@ -17,7 +17,7 @@ module Schemable :enum_prefix_for_simple_enum, :enum_suffix_for_simple_enum, :infer_attributes_from_custom_method, - :infer_attributes_from_jsonapi_serializable, + :infer_attributes_from_jsonapi_serializable ) # Initializes a new Configuration instance with default values. @@ -46,7 +46,7 @@ module Schemable # @param type_name [Symbol, String] The name of the type. # @return [Hash] The type mapper for the given type name. def type_mapper(type_name) - return @custom_type_mappers[type_name] if @custom_type_mappers.key?(type_name) + return @custom_type_mappers[type_name] if @custom_type_mappers.key?(type_name.to_sym) { text: { type: :string }, diff --git a/lib/schemable/definition.rb b/lib/schemable/definition.rb index 41c8844..ad159ee 100644 --- a/lib/schemable/definition.rb +++ b/lib/schemable/definition.rb @@ -3,7 +3,7 @@ module Schemable # It includes methods for handling attributes, relationships, and various request and response attributes. # The definition class is meant to be inherited by a class that represents a model. # This class should be configured to match the model's attributes and relationships. - # The defaullt configuration is set in this class, but can be overridden in the model's definition class. + # The default configuration is set in this class, but can be overridden in the model's definition class. # # @see Schemable class Definition