Class: CandidApiClient::CustomSchemas::V1::Types::Schema
- Inherits:
-
Object
- Object
- CandidApiClient::CustomSchemas::V1::Types::Schema
- Defined in:
- lib/candidhealth/custom_schemas/v_1/types/schema.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #description ⇒ String readonly
- #fields ⇒ Array<CandidApiClient::CustomSchemas::V1::Types::SchemaField> readonly
- #id ⇒ String readonly
- #name ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema
Deserialize a JSON object to an instance of Schema.
-
.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(id:, name:, fields:, description: OMIT, additional_properties: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Schema to a JSON object.
Constructor Details
#initialize(id:, name:, fields:, description: OMIT, additional_properties: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 34 def initialize(id:, name:, fields:, description: OMIT, additional_properties: nil) @id = id @name = name @description = description if description != OMIT @fields = fields @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "description": description, "fields": fields }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 21 def additional_properties @additional_properties end |
#description ⇒ String (readonly)
17 18 19 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 17 def description @description end |
#fields ⇒ Array<CandidApiClient::CustomSchemas::V1::Types::SchemaField> (readonly)
19 20 21 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 19 def fields @fields end |
#id ⇒ String (readonly)
13 14 15 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 13 def id @id end |
#name ⇒ String (readonly)
15 16 17 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 15 def name @name end |
Class Method Details
.from_json(json_object:) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema
Deserialize a JSON object to an instance of Schema
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct["id"] name = struct["name"] description = struct["description"] fields = parsed_json["fields"]&.map do |item| item = item.to_json CandidApiClient::CustomSchemas::V1::Types::SchemaField.from_json(json_object: item) end new( id: id, name: name, description: description, fields: fields, 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.
81 82 83 84 85 86 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 81 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.fields.is_a?(Array) != false || raise("Passed value for field obj.fields is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Schema to a JSON object
71 72 73 |
# File 'lib/candidhealth/custom_schemas/v_1/types/schema.rb', line 71 def to_json(*_args) @_field_set&.to_json end |