Class: NewDemoApiClient::ValidationError

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/validation_error.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loc:, msg:, type:, additional_properties: nil) ⇒ NewDemoApiClient::ValidationError

Parameters:

  • loc (Array<NewDemoApiClient::ValidationErrorLocItem>)
  • msg (String)
  • type (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#locArray<NewDemoApiClient::ValidationErrorLocItem> (readonly)



10
11
12
# File 'lib/test_sdk/types/validation_error.rb', line 10

def loc
  @loc
end

#msgString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/test_sdk/types/validation_error.rb', line 12

def msg
  @msg
end

#typeString (readonly)

Returns:

  • (String)


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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


60
61
62
# File 'lib/test_sdk/types/validation_error.rb', line 60

def to_json(*_args)
  @_field_set&.to_json
end