mux_ruby 1.8.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +26 -37
- data/README.md +37 -13
- data/docs/AbridgedVideoView.md +33 -13
- data/docs/Asset.md +59 -25
- data/docs/AssetErrors.md +15 -4
- data/docs/AssetMaster.md +15 -4
- data/docs/AssetNonStandardInputReasons.md +29 -11
- data/docs/AssetRecordingTimes.md +15 -4
- data/docs/AssetResponse.md +13 -3
- data/docs/AssetStaticRenditions.md +15 -4
- data/docs/AssetStaticRenditionsFiles.md +23 -8
- data/docs/AssetsApi.md +396 -161
- data/docs/BreakdownValue.md +21 -7
- data/docs/CreateAssetRequest.md +27 -10
- data/docs/CreateLiveStreamRequest.md +27 -9
- data/docs/CreatePlaybackIDRequest.md +13 -3
- data/docs/CreatePlaybackIDResponse.md +13 -3
- data/docs/CreateSimulcastTargetRequest.md +17 -5
- data/docs/CreateTrackRequest.md +25 -9
- data/docs/CreateTrackResponse.md +13 -3
- data/docs/CreateUploadRequest.md +19 -6
- data/docs/DeliveryReport.md +27 -9
- data/docs/DeliveryUsageApi.md +41 -23
- data/docs/DimensionValue.md +15 -4
- data/docs/DimensionsApi.md +72 -34
- data/docs/DirectUploadsApi.md +131 -56
- data/docs/DisableLiveStreamResponse.md +13 -3
- data/docs/EnableLiveStreamResponse.md +13 -3
- data/docs/Error.md +27 -10
- data/docs/ErrorsApi.md +38 -20
- data/docs/ExportDate.md +20 -0
- data/docs/ExportFile.md +22 -0
- data/docs/ExportsApi.md +99 -12
- data/docs/FilterValue.md +15 -4
- data/docs/FiltersApi.md +71 -33
- data/docs/GetAssetInputInfoResponse.md +13 -3
- data/docs/GetAssetOrLiveStreamIdResponse.md +18 -0
- data/docs/GetAssetOrLiveStreamIdResponseData.md +22 -0
- data/docs/GetAssetOrLiveStreamIdResponseDataObject.md +20 -0
- data/docs/GetAssetPlaybackIDResponse.md +13 -3
- data/docs/GetMetricTimeseriesDataResponse.md +17 -5
- data/docs/GetOverallValuesResponse.md +17 -5
- data/docs/GetRealTimeBreakdownResponse.md +17 -5
- data/docs/GetRealTimeHistogramTimeseriesResponse.md +19 -6
- data/docs/GetRealTimeHistogramTimeseriesResponseMeta.md +13 -3
- data/docs/GetRealTimeTimeseriesResponse.md +17 -5
- data/docs/Incident.md +53 -23
- data/docs/IncidentBreakdown.md +17 -5
- data/docs/IncidentNotification.md +17 -5
- data/docs/IncidentNotificationRule.md +21 -7
- data/docs/IncidentResponse.md +15 -4
- data/docs/IncidentsApi.md +118 -62
- data/docs/InputFile.md +15 -4
- data/docs/InputInfo.md +15 -4
- data/docs/InputSettings.md +31 -10
- data/docs/InputSettingsOverlaySettings.md +25 -9
- data/docs/InputTrack.md +29 -11
- data/docs/Insight.md +23 -8
- data/docs/ListAllMetricValuesResponse.md +17 -5
- data/docs/ListAssetsResponse.md +13 -3
- data/docs/ListBreakdownValuesResponse.md +17 -5
- data/docs/ListDeliveryUsageResponse.md +19 -6
- data/docs/ListDimensionValuesResponse.md +17 -5
- data/docs/ListDimensionsResponse.md +17 -5
- data/docs/ListErrorsResponse.md +17 -5
- data/docs/ListExportsResponse.md +17 -5
- data/docs/ListFilterValuesResponse.md +17 -5
- data/docs/ListFiltersResponse.md +17 -5
- data/docs/ListFiltersResponseData.md +15 -4
- data/docs/ListIncidentsResponse.md +17 -5
- data/docs/ListInsightsResponse.md +17 -5
- data/docs/ListLiveStreamsResponse.md +13 -3
- data/docs/ListRealTimeDimensionsResponse.md +17 -5
- data/docs/ListRealTimeDimensionsResponseData.md +15 -4
- data/docs/ListRealTimeMetricsResponse.md +17 -5
- data/docs/ListRelatedIncidentsResponse.md +17 -5
- data/docs/ListSigningKeysResponse.md +13 -3
- data/docs/ListUploadsResponse.md +13 -3
- data/docs/ListVideoViewExportsResponse.md +22 -0
- data/docs/ListVideoViewsResponse.md +17 -5
- data/docs/LiveStream.md +39 -15
- data/docs/LiveStreamResponse.md +13 -3
- data/docs/LiveStreamsApi.md +418 -170
- data/docs/Metric.md +21 -7
- data/docs/MetricsApi.md +211 -117
- data/docs/NotificationRule.md +17 -5
- data/docs/OverallValues.md +19 -6
- data/docs/PlaybackID.md +15 -4
- data/docs/PlaybackIDApi.md +78 -0
- data/docs/PlaybackPolicy.md +10 -2
- data/docs/RealTimeApi.md +177 -81
- data/docs/RealTimeBreakdownValue.md +21 -7
- data/docs/RealTimeHistogramTimeseriesBucket.md +15 -4
- data/docs/RealTimeHistogramTimeseriesBucketValues.md +15 -4
- data/docs/RealTimeHistogramTimeseriesDatapoint.md +25 -9
- data/docs/RealTimeTimeseriesDatapoint.md +17 -5
- data/docs/Score.md +23 -8
- data/docs/SignalLiveStreamCompleteResponse.md +13 -3
- data/docs/SigningKey.md +17 -5
- data/docs/SigningKeyResponse.md +13 -3
- data/docs/SimulcastTarget.md +21 -7
- data/docs/SimulcastTargetResponse.md +13 -3
- data/docs/Track.md +37 -15
- data/docs/URLSigningKeysApi.md +130 -54
- data/docs/UpdateAssetMP4SupportRequest.md +13 -3
- data/docs/UpdateAssetMasterAccessRequest.md +13 -3
- data/docs/Upload.md +29 -11
- data/docs/UploadError.md +15 -4
- data/docs/UploadResponse.md +13 -3
- data/docs/VideoView.md +251 -114
- data/docs/VideoViewEvent.md +19 -6
- data/docs/VideoViewResponse.md +15 -4
- data/docs/VideoViewsApi.md +78 -41
- data/examples/video/exercise-assets.rb +21 -0
- data/examples/video/exercise-live-streams.rb +8 -0
- data/gen/.gitignore +7 -0
- data/gen/Makefile +31 -0
- data/gen/generator-config.json +11 -0
- data/gen/openapitools.json +7 -0
- data/gen/package.json +17 -0
- data/gen/templates/Gemfile.mustache +11 -0
- data/gen/templates/README.mustache +158 -0
- data/gen/templates/Rakefile.mustache +10 -0
- data/gen/templates/api.mustache +206 -0
- data/gen/templates/api_client.mustache +264 -0
- data/gen/templates/api_client_faraday_partial.mustache +138 -0
- data/gen/templates/api_client_spec.mustache +220 -0
- data/gen/templates/api_client_typhoeus_partial.mustache +183 -0
- data/gen/templates/api_doc.mustache +118 -0
- data/gen/templates/api_error.mustache +67 -0
- data/gen/templates/api_info.mustache +12 -0
- data/gen/templates/api_test.mustache +47 -0
- data/gen/templates/base_object.mustache +120 -0
- data/gen/templates/configuration.mustache +349 -0
- data/gen/templates/configuration_spec.mustache +34 -0
- data/gen/templates/configuration_tls_faraday_partial.mustache +29 -0
- data/gen/templates/configuration_tls_typhoeus_partial.mustache +34 -0
- data/gen/templates/gem.mustache +40 -0
- data/gen/templates/gemspec.mustache +35 -0
- data/gen/templates/gitignore.mustache +39 -0
- data/gen/templates/model.mustache +26 -0
- data/gen/templates/model_doc.mustache +12 -0
- data/gen/templates/model_test.mustache +77 -0
- data/gen/templates/partial_model_enum_class.mustache +20 -0
- data/gen/templates/partial_model_generic.mustache +371 -0
- data/gen/templates/partial_model_generic_doc.mustache +28 -0
- data/gen/templates/partial_oneof_module.mustache +137 -0
- data/gen/templates/partial_oneof_module_doc.mustache +92 -0
- data/gen/templates/rspec.mustache +2 -0
- data/gen/templates/rubocop.mustache +148 -0
- data/gen/templates/spec_helper.mustache +103 -0
- data/gen/templates/version.mustache +7 -0
- data/gen/yarn.lock +1878 -0
- data/lib/mux_ruby.rb +16 -2
- data/lib/mux_ruby/api/assets_api.rb +291 -152
- data/lib/mux_ruby/api/delivery_usage_api.rb +32 -16
- data/lib/mux_ruby/api/dimensions_api.rb +55 -29
- data/lib/mux_ruby/api/direct_uploads_api.rb +90 -44
- data/lib/mux_ruby/api/errors_api.rb +34 -18
- data/lib/mux_ruby/api/exports_api.rb +86 -13
- data/lib/mux_ruby/api/filters_api.rb +53 -27
- data/lib/mux_ruby/api/incidents_api.rb +94 -52
- data/lib/mux_ruby/api/live_streams_api.rb +299 -157
- data/lib/mux_ruby/api/metrics_api.rb +193 -122
- data/lib/mux_ruby/api/playback_id_api.rb +85 -0
- data/lib/mux_ruby/api/real_time_api.rb +149 -87
- data/lib/mux_ruby/api/url_signing_keys_api.rb +95 -48
- data/lib/mux_ruby/api/video_views_api.rb +60 -33
- data/lib/mux_ruby/api_client.rb +106 -91
- data/lib/mux_ruby/api_error.rb +35 -7
- data/lib/mux_ruby/configuration.rb +50 -14
- data/lib/mux_ruby/models/abridged_video_view.rb +58 -24
- data/lib/mux_ruby/models/asset.rb +129 -58
- data/lib/mux_ruby/models/asset_errors.rb +52 -15
- data/lib/mux_ruby/models/asset_master.rb +85 -15
- data/lib/mux_ruby/models/asset_non_standard_input_reasons.rb +78 -43
- data/lib/mux_ruby/models/asset_recording_times.rb +52 -18
- data/lib/mux_ruby/models/asset_response.rb +48 -14
- data/lib/mux_ruby/models/asset_static_renditions.rb +55 -19
- data/lib/mux_ruby/models/asset_static_renditions_files.rb +60 -25
- data/lib/mux_ruby/models/breakdown_value.rb +52 -18
- data/lib/mux_ruby/models/create_asset_request.rb +70 -30
- data/lib/mux_ruby/models/create_live_stream_request.rb +68 -23
- data/lib/mux_ruby/models/create_playback_id_request.rb +48 -14
- data/lib/mux_ruby/models/create_playback_id_response.rb +48 -14
- data/lib/mux_ruby/models/create_simulcast_target_request.rb +50 -16
- data/lib/mux_ruby/models/create_track_request.rb +65 -27
- data/lib/mux_ruby/models/create_track_response.rb +48 -14
- data/lib/mux_ruby/models/create_upload_request.rb +52 -18
- data/lib/mux_ruby/models/delivery_report.rb +106 -21
- data/lib/mux_ruby/models/dimension_value.rb +49 -15
- data/lib/mux_ruby/models/disable_live_stream_response.rb +48 -14
- data/lib/mux_ruby/models/enable_live_stream_response.rb +48 -14
- data/lib/mux_ruby/models/error.rb +63 -21
- data/lib/mux_ruby/models/export_date.rb +229 -0
- data/lib/mux_ruby/models/export_file.rb +236 -0
- data/lib/mux_ruby/models/filter_value.rb +49 -15
- data/lib/mux_ruby/models/get_asset_input_info_response.rb +48 -14
- data/lib/mux_ruby/models/get_asset_or_live_stream_id_response.rb +218 -0
- data/lib/mux_ruby/models/get_asset_or_live_stream_id_response_data.rb +237 -0
- data/lib/mux_ruby/models/get_asset_or_live_stream_id_response_data_object.rb +264 -0
- data/lib/mux_ruby/models/get_asset_playback_id_response.rb +48 -14
- data/lib/mux_ruby/models/get_metric_timeseries_data_response.rb +50 -16
- data/lib/mux_ruby/models/get_overall_values_response.rb +50 -16
- data/lib/mux_ruby/models/get_real_time_breakdown_response.rb +50 -16
- data/lib/mux_ruby/models/get_real_time_histogram_timeseries_response.rb +51 -17
- data/lib/mux_ruby/models/get_real_time_histogram_timeseries_response_meta.rb +48 -14
- data/lib/mux_ruby/models/get_real_time_timeseries_response.rb +50 -16
- data/lib/mux_ruby/models/incident.rb +68 -34
- data/lib/mux_ruby/models/incident_breakdown.rb +50 -16
- data/lib/mux_ruby/models/incident_notification.rb +50 -16
- data/lib/mux_ruby/models/incident_notification_rule.rb +52 -18
- data/lib/mux_ruby/models/incident_response.rb +49 -15
- data/lib/mux_ruby/models/input_file.rb +49 -15
- data/lib/mux_ruby/models/input_info.rb +49 -15
- data/lib/mux_ruby/models/input_settings.rb +91 -30
- data/lib/mux_ruby/models/input_settings_overlay_settings.rb +68 -26
- data/lib/mux_ruby/models/input_track.rb +56 -22
- data/lib/mux_ruby/models/insight.rb +53 -19
- data/lib/mux_ruby/models/list_all_metric_values_response.rb +50 -16
- data/lib/mux_ruby/models/list_assets_response.rb +48 -14
- data/lib/mux_ruby/models/list_breakdown_values_response.rb +50 -16
- data/lib/mux_ruby/models/list_delivery_usage_response.rb +51 -17
- data/lib/mux_ruby/models/list_dimension_values_response.rb +50 -16
- data/lib/mux_ruby/models/list_dimensions_response.rb +50 -16
- data/lib/mux_ruby/models/list_errors_response.rb +50 -16
- data/lib/mux_ruby/models/list_exports_response.rb +50 -16
- data/lib/mux_ruby/models/list_filter_values_response.rb +50 -16
- data/lib/mux_ruby/models/list_filters_response.rb +50 -16
- data/lib/mux_ruby/models/list_filters_response_data.rb +49 -15
- data/lib/mux_ruby/models/list_incidents_response.rb +50 -16
- data/lib/mux_ruby/models/list_insights_response.rb +50 -16
- data/lib/mux_ruby/models/list_live_streams_response.rb +48 -14
- data/lib/mux_ruby/models/list_real_time_dimensions_response.rb +50 -16
- data/lib/mux_ruby/models/list_real_time_dimensions_response_data.rb +49 -15
- data/lib/mux_ruby/models/list_real_time_metrics_response.rb +50 -16
- data/lib/mux_ruby/models/list_related_incidents_response.rb +50 -16
- data/lib/mux_ruby/models/list_signing_keys_response.rb +48 -14
- data/lib/mux_ruby/models/list_uploads_response.rb +48 -14
- data/lib/mux_ruby/models/list_video_view_exports_response.rb +240 -0
- data/lib/mux_ruby/models/list_video_views_response.rb +50 -16
- data/lib/mux_ruby/models/live_stream.rb +121 -29
- data/lib/mux_ruby/models/live_stream_response.rb +48 -14
- data/lib/mux_ruby/models/metric.rb +52 -18
- data/lib/mux_ruby/models/notification_rule.rb +50 -16
- data/lib/mux_ruby/models/overall_values.rb +51 -17
- data/lib/mux_ruby/models/playback_id.rb +50 -15
- data/lib/mux_ruby/models/playback_policy.rb +12 -6
- data/lib/mux_ruby/models/real_time_breakdown_value.rb +52 -18
- data/lib/mux_ruby/models/real_time_histogram_timeseries_bucket.rb +50 -16
- data/lib/mux_ruby/models/real_time_histogram_timeseries_bucket_values.rb +49 -15
- data/lib/mux_ruby/models/real_time_histogram_timeseries_datapoint.rb +54 -20
- data/lib/mux_ruby/models/real_time_timeseries_datapoint.rb +50 -16
- data/lib/mux_ruby/models/score.rb +53 -19
- data/lib/mux_ruby/models/signal_live_stream_complete_response.rb +48 -14
- data/lib/mux_ruby/models/signing_key.rb +53 -16
- data/lib/mux_ruby/models/signing_key_response.rb +48 -14
- data/lib/mux_ruby/models/simulcast_target.rb +55 -21
- data/lib/mux_ruby/models/simulcast_target_response.rb +48 -14
- data/lib/mux_ruby/models/track.rb +92 -33
- data/lib/mux_ruby/models/update_asset_master_access_request.rb +51 -17
- data/lib/mux_ruby/models/update_asset_mp4_support_request.rb +51 -17
- data/lib/mux_ruby/models/upload.rb +62 -26
- data/lib/mux_ruby/models/upload_error.rb +51 -15
- data/lib/mux_ruby/models/upload_response.rb +48 -14
- data/lib/mux_ruby/models/video_view.rb +242 -136
- data/lib/mux_ruby/models/video_view_event.rb +51 -17
- data/lib/mux_ruby/models/video_view_response.rb +49 -15
- data/lib/mux_ruby/version.rb +10 -3
- data/mux_ruby.gemspec +15 -15
- data/spec/api/assets_api_spec.rb +2 -0
- data/spec/api/playback_id_api_spec.rb +40 -0
- data/spec/api_client_spec.rb +10 -3
- data/spec/configuration_spec.rb +9 -2
- data/spec/models/asset_master_spec.rb +4 -0
- data/spec/models/asset_spec.rb +10 -0
- data/spec/models/export_date_spec.rb +40 -0
- data/spec/models/export_file_spec.rb +46 -0
- data/spec/models/get_asset_or_live_stream_id_response_data_object_spec.rb +44 -0
- data/spec/models/get_asset_or_live_stream_id_response_data_spec.rb +46 -0
- data/spec/models/get_asset_or_live_stream_id_response_spec.rb +34 -0
- data/spec/models/input_settings_spec.rb +12 -0
- data/spec/models/list_video_view_exports_response_spec.rb +46 -0
- data/spec/models/track_spec.rb +4 -0
- data/spec/spec_helper.rb +9 -2
- metadata +161 -235
@@ -0,0 +1,28 @@
|
|
1
|
+
# {{moduleName}}::{{classname}}
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
| Name | Type | Description | Notes |
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
7
|
+
{{#vars}}
|
8
|
+
| **{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} |
|
9
|
+
{{/vars}}
|
10
|
+
|
11
|
+
## Example
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require '{{{gemName}}}'
|
15
|
+
|
16
|
+
{{^vars}}
|
17
|
+
instance = {{moduleName}}::{{classname}}.new()
|
18
|
+
{{/vars}}
|
19
|
+
{{#vars}}
|
20
|
+
{{#-first}}
|
21
|
+
instance = {{moduleName}}::{{classname}}.new(
|
22
|
+
{{/-first}}
|
23
|
+
{{name}}: {{example}}{{^-last}},{{/-last}}
|
24
|
+
{{#-last}}
|
25
|
+
)
|
26
|
+
{{/-last}}
|
27
|
+
{{/vars}}
|
28
|
+
```
|
@@ -0,0 +1,137 @@
|
|
1
|
+
{{#description}}
|
2
|
+
# {{{description}}}
|
3
|
+
{{/description}}
|
4
|
+
module {{classname}}
|
5
|
+
class << self
|
6
|
+
{{#oneOf}}
|
7
|
+
{{#-first}}
|
8
|
+
# List of class defined in oneOf (OpenAPI v3)
|
9
|
+
def openapi_one_of
|
10
|
+
[
|
11
|
+
{{/-first}}
|
12
|
+
:'{{{.}}}'{{^-last}},{{/-last}}
|
13
|
+
{{#-last}}
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
{{/-last}}
|
18
|
+
{{/oneOf}}
|
19
|
+
{{#discriminator}}
|
20
|
+
{{#propertyName}}
|
21
|
+
# Discriminator's property name (OpenAPI v3)
|
22
|
+
def openapi_discriminator_name
|
23
|
+
:'{{{.}}}'
|
24
|
+
end
|
25
|
+
|
26
|
+
{{/propertyName}}
|
27
|
+
{{#mappedModels}}
|
28
|
+
{{#-first}}
|
29
|
+
# Discriminator's mapping (OpenAPI v3)
|
30
|
+
def openapi_discriminator_mapping
|
31
|
+
{
|
32
|
+
{{/-first}}
|
33
|
+
:'{{{mappingName}}}' => :'{{{modelName}}}'{{^-last}},{{/-last}}
|
34
|
+
{{#-last}}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
{{/-last}}
|
39
|
+
{{/mappedModels}}
|
40
|
+
{{/discriminator}}
|
41
|
+
# Builds the object
|
42
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
43
|
+
# @return [Object] Returns the model or the data itself
|
44
|
+
def build(data)
|
45
|
+
{{#discriminator}}
|
46
|
+
discriminator_value = data[openapi_discriminator_name]
|
47
|
+
return nil unless discriminator_value
|
48
|
+
{{#mappedModels}}
|
49
|
+
{{#-first}}
|
50
|
+
|
51
|
+
klass = openapi_discriminator_mapping[discriminator_value.to_sym]
|
52
|
+
return nil unless klass
|
53
|
+
|
54
|
+
{{moduleName}}.const_get(klass).build_from_hash(data)
|
55
|
+
{{/-first}}
|
56
|
+
{{/mappedModels}}
|
57
|
+
{{^mappedModels}}
|
58
|
+
{{moduleName}}.const_get(discriminator_value).build_from_hash(data)
|
59
|
+
{{/mappedModels}}
|
60
|
+
{{/discriminator}}
|
61
|
+
{{^discriminator}}
|
62
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
63
|
+
# Note:
|
64
|
+
# - We do not attempt to check whether exactly one item matches.
|
65
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
66
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
67
|
+
# - TODO: scalar values are defacto behaving as if they were nullable.
|
68
|
+
# - TODO: logging when debugging is set.
|
69
|
+
openapi_one_of.each do |klass|
|
70
|
+
begin
|
71
|
+
next if klass == :AnyType # "nullable: true"
|
72
|
+
typed_data = find_and_cast_into_type(klass, data)
|
73
|
+
return typed_data if typed_data
|
74
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
79
|
+
{{/discriminator}}
|
80
|
+
end
|
81
|
+
{{^discriminator}}
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
SchemaMismatchError = Class.new(StandardError)
|
86
|
+
|
87
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
88
|
+
def find_and_cast_into_type(klass, data)
|
89
|
+
return if data.nil?
|
90
|
+
|
91
|
+
case klass.to_s
|
92
|
+
when 'Boolean'
|
93
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
94
|
+
when 'Float'
|
95
|
+
return data if data.instance_of?(Float)
|
96
|
+
when 'Integer'
|
97
|
+
return data if data.instance_of?(Integer)
|
98
|
+
when 'Time'
|
99
|
+
return Time.parse(data)
|
100
|
+
when 'Date'
|
101
|
+
return Date.parse(data)
|
102
|
+
when 'String'
|
103
|
+
return data if data.instance_of?(String)
|
104
|
+
when 'Object' # "type: object"
|
105
|
+
return data if data.instance_of?(Hash)
|
106
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
107
|
+
if data.instance_of?(Array)
|
108
|
+
sub_type = Regexp.last_match[:sub_type]
|
109
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
110
|
+
end
|
111
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
112
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
113
|
+
sub_type = Regexp.last_match[:sub_type]
|
114
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
115
|
+
end
|
116
|
+
else # model
|
117
|
+
const = {{moduleName}}.const_get(klass)
|
118
|
+
if const
|
119
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
120
|
+
model = const.build(data)
|
121
|
+
return model if model
|
122
|
+
else
|
123
|
+
# raise if data contains keys that are not known to the model
|
124
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
125
|
+
model = const.build_from_hash(data)
|
126
|
+
return model if model && model.valid?
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
raise # if no match by now, raise
|
132
|
+
rescue
|
133
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
134
|
+
end
|
135
|
+
{{/discriminator}}
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# {{moduleName}}::{{classname}}
|
2
|
+
|
3
|
+
## Class instance methods
|
4
|
+
|
5
|
+
### `openapi_one_of`
|
6
|
+
|
7
|
+
Returns the list of classes defined in oneOf.
|
8
|
+
|
9
|
+
#### Example
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require '{{{gemName}}}'
|
13
|
+
|
14
|
+
{{moduleName}}::{{classname}}.openapi_one_of
|
15
|
+
# =>
|
16
|
+
{{#oneOf}}
|
17
|
+
{{#-first}}
|
18
|
+
# [
|
19
|
+
{{/-first}}
|
20
|
+
# :'{{{.}}}'{{^-last}},{{/-last}}
|
21
|
+
{{#-last}}
|
22
|
+
# ]
|
23
|
+
{{/-last}}
|
24
|
+
{{/oneOf}}
|
25
|
+
```
|
26
|
+
{{#discriminator}}
|
27
|
+
{{#propertyName}}
|
28
|
+
|
29
|
+
### `openapi_discriminator_name`
|
30
|
+
|
31
|
+
Returns the discriminator's property name.
|
32
|
+
|
33
|
+
#### Example
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require '{{{gemName}}}'
|
37
|
+
|
38
|
+
{{moduleName}}::{{classname}}.openapi_discriminator_name
|
39
|
+
# => :'{{{.}}}'
|
40
|
+
```
|
41
|
+
{{/propertyName}}
|
42
|
+
{{#mappedModels}}
|
43
|
+
{{#-first}}
|
44
|
+
|
45
|
+
### `openapi_discriminator_name`
|
46
|
+
|
47
|
+
Returns the discriminator's mapping.
|
48
|
+
|
49
|
+
#### Example
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
require '{{{gemName}}}'
|
53
|
+
|
54
|
+
{{moduleName}}::{{classname}}.openapi_discriminator_mapping
|
55
|
+
# =>
|
56
|
+
# {
|
57
|
+
{{/-first}}
|
58
|
+
# :'{{{mappingName}}}' => :'{{{modelName}}}'{{^-last}},{{/-last}}
|
59
|
+
{{#-last}}
|
60
|
+
# }
|
61
|
+
{{/-last}}
|
62
|
+
{{/mappedModels}}
|
63
|
+
{{/discriminator}}
|
64
|
+
|
65
|
+
### build
|
66
|
+
|
67
|
+
Find the appropriate object from the `openapi_one_of` list and casts the data into it.
|
68
|
+
|
69
|
+
#### Example
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require '{{{gemName}}}'
|
73
|
+
|
74
|
+
{{moduleName}}::{{classname}}.build(data)
|
75
|
+
# => {{#oneOf}}{{#-first}}#<{{{.}}}:0x00007fdd4aab02a0>{{/-first}}{{/oneOf}}
|
76
|
+
|
77
|
+
{{moduleName}}::{{classname}}.build(data_that_doesnt_match)
|
78
|
+
# => nil
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Parameters
|
82
|
+
|
83
|
+
| Name | Type | Description |
|
84
|
+
| ---- | ---- | ----------- |
|
85
|
+
| **data** | **Mixed** | data to be matched against the list of oneOf items |
|
86
|
+
|
87
|
+
#### Return type
|
88
|
+
|
89
|
+
{{#oneOf}}
|
90
|
+
- `{{{.}}}`
|
91
|
+
{{/oneOf}}
|
92
|
+
- `nil` (if no type matches)
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
|
2
|
+
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
6
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
7
|
+
DisabledByDefault: true
|
8
|
+
Exclude:
|
9
|
+
- '**/templates/**/*'
|
10
|
+
- '**/vendor/**/*'
|
11
|
+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
|
12
|
+
|
13
|
+
# Prefer &&/|| over and/or.
|
14
|
+
Style/AndOr:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
# Align `when` with `case`.
|
18
|
+
Layout/CaseIndentation:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
# Align comments with method definitions.
|
22
|
+
Layout/CommentIndentation:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Layout/ElseAlignment:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Layout/EmptyLineAfterMagicComment:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
# In a regular class definition, no empty lines around the body.
|
32
|
+
Layout/EmptyLinesAroundClassBody:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
# In a regular method definition, no empty lines around the body.
|
36
|
+
Layout/EmptyLinesAroundMethodBody:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
# In a regular module definition, no empty lines around the body.
|
40
|
+
Layout/EmptyLinesAroundModuleBody:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Layout/FirstArgumentIndentation:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
47
|
+
Style/HashSyntax:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
51
|
+
# extra level of indentation.
|
52
|
+
Layout/IndentationConsistency:
|
53
|
+
Enabled: true
|
54
|
+
EnforcedStyle: indented_internal_methods
|
55
|
+
|
56
|
+
# Two spaces, no tabs (for indentation).
|
57
|
+
Layout/IndentationWidth:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Layout/LeadingCommentSpace:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Layout/SpaceAfterColon:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Layout/SpaceAfterComma:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Layout/SpaceAroundKeyword:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Layout/SpaceAroundOperators:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Layout/SpaceBeforeComma:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Layout/SpaceBeforeFirstArg:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Style/DefWithParentheses:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
# Defining a method with parameters needs parentheses.
|
88
|
+
Style/MethodDefParentheses:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
Style/FrozenStringLiteralComment:
|
92
|
+
Enabled: false
|
93
|
+
EnforcedStyle: always
|
94
|
+
|
95
|
+
# Use `foo {}` not `foo{}`.
|
96
|
+
Layout/SpaceBeforeBlockBraces:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
# Use `foo { bar }` not `foo {bar}`.
|
100
|
+
Layout/SpaceInsideBlockBraces:
|
101
|
+
Enabled: true
|
102
|
+
|
103
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
104
|
+
Layout/SpaceInsideHashLiteralBraces:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
Layout/SpaceInsideParens:
|
108
|
+
Enabled: true
|
109
|
+
|
110
|
+
# Check quotes usage according to lint rule below.
|
111
|
+
#Style/StringLiterals:
|
112
|
+
# Enabled: true
|
113
|
+
# EnforcedStyle: single_quotes
|
114
|
+
|
115
|
+
# Detect hard tabs, no hard tabs.
|
116
|
+
Layout/IndentationStyle:
|
117
|
+
Enabled: true
|
118
|
+
|
119
|
+
# Blank lines should not have any spaces.
|
120
|
+
Layout/TrailingEmptyLines:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
# No trailing whitespace.
|
124
|
+
Layout/TrailingWhitespace:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
# Use quotes for string literals when they are enough.
|
128
|
+
Style/RedundantPercentQ:
|
129
|
+
Enabled: true
|
130
|
+
|
131
|
+
# Align `end` with the matching keyword or starting expression except for
|
132
|
+
# assignments, where it should be aligned with the LHS.
|
133
|
+
Layout/EndAlignment:
|
134
|
+
Enabled: true
|
135
|
+
EnforcedStyleAlignWith: variable
|
136
|
+
AutoCorrect: true
|
137
|
+
|
138
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
139
|
+
Lint/RequireParentheses:
|
140
|
+
Enabled: true
|
141
|
+
|
142
|
+
Style/RedundantReturn:
|
143
|
+
Enabled: true
|
144
|
+
AllowMultipleReturnValues: true
|
145
|
+
|
146
|
+
Style/Semicolon:
|
147
|
+
Enabled: true
|
148
|
+
AllowAsExpressionSeparator: true
|
@@ -0,0 +1,103 @@
|
|
1
|
+
=begin
|
2
|
+
{{> api_info}}
|
3
|
+
=end
|
4
|
+
|
5
|
+
# load the gem
|
6
|
+
require '{{{gemName}}}'
|
7
|
+
|
8
|
+
# The following was generated by the `rspec --init` command. Conventionally, all
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
11
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
12
|
+
# files.
|
13
|
+
#
|
14
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
15
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
16
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
17
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
18
|
+
# a separate helper file that requires the additional dependencies and performs
|
19
|
+
# the additional setup, and require it from the spec files that actually need
|
20
|
+
# it.
|
21
|
+
#
|
22
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
23
|
+
# users commonly want.
|
24
|
+
#
|
25
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
26
|
+
RSpec.configure do |config|
|
27
|
+
# rspec-expectations config goes here. You can use an alternate
|
28
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
29
|
+
# assertions if you prefer.
|
30
|
+
config.expect_with :rspec do |expectations|
|
31
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
32
|
+
# and `failure_message` of custom matchers include text for helper methods
|
33
|
+
# defined using `chain`, e.g.:
|
34
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
35
|
+
# # => "be bigger than 2 and smaller than 4"
|
36
|
+
# ...rather than:
|
37
|
+
# # => "be bigger than 2"
|
38
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
42
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
43
|
+
config.mock_with :rspec do |mocks|
|
44
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
45
|
+
# a real object. This is generally recommended, and will default to
|
46
|
+
# `true` in RSpec 4.
|
47
|
+
mocks.verify_partial_doubles = true
|
48
|
+
end
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# These two settings work together to allow you to limit a spec run
|
54
|
+
# to individual examples or groups you care about by tagging them with
|
55
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
56
|
+
# get run.
|
57
|
+
config.filter_run :focus
|
58
|
+
config.run_all_when_everything_filtered = true
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# be too noisy due to issues in dependencies.
|
74
|
+
config.warnings = true
|
75
|
+
|
76
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# file, and it's useful to allow more verbose output when running an
|
78
|
+
# individual spec file.
|
79
|
+
if config.files_to_run.one?
|
80
|
+
# Use the documentation formatter for detailed output,
|
81
|
+
# unless a formatter has already been configured
|
82
|
+
# (e.g. via a command-line flag).
|
83
|
+
config.default_formatter = 'doc'
|
84
|
+
end
|
85
|
+
|
86
|
+
# Print the 10 slowest examples and example groups at the
|
87
|
+
# end of the spec run, to help surface which specs are running
|
88
|
+
# particularly slow.
|
89
|
+
config.profile_examples = 10
|
90
|
+
|
91
|
+
# Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# the seed, which is printed after each run.
|
94
|
+
# --seed 1234
|
95
|
+
config.order = :random
|
96
|
+
|
97
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# test failures related to randomization by passing the same `--seed` value
|
100
|
+
# as the one that triggered the failure.
|
101
|
+
Kernel.srand config.seed
|
102
|
+
=end
|
103
|
+
end
|