Class: Intrinsic::ErrorSchemaError
- Inherits:
-
Object
- Object
- Intrinsic::ErrorSchemaError
- Defined in:
- lib/intrinsic/types/error_schema_error.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ ErrorSchemaError
Deserialize a JSON object to an instance of ErrorSchemaError.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(type:, message:, code:, param: nil, additional_properties: nil) ⇒ ErrorSchemaError constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ErrorSchemaError to a JSON object.
Constructor Details
#initialize(type:, message:, code:, param: nil, additional_properties: nil) ⇒ ErrorSchemaError
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 17 def initialize(type:, message:, code:, param: nil, additional_properties: nil) # @type [ERROR_SCHEMA_ERROR_TYPE] @type = type # @type [String] @message = # @type [ERROR_SCHEMA_ERROR_CODE] @code = code # @type [String] @param = param # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 9 def additional_properties @additional_properties end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 9 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 9 def @message end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
9 10 11 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 9 def param @param end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 9 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ ErrorSchemaError
Deserialize a JSON object to an instance of ErrorSchemaError
34 35 36 37 38 39 40 41 42 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 34 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) type = ERROR_SCHEMA_ERROR_TYPE.key(parsed_json["type"]) || parsed_json["type"] = struct. code = ERROR_SCHEMA_ERROR_CODE.key(parsed_json["code"]) || parsed_json["code"] param = struct.param new(type: type, message: , code: code, param: param, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
60 61 62 63 64 65 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 60 def self.validate_raw(obj:) obj.type.is_a?(ERROR_SCHEMA_ERROR_TYPE) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj..is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") obj.code.is_a?(ERROR_SCHEMA_ERROR_CODE) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") obj.param&.is_a?(String) != false || raise("Passed value for field obj.param is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of ErrorSchemaError to a JSON object
47 48 49 50 51 52 53 54 |
# File 'lib/intrinsic/types/error_schema_error.rb', line 47 def to_json(*_args) { "type": ERROR_SCHEMA_ERROR_TYPE[@type] || @type, "message": @message, "code": ERROR_SCHEMA_ERROR_CODE[@code] || @code, "param": @param }.to_json end |