Class: NewDemoApiClient::ValidationError
- Inherits:
-
Object
- Object
- NewDemoApiClient::ValidationError
- Defined in:
- lib/test_sdk/types/validation_error.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #loc ⇒ Array<NewDemoApiClient::ValidationErrorLocItem> readonly
- #msg ⇒ String readonly
- #type ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::ValidationError
Deserialize a JSON object to an instance of ValidationError.
-
.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(loc:, msg:, type:, additional_properties: nil) ⇒ NewDemoApiClient::ValidationError constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ValidationError to a JSON object.
Constructor Details
#initialize(loc:, msg:, type:, additional_properties: nil) ⇒ NewDemoApiClient::ValidationError
28 29 30 31 32 33 34 |
# File 'lib/test_sdk/types/validation_error.rb', line 28 def initialize(loc:, msg:, type:, additional_properties: nil) @loc = loc @msg = msg @type = type @additional_properties = additional_properties @_field_set = { "loc": loc, "msg": msg, "type": type } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/test_sdk/types/validation_error.rb', line 16 def additional_properties @additional_properties end |
#loc ⇒ Array<NewDemoApiClient::ValidationErrorLocItem> (readonly)
10 11 12 |
# File 'lib/test_sdk/types/validation_error.rb', line 10 def loc @loc end |
#msg ⇒ String (readonly)
12 13 14 |
# File 'lib/test_sdk/types/validation_error.rb', line 12 def msg @msg end |
#type ⇒ String (readonly)
14 15 16 |
# File 'lib/test_sdk/types/validation_error.rb', line 14 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ NewDemoApiClient::ValidationError
Deserialize a JSON object to an instance of ValidationError
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/test_sdk/types/validation_error.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) loc = parsed_json["loc"]&.map do |item| item = item.to_json NewDemoApiClient::ValidationErrorLocItem.from_json(json_object: item) end msg = parsed_json["msg"] type = parsed_json["type"] new( loc: loc, msg: msg, type: type, 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.
70 71 72 73 74 |
# File 'lib/test_sdk/types/validation_error.rb', line 70 def self.validate_raw(obj:) obj.loc.is_a?(Array) != false || raise("Passed value for field obj.loc is not the expected type, validation failed.") obj.msg.is_a?(String) != false || raise("Passed value for field obj.msg is not the expected type, validation failed.") obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ValidationError to a JSON object
60 61 62 |
# File 'lib/test_sdk/types/validation_error.rb', line 60 def to_json(*_args) @_field_set&.to_json end |