ragie_ruby_sdk 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c3926c23faa5d9ce5e7ae0ee870939588d76a282287dbc70e42ec40382fcc97
4
- data.tar.gz: 9e38fc9e6238a01a2c4dc24ee74b569d5dc30c99aa5f3fc4a9aa64af604b5edd
3
+ metadata.gz: a3200c561197e12c722ff0bdc97c41feed4fbcdcad95f896416f4c2ecbbccae5
4
+ data.tar.gz: 7cc4f9413ee4f763c51f897f05750cf6c6d89a349439a710f7d8097aa019af79
5
5
  SHA512:
6
- metadata.gz: c046158170e4d345a2285a3126f1d6b182d25d46bdce8bed516aa45b049e504f7c47157a68c084b53fc4510f934260d2aa478c52900a9ba0ed5991200acfc2c3
7
- data.tar.gz: 6626dd14490fccb0418c553d3a82d4c4ba45513ce399f1dc4c978e99286127206c2a34167ae99f3ce95c97fef6cad53d30e92e6cf5a4e8a480b97db99ab9d2d4
6
+ metadata.gz: 4573525c861a74c9436d28d23d121794bb288116f641ccf71c1751be3b905bd86f959bcaa00f91bc99bb3f39efe6c435d3e320ad6c3d0472941820adce106520
7
+ data.tar.gz: 3cd81d8bd3d19c160d7f99732e923e88d2ff20e33245054e4812ba72c5d6ae3054a54502165a36e11ee469b94cf22c419b4b81a63a26945a82d6cb13ca309986
data/README.md CHANGED
@@ -7,7 +7,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
7
7
  This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
8
8
 
9
9
  - API version: 1.0.0
10
- - Package version: 1.0.5
10
+ - Package version: 1.0.6
11
11
  - Generator version: 7.16.0-SNAPSHOT
12
12
  - Build package: org.openapitools.codegen.languages.RubyClientCodegen
13
13
 
@@ -24,16 +24,16 @@ gem build ragie_ruby_sdk.gemspec
24
24
  Then either install the gem locally:
25
25
 
26
26
  ```shell
27
- gem install ./ragie_ruby_sdk-1.0.5.gem
27
+ gem install ./ragie_ruby_sdk-1.0.6.gem
28
28
  ```
29
29
 
30
- (for development, run `gem install --dev ./ragie_ruby_sdk-1.0.5.gem` to install the development dependencies)
30
+ (for development, run `gem install --dev ./ragie_ruby_sdk-1.0.6.gem` to install the development dependencies)
31
31
 
32
32
  or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
33
33
 
34
34
  Finally add this to the Gemfile:
35
35
 
36
- gem 'ragie_ruby_sdk', '~> 1.0.5'
36
+ gem 'ragie_ruby_sdk', '~> 1.0.6'
37
37
 
38
38
  ### Install from Git
39
39
 
@@ -227,7 +227,6 @@ Class | Method | HTTP request | Description
227
227
  - [RagieRubySdk::Link](docs/Link.md)
228
228
  - [RagieRubySdk::ListConnectorSourceTypeInfo](docs/ListConnectorSourceTypeInfo.md)
229
229
  - [RagieRubySdk::MediaModeParam](docs/MediaModeParam.md)
230
- - [RagieRubySdk::MediaType](docs/MediaType.md)
231
230
  - [RagieRubySdk::MetadataValue](docs/MetadataValue.md)
232
231
  - [RagieRubySdk::MetadataValue1](docs/MetadataValue1.md)
233
232
  - [RagieRubySdk::Mode](docs/Mode.md)
@@ -272,7 +271,6 @@ Class | Method | HTTP request | Description
272
271
  - [RagieRubySdk::SharepointSiteData](docs/SharepointSiteData.md)
273
272
  - [RagieRubySdk::SlackData](docs/SlackData.md)
274
273
  - [RagieRubySdk::Source](docs/Source.md)
275
- - [RagieRubySdk::Status](docs/Status.md)
276
274
  - [RagieRubySdk::UpdateDocumentFromUrlParams](docs/UpdateDocumentFromUrlParams.md)
277
275
  - [RagieRubySdk::UpdateDocumentRawParams](docs/UpdateDocumentRawParams.md)
278
276
  - [RagieRubySdk::UpdateInstructionParams](docs/UpdateInstructionParams.md)
@@ -5,7 +5,7 @@
5
5
  | Name | Type | Description | Notes |
6
6
  | ---- | ---- | ----------- | ----- |
7
7
  | **document_id** | **String** | | |
8
- | **status** | [**Status**](Status.md) | | |
8
+ | **status** | **String** | | |
9
9
  | **partition** | **String** | | |
10
10
  | **metadata** | **Hash<String, Object>** | | |
11
11
  | **external_id** | **String** | | |
data/docs/DocumentsApi.md CHANGED
@@ -644,7 +644,7 @@ end
644
644
  api_instance = RagieRubySdk::DocumentsApi.new
645
645
  document_id = '38400000-8cf0-11bd-b23e-10b96e4ef00d' # String | The id of the document.
646
646
  opts = {
647
- media_type: RagieRubySdk::MediaType.new, # MediaType | The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
647
+ media_type: 'text/plain', # String | The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
648
648
  download: true, # Boolean | Whether to return the content as a file download or a raw stream. If set to `true`, the content will be returned as a named file for download.
649
649
  partition: 'partition_example', # String | An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition.
650
650
  range: 'range_example' # String |
@@ -682,7 +682,7 @@ end
682
682
  | Name | Type | Description | Notes |
683
683
  | ---- | ---- | ----------- | ----- |
684
684
  | **document_id** | **String** | The id of the document. | |
685
- | **media_type** | [**MediaType**](.md) | The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type. | [optional] |
685
+ | **media_type** | **String** | The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type. | [optional] |
686
686
  | **download** | **Boolean** | Whether to return the content as a file download or a raw stream. If set to `true`, the content will be returned as a named file for download. | [optional][default to false] |
687
687
  | **partition** | **String** | An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition. | [optional] |
688
688
  | **range** | **String** | | [optional] |
@@ -617,7 +617,7 @@ module RagieRubySdk
617
617
  # Get the content of a document. The `media_type` parameter can be used to request the content in a different format. When requesting as `application/json` additional metadata about the document will be included. If the original document contained content such as images or other non-textual media, this response will include a text description of that media instead of the original file data. Using mime types such as `audio/mpeg` or `video/mp4` will stream the file in a format that can be provided to an audio video player.
618
618
  # @param document_id [String] The id of the document.
619
619
  # @param [Hash] opts the optional parameters
620
- # @option opts [MediaType] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
620
+ # @option opts [String] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
621
621
  # @option opts [Boolean] :download Whether to return the content as a file download or a raw stream. If set to `true`, the content will be returned as a named file for download. (default to false)
622
622
  # @option opts [String] :partition An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition.
623
623
  # @option opts [String] :range
@@ -631,7 +631,7 @@ module RagieRubySdk
631
631
  # Get the content of a document. The `media_type` parameter can be used to request the content in a different format. When requesting as `application/json` additional metadata about the document will be included. If the original document contained content such as images or other non-textual media, this response will include a text description of that media instead of the original file data. Using mime types such as `audio/mpeg` or `video/mp4` will stream the file in a format that can be provided to an audio video player.
632
632
  # @param document_id [String] The id of the document.
633
633
  # @param [Hash] opts the optional parameters
634
- # @option opts [MediaType] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
634
+ # @option opts [String] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
635
635
  # @option opts [Boolean] :download Whether to return the content as a file download or a raw stream. If set to `true`, the content will be returned as a named file for download. (default to false)
636
636
  # @option opts [String] :partition An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition.
637
637
  # @option opts [String] :range
@@ -644,6 +644,10 @@ module RagieRubySdk
644
644
  if @api_client.config.client_side_validation && document_id.nil?
645
645
  fail ArgumentError, "Missing the required parameter 'document_id' when calling DocumentsApi.get_document_content"
646
646
  end
647
+ allowable_values = ["text/plain", "audio/mpeg", "video/mp4", "image/webp", "image/heic", "image/bmp", "image/png", "image/jpeg", "image/tiff", "application/json"]
648
+ if @api_client.config.client_side_validation && opts[:'media_type'] && !allowable_values.include?(opts[:'media_type'])
649
+ fail ArgumentError, "invalid value for \"media_type\", must be one of #{allowable_values}"
650
+ end
647
651
  # resource path
648
652
  local_var_path = '/documents/{document_id}/content'.sub('{' + 'document_id' + '}', CGI.escape(document_id.to_s))
649
653
 
@@ -33,6 +33,28 @@ module RagieRubySdk
33
33
 
34
34
  attr_accessor :error
35
35
 
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
36
58
  # Attribute mapping from ruby-style variable name to JSON key.
37
59
  def self.attribute_map
38
60
  {
@@ -62,7 +84,7 @@ module RagieRubySdk
62
84
  def self.openapi_types
63
85
  {
64
86
  :'document_id' => :'String',
65
- :'status' => :'Status',
87
+ :'status' => :'String',
66
88
  :'partition' => :'String',
67
89
  :'metadata' => :'Hash<String, Object>',
68
90
  :'external_id' => :'String',
@@ -190,6 +212,8 @@ module RagieRubySdk
190
212
  warn '[DEPRECATED] the `valid?` method is obsolete'
191
213
  return false if @document_id.nil?
192
214
  return false if @status.nil?
215
+ status_validator = EnumAttributeValidator.new('String', ["ready", "failed", "indexed", "keyword_indexed"])
216
+ return false unless status_validator.valid?(@status)
193
217
  return false if @partition.nil?
194
218
  return false if @metadata.nil?
195
219
  return false if @name.nil?
@@ -206,13 +230,13 @@ module RagieRubySdk
206
230
  @document_id = document_id
207
231
  end
208
232
 
209
- # Custom attribute writer method with validation
210
- # @param [Object] status Value to be assigned
233
+ # Custom attribute writer method checking allowed values (enum).
234
+ # @param [Object] status Object to be assigned
211
235
  def status=(status)
212
- if status.nil?
213
- fail ArgumentError, 'status cannot be nil'
236
+ validator = EnumAttributeValidator.new('String', ["ready", "failed", "indexed", "keyword_indexed"])
237
+ unless validator.valid?(status)
238
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
214
239
  end
215
-
216
240
  @status = status
217
241
  end
218
242
 
@@ -11,5 +11,5 @@ Generator version: 7.16.0-SNAPSHOT
11
11
  =end
12
12
 
13
13
  module RagieRubySdk
14
- VERSION = '1.0.6'
14
+ VERSION = '1.0.7'
15
15
  end
@@ -101,7 +101,6 @@ require 'ragie_ruby_sdk/models/intercom_data'
101
101
  require 'ragie_ruby_sdk/models/link'
102
102
  require 'ragie_ruby_sdk/models/list_connector_source_type_info'
103
103
  require 'ragie_ruby_sdk/models/media_mode_param'
104
- require 'ragie_ruby_sdk/models/media_type'
105
104
  require 'ragie_ruby_sdk/models/metadata_value'
106
105
  require 'ragie_ruby_sdk/models/metadata_value1'
107
106
  require 'ragie_ruby_sdk/models/mode'
@@ -146,7 +145,6 @@ require 'ragie_ruby_sdk/models/sharepoint_file_data'
146
145
  require 'ragie_ruby_sdk/models/sharepoint_site_data'
147
146
  require 'ragie_ruby_sdk/models/slack_data'
148
147
  require 'ragie_ruby_sdk/models/source'
149
- require 'ragie_ruby_sdk/models/status'
150
148
  require 'ragie_ruby_sdk/models/update_document_from_url_params'
151
149
  require 'ragie_ruby_sdk/models/update_document_raw_params'
152
150
  require 'ragie_ruby_sdk/models/update_instruction_params'
@@ -151,7 +151,7 @@ describe 'DocumentsApi' do
151
151
  # Get the content of a document. The &#x60;media_type&#x60; parameter can be used to request the content in a different format. When requesting as &#x60;application/json&#x60; additional metadata about the document will be included. If the original document contained content such as images or other non-textual media, this response will include a text description of that media instead of the original file data. Using mime types such as &#x60;audio/mpeg&#x60; or &#x60;video/mp4&#x60; will stream the file in a format that can be provided to an audio video player.
152
152
  # @param document_id The id of the document.
153
153
  # @param [Hash] opts the optional parameters
154
- # @option opts [MediaType] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document&#39;s type.
154
+ # @option opts [String] :media_type The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document&#39;s type.
155
155
  # @option opts [Boolean] :download Whether to return the content as a file download or a raw stream. If set to &#x60;true&#x60;, the content will be returned as a named file for download.
156
156
  # @option opts [String] :partition An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition.
157
157
  # @option opts [String] :range
@@ -36,6 +36,10 @@ describe RagieRubySdk::DocumentUpdateWebhookPayload do
36
36
  describe 'test attribute "status"' do
37
37
  it 'should work' do
38
38
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
39
+ # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["ready", "failed", "indexed", "keyword_indexed"])
40
+ # validator.allowable_values.each do |value|
41
+ # expect { instance.status = value }.not_to raise_error
42
+ # end
39
43
  end
40
44
  end
41
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ragie_ruby_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenAPI-Generator
@@ -178,7 +178,6 @@ files:
178
178
  - docs/Link.md
179
179
  - docs/ListConnectorSourceTypeInfo.md
180
180
  - docs/MediaModeParam.md
181
- - docs/MediaType.md
182
181
  - docs/MetadataValue.md
183
182
  - docs/MetadataValue1.md
184
183
  - docs/Mode.md
@@ -225,7 +224,6 @@ files:
225
224
  - docs/SharepointSiteData.md
226
225
  - docs/SlackData.md
227
226
  - docs/Source.md
228
- - docs/Status.md
229
227
  - docs/UpdateDocumentFromUrlParams.md
230
228
  - docs/UpdateDocumentRawParams.md
231
229
  - docs/UpdateInstructionParams.md
@@ -333,7 +331,6 @@ files:
333
331
  - lib/ragie_ruby_sdk/models/link.rb
334
332
  - lib/ragie_ruby_sdk/models/list_connector_source_type_info.rb
335
333
  - lib/ragie_ruby_sdk/models/media_mode_param.rb
336
- - lib/ragie_ruby_sdk/models/media_type.rb
337
334
  - lib/ragie_ruby_sdk/models/metadata_value.rb
338
335
  - lib/ragie_ruby_sdk/models/metadata_value1.rb
339
336
  - lib/ragie_ruby_sdk/models/mode.rb
@@ -378,7 +375,6 @@ files:
378
375
  - lib/ragie_ruby_sdk/models/sharepoint_site_data.rb
379
376
  - lib/ragie_ruby_sdk/models/slack_data.rb
380
377
  - lib/ragie_ruby_sdk/models/source.rb
381
- - lib/ragie_ruby_sdk/models/status.rb
382
378
  - lib/ragie_ruby_sdk/models/update_document_from_url_params.rb
383
379
  - lib/ragie_ruby_sdk/models/update_document_raw_params.rb
384
380
  - lib/ragie_ruby_sdk/models/update_instruction_params.rb
@@ -483,7 +479,6 @@ files:
483
479
  - spec/models/link_spec.rb
484
480
  - spec/models/list_connector_source_type_info_spec.rb
485
481
  - spec/models/media_mode_param_spec.rb
486
- - spec/models/media_type_spec.rb
487
482
  - spec/models/metadata_value1_spec.rb
488
483
  - spec/models/metadata_value_spec.rb
489
484
  - spec/models/mode1_spec.rb
@@ -528,7 +523,6 @@ files:
528
523
  - spec/models/sharepoint_site_data_spec.rb
529
524
  - spec/models/slack_data_spec.rb
530
525
  - spec/models/source_spec.rb
531
- - spec/models/status_spec.rb
532
526
  - spec/models/update_document_from_url_params_spec.rb
533
527
  - spec/models/update_document_raw_params_spec.rb
534
528
  - spec/models/update_instruction_params_spec.rb
@@ -654,7 +648,6 @@ test_files:
654
648
  - spec/models/link_spec.rb
655
649
  - spec/models/list_connector_source_type_info_spec.rb
656
650
  - spec/models/media_mode_param_spec.rb
657
- - spec/models/media_type_spec.rb
658
651
  - spec/models/metadata_value1_spec.rb
659
652
  - spec/models/metadata_value_spec.rb
660
653
  - spec/models/mode1_spec.rb
@@ -699,7 +692,6 @@ test_files:
699
692
  - spec/models/sharepoint_site_data_spec.rb
700
693
  - spec/models/slack_data_spec.rb
701
694
  - spec/models/source_spec.rb
702
- - spec/models/status_spec.rb
703
695
  - spec/models/update_document_from_url_params_spec.rb
704
696
  - spec/models/update_document_raw_params_spec.rb
705
697
  - spec/models/update_instruction_params_spec.rb
data/docs/MediaType.md DELETED
@@ -1,15 +0,0 @@
1
- # RagieRubySdk::MediaType
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
-
8
- ## Example
9
-
10
- ```ruby
11
- require 'ragie_ruby_sdk'
12
-
13
- instance = RagieRubySdk::MediaType.new()
14
- ```
15
-
data/docs/Status.md DELETED
@@ -1,15 +0,0 @@
1
- # RagieRubySdk::Status
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
-
8
- ## Example
9
-
10
- ```ruby
11
- require 'ragie_ruby_sdk'
12
-
13
- instance = RagieRubySdk::Status.new()
14
- ```
15
-
@@ -1,104 +0,0 @@
1
- =begin
2
- #Ragie API
3
-
4
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.16.0-SNAPSHOT
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module RagieRubySdk
17
- # The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type.
18
- module MediaType
19
- class << self
20
- # List of class defined in anyOf (OpenAPI v3)
21
- def openapi_any_of
22
- [
23
- :'String'
24
- ]
25
- end
26
-
27
- # Builds the object
28
- # @param [Mixed] Data to be matched against the list of anyOf items
29
- # @return [Object] Returns the model or the data itself
30
- def build(data)
31
- # Go through the list of anyOf items and attempt to identify the appropriate one.
32
- # Note:
33
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
34
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
35
- # - TODO: scalar values are de facto behaving as if they were nullable.
36
- # - TODO: logging when debugging is set.
37
- openapi_any_of.each do |klass|
38
- begin
39
- next if klass == :AnyType # "nullable: true"
40
- typed_data = find_and_cast_into_type(klass, data)
41
- return typed_data if typed_data
42
- rescue # rescue all errors so we keep iterating even if the current item lookup raises
43
- end
44
- end
45
-
46
- openapi_any_of.include?(:AnyType) ? data : nil
47
- end
48
-
49
- private
50
-
51
- SchemaMismatchError = Class.new(StandardError)
52
-
53
- # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
54
- def find_and_cast_into_type(klass, data)
55
- return if data.nil?
56
-
57
- case klass.to_s
58
- when 'Boolean'
59
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
60
- when 'Float'
61
- return data if data.instance_of?(Float)
62
- when 'Integer'
63
- return data if data.instance_of?(Integer)
64
- when 'Time'
65
- return Time.parse(data)
66
- when 'Date'
67
- return Date.iso8601(data)
68
- when 'String'
69
- return data if data.instance_of?(String)
70
- when 'Object' # "type: object"
71
- return data if data.instance_of?(Hash)
72
- when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
73
- if data.instance_of?(Array)
74
- sub_type = Regexp.last_match[:sub_type]
75
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
76
- end
77
- when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
78
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
- sub_type = Regexp.last_match[:sub_type]
80
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
- end
82
- else # model
83
- const = RagieRubySdk.const_get(klass)
84
- if const
85
- if const.respond_to?(:openapi_any_of) # nested anyOf model
86
- model = const.build(data)
87
- return model if model
88
- else
89
- # raise if data contains keys that are not known to the model
90
- raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
91
- model = const.build_from_hash(data)
92
- return model if model
93
- end
94
- end
95
- end
96
-
97
- raise # if no match by now, raise
98
- rescue
99
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
100
- end
101
- end
102
- end
103
-
104
- end
@@ -1,103 +0,0 @@
1
- =begin
2
- #Ragie API
3
-
4
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.16.0-SNAPSHOT
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module RagieRubySdk
17
- module Status
18
- class << self
19
- # List of class defined in anyOf (OpenAPI v3)
20
- def openapi_any_of
21
- [
22
- :'String'
23
- ]
24
- end
25
-
26
- # Builds the object
27
- # @param [Mixed] Data to be matched against the list of anyOf items
28
- # @return [Object] Returns the model or the data itself
29
- def build(data)
30
- # Go through the list of anyOf items and attempt to identify the appropriate one.
31
- # Note:
32
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
33
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
34
- # - TODO: scalar values are de facto behaving as if they were nullable.
35
- # - TODO: logging when debugging is set.
36
- openapi_any_of.each do |klass|
37
- begin
38
- next if klass == :AnyType # "nullable: true"
39
- typed_data = find_and_cast_into_type(klass, data)
40
- return typed_data if typed_data
41
- rescue # rescue all errors so we keep iterating even if the current item lookup raises
42
- end
43
- end
44
-
45
- openapi_any_of.include?(:AnyType) ? data : nil
46
- end
47
-
48
- private
49
-
50
- SchemaMismatchError = Class.new(StandardError)
51
-
52
- # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
53
- def find_and_cast_into_type(klass, data)
54
- return if data.nil?
55
-
56
- case klass.to_s
57
- when 'Boolean'
58
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
59
- when 'Float'
60
- return data if data.instance_of?(Float)
61
- when 'Integer'
62
- return data if data.instance_of?(Integer)
63
- when 'Time'
64
- return Time.parse(data)
65
- when 'Date'
66
- return Date.iso8601(data)
67
- when 'String'
68
- return data if data.instance_of?(String)
69
- when 'Object' # "type: object"
70
- return data if data.instance_of?(Hash)
71
- when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
72
- if data.instance_of?(Array)
73
- sub_type = Regexp.last_match[:sub_type]
74
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
- end
76
- when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
77
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
- sub_type = Regexp.last_match[:sub_type]
79
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
- end
81
- else # model
82
- const = RagieRubySdk.const_get(klass)
83
- if const
84
- if const.respond_to?(:openapi_any_of) # nested anyOf model
85
- model = const.build(data)
86
- return model if model
87
- else
88
- # raise if data contains keys that are not known to the model
89
- raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
90
- model = const.build_from_hash(data)
91
- return model if model
92
- end
93
- end
94
- end
95
-
96
- raise # if no match by now, raise
97
- rescue
98
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
99
- end
100
- end
101
- end
102
-
103
- end
@@ -1,21 +0,0 @@
1
- =begin
2
- #Ragie API
3
-
4
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.16.0-SNAPSHOT
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
- require 'date'
16
-
17
- # Unit tests for RagieRubySdk::MediaType
18
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
- # Please update as you see appropriate
20
- describe RagieRubySdk::MediaType do
21
- end
@@ -1,21 +0,0 @@
1
- =begin
2
- #Ragie API
3
-
4
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.16.0-SNAPSHOT
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
- require 'date'
16
-
17
- # Unit tests for RagieRubySdk::Status
18
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
- # Please update as you see appropriate
20
- describe RagieRubySdk::Status do
21
- end