kuapir 0.1.2
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 +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +77 -0
- data/LICENSE +21 -0
- data/README.md +170 -0
- data/Rakefile +12 -0
- data/docs/BoxOffice.md +26 -0
- data/docs/BoxOfficeResponse.md +20 -0
- data/docs/Company.md +18 -0
- data/docs/Country.md +18 -0
- data/docs/DigitalReleaseItem.md +44 -0
- data/docs/DigitalReleaseResponse.md +22 -0
- data/docs/Distribution.md +28 -0
- data/docs/DistributionResponse.md +20 -0
- data/docs/Episode.md +28 -0
- data/docs/Fact.md +22 -0
- data/docs/FactResponse.md +20 -0
- data/docs/Film.md +100 -0
- data/docs/FilmSearchByFiltersResponse.md +22 -0
- data/docs/FilmSearchByFiltersResponseItems.md +42 -0
- data/docs/FilmSearchResponse.md +24 -0
- data/docs/FilmSearchResponseFilms.md +42 -0
- data/docs/FilmSequelsAndPrequelsResponse.md +30 -0
- data/docs/FilmTopResponse.md +20 -0
- data/docs/FilmTopResponseFilms.md +38 -0
- data/docs/FilmsApi.md +1126 -0
- data/docs/FiltersResponse.md +20 -0
- data/docs/FiltersResponseCountries.md +20 -0
- data/docs/FiltersResponseGenres.md +20 -0
- data/docs/Genre.md +18 -0
- data/docs/ImageResponse.md +22 -0
- data/docs/ImageResponseItems.md +20 -0
- data/docs/PersonByNameResponse.md +20 -0
- data/docs/PersonByNameResponseItems.md +28 -0
- data/docs/PersonResponse.md +50 -0
- data/docs/PersonResponseFilms.md +30 -0
- data/docs/PersonResponseSpouses.md +32 -0
- data/docs/PersonsApi.md +83 -0
- data/docs/PremiereResponse.md +20 -0
- data/docs/PremiereResponseItem.md +36 -0
- data/docs/RelatedFilmResponse.md +20 -0
- data/docs/RelatedFilmResponseItems.md +30 -0
- data/docs/ReviewDetailsResponse.md +32 -0
- data/docs/ReviewsApi.md +155 -0
- data/docs/ReviewsResponse.md +34 -0
- data/docs/ReviewsResponseReviews.md +32 -0
- data/docs/Season.md +20 -0
- data/docs/SeasonResponse.md +20 -0
- data/docs/StaffApi.md +147 -0
- data/docs/StaffResponse.md +30 -0
- data/docs/VideoResponse.md +20 -0
- data/docs/VideoResponseItems.md +22 -0
- data/kinopoiskapiunofficial-openapi.json +2918 -0
- data/kuapir.gemspec +42 -0
- data/lib/kuapir/api/films_api.rb +1193 -0
- data/lib/kuapir/api/persons_api.rb +89 -0
- data/lib/kuapir/api/reviews_api.rb +165 -0
- data/lib/kuapir/api/staff_api.rb +145 -0
- data/lib/kuapir/api_client.rb +390 -0
- data/lib/kuapir/api_error.rb +57 -0
- data/lib/kuapir/configuration.rb +287 -0
- data/lib/kuapir/models/box_office.rb +246 -0
- data/lib/kuapir/models/box_office_response.rb +224 -0
- data/lib/kuapir/models/company.rb +214 -0
- data/lib/kuapir/models/country.rb +214 -0
- data/lib/kuapir/models/digital_release_item.rb +334 -0
- data/lib/kuapir/models/digital_release_response.rb +232 -0
- data/lib/kuapir/models/distribution.rb +300 -0
- data/lib/kuapir/models/distribution_response.rb +224 -0
- data/lib/kuapir/models/episode.rb +249 -0
- data/lib/kuapir/models/fact.rb +266 -0
- data/lib/kuapir/models/fact_response.rb +224 -0
- data/lib/kuapir/models/film.rb +551 -0
- data/lib/kuapir/models/film_search_by_filters_response.rb +232 -0
- data/lib/kuapir/models/film_search_by_filters_response_items.rb +319 -0
- data/lib/kuapir/models/film_search_response.rb +244 -0
- data/lib/kuapir/models/film_search_response_films.rb +311 -0
- data/lib/kuapir/models/film_sequels_and_prequels_response.rb +300 -0
- data/lib/kuapir/models/film_top_response.rb +224 -0
- data/lib/kuapir/models/film_top_response_films.rb +272 -0
- data/lib/kuapir/models/filters_response.rb +226 -0
- data/lib/kuapir/models/filters_response_countries.rb +214 -0
- data/lib/kuapir/models/filters_response_genres.rb +214 -0
- data/lib/kuapir/models/genre.rb +214 -0
- data/lib/kuapir/models/image_response.rb +238 -0
- data/lib/kuapir/models/image_response_items.rb +214 -0
- data/lib/kuapir/models/person_by_name_response.rb +224 -0
- data/lib/kuapir/models/person_by_name_response_items.rb +274 -0
- data/lib/kuapir/models/person_response.rb +363 -0
- data/lib/kuapir/models/person_response_films.rb +284 -0
- data/lib/kuapir/models/person_response_spouses.rb +283 -0
- data/lib/kuapir/models/premiere_response.rb +224 -0
- data/lib/kuapir/models/premiere_response_item.rb +289 -0
- data/lib/kuapir/models/related_film_response.rb +224 -0
- data/lib/kuapir/models/related_film_response_items.rb +279 -0
- data/lib/kuapir/models/review_details_response.rb +314 -0
- data/lib/kuapir/models/reviews_response.rb +294 -0
- data/lib/kuapir/models/reviews_response_reviews.rb +282 -0
- data/lib/kuapir/models/season.rb +224 -0
- data/lib/kuapir/models/season_response.rb +224 -0
- data/lib/kuapir/models/staff_response.rb +301 -0
- data/lib/kuapir/models/video_response.rb +224 -0
- data/lib/kuapir/models/video_response_items.rb +255 -0
- data/lib/kuapir/version.rb +5 -0
- data/lib/kuapir.rb +83 -0
- data/openapi-generator-templates/Gemfile.mustache +9 -0
- data/openapi-generator-templates/README.mustache +148 -0
- data/openapi-generator-templates/Rakefile.mustache +10 -0
- data/openapi-generator-templates/api.mustache +205 -0
- data/openapi-generator-templates/api_client.mustache +260 -0
- data/openapi-generator-templates/api_client_faraday_partial.mustache +136 -0
- data/openapi-generator-templates/api_client_spec.mustache +216 -0
- data/openapi-generator-templates/api_client_typhoeus_partial.mustache +153 -0
- data/openapi-generator-templates/api_doc.mustache +118 -0
- data/openapi-generator-templates/api_error.mustache +45 -0
- data/openapi-generator-templates/api_info.mustache +12 -0
- data/openapi-generator-templates/api_test.mustache +43 -0
- data/openapi-generator-templates/base_object.mustache +120 -0
- data/openapi-generator-templates/configuration.mustache +381 -0
- data/openapi-generator-templates/configuration_spec.mustache +30 -0
- data/openapi-generator-templates/configuration_tls_faraday_partial.mustache +29 -0
- data/openapi-generator-templates/configuration_tls_typhoeus_partial.mustache +34 -0
- data/openapi-generator-templates/gem.mustache +50 -0
- data/openapi-generator-templates/gemspec.mustache +31 -0
- data/openapi-generator-templates/git_push.sh.mustache +57 -0
- data/openapi-generator-templates/gitignore.mustache +39 -0
- data/openapi-generator-templates/model.mustache +22 -0
- data/openapi-generator-templates/model_doc.mustache +12 -0
- data/openapi-generator-templates/model_test.mustache +73 -0
- data/openapi-generator-templates/partial_model_enum_class.mustache +20 -0
- data/openapi-generator-templates/partial_model_generic.mustache +371 -0
- data/openapi-generator-templates/partial_model_generic_doc.mustache +28 -0
- data/openapi-generator-templates/partial_oneof_module.mustache +137 -0
- data/openapi-generator-templates/partial_oneof_module_doc.mustache +92 -0
- data/openapi-generator-templates/rspec.mustache +2 -0
- data/openapi-generator-templates/rubocop.mustache +148 -0
- data/openapi-generator-templates/spec_helper.mustache +99 -0
- data/openapi-generator-templates/travis.mustache +14 -0
- data/openapi-generator-templates/version.mustache +3 -0
- data/openapitools.json +21 -0
- data/spec/api/films_api_spec.rb +227 -0
- data/spec/api/persons_api_spec.rb +45 -0
- data/spec/api/reviews_api_spec.rb +57 -0
- data/spec/api/staff_api_spec.rb +54 -0
- data/spec/api_client_spec.rb +229 -0
- data/spec/configuration_spec.rb +28 -0
- data/spec/models/box_office_response_spec.rb +37 -0
- data/spec/models/box_office_spec.rb +55 -0
- data/spec/models/company_spec.rb +31 -0
- data/spec/models/country_spec.rb +31 -0
- data/spec/models/digital_release_item_spec.rb +109 -0
- data/spec/models/digital_release_response_spec.rb +43 -0
- data/spec/models/distribution_response_spec.rb +37 -0
- data/spec/models/distribution_spec.rb +69 -0
- data/spec/models/episode_spec.rb +61 -0
- data/spec/models/fact_response_spec.rb +37 -0
- data/spec/models/fact_spec.rb +47 -0
- data/spec/models/film_search_by_filters_response_items_spec.rb +107 -0
- data/spec/models/film_search_by_filters_response_spec.rb +43 -0
- data/spec/models/film_search_response_films_spec.rb +107 -0
- data/spec/models/film_search_response_spec.rb +49 -0
- data/spec/models/film_sequels_and_prequels_response_spec.rb +71 -0
- data/spec/models/film_spec.rb +285 -0
- data/spec/models/film_top_response_films_spec.rb +91 -0
- data/spec/models/film_top_response_spec.rb +37 -0
- data/spec/models/filters_response_countries_spec.rb +37 -0
- data/spec/models/filters_response_genres_spec.rb +37 -0
- data/spec/models/filters_response_spec.rb +37 -0
- data/spec/models/genre_spec.rb +31 -0
- data/spec/models/image_response_items_spec.rb +37 -0
- data/spec/models/image_response_spec.rb +43 -0
- data/spec/models/person_by_name_response_items_spec.rb +65 -0
- data/spec/models/person_by_name_response_spec.rb +37 -0
- data/spec/models/person_response_films_spec.rb +71 -0
- data/spec/models/person_response_spec.rb +131 -0
- data/spec/models/person_response_spouses_spec.rb +77 -0
- data/spec/models/premiere_response_item_spec.rb +85 -0
- data/spec/models/premiere_response_spec.rb +37 -0
- data/spec/models/related_film_response_items_spec.rb +71 -0
- data/spec/models/related_film_response_spec.rb +37 -0
- data/spec/models/review_details_response_spec.rb +77 -0
- data/spec/models/reviews_response_reviews_spec.rb +77 -0
- data/spec/models/reviews_response_spec.rb +79 -0
- data/spec/models/season_response_spec.rb +37 -0
- data/spec/models/season_spec.rb +37 -0
- data/spec/models/staff_response_spec.rb +71 -0
- data/spec/models/video_response_items_spec.rb +47 -0
- data/spec/models/video_response_spec.rb +37 -0
- data/spec/spec_helper.rb +107 -0
- metadata +326 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
3
|
+
#
|
4
|
+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
5
|
+
|
6
|
+
git_user_id=$1
|
7
|
+
git_repo_id=$2
|
8
|
+
release_note=$3
|
9
|
+
git_host=$4
|
10
|
+
|
11
|
+
if [ "$git_host" = "" ]; then
|
12
|
+
git_host="{{{gitHost}}}"
|
13
|
+
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
14
|
+
fi
|
15
|
+
|
16
|
+
if [ "$git_user_id" = "" ]; then
|
17
|
+
git_user_id="{{{gitUserId}}}"
|
18
|
+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
19
|
+
fi
|
20
|
+
|
21
|
+
if [ "$git_repo_id" = "" ]; then
|
22
|
+
git_repo_id="{{{gitRepoId}}}"
|
23
|
+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
24
|
+
fi
|
25
|
+
|
26
|
+
if [ "$release_note" = "" ]; then
|
27
|
+
release_note="{{{releaseNote}}}"
|
28
|
+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
29
|
+
fi
|
30
|
+
|
31
|
+
# Initialize the local directory as a Git repository
|
32
|
+
git init
|
33
|
+
|
34
|
+
# Adds the files in the local repository and stages them for commit.
|
35
|
+
git add .
|
36
|
+
|
37
|
+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
38
|
+
git commit -m "$release_note"
|
39
|
+
|
40
|
+
# Sets the new remote
|
41
|
+
git_remote=$(git remote)
|
42
|
+
if [ "$git_remote" = "" ]; then # git remote not defined
|
43
|
+
|
44
|
+
if [ "$GIT_TOKEN" = "" ]; then
|
45
|
+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
46
|
+
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
47
|
+
else
|
48
|
+
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
49
|
+
fi
|
50
|
+
|
51
|
+
fi
|
52
|
+
|
53
|
+
git pull origin master
|
54
|
+
|
55
|
+
# Pushes (Forces) the changes in the local repository up to the remote repository
|
56
|
+
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
57
|
+
git push origin master 2>&1 | grep -v 'To https'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Generated by: https://openapi-generator.tech
|
2
|
+
#
|
3
|
+
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/spec/examples.txt
|
12
|
+
/test/tmp/
|
13
|
+
/test/version_tmp/
|
14
|
+
/tmp/
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
|
21
|
+
## Documentation cache and generated files:
|
22
|
+
/.yardoc/
|
23
|
+
/_yardoc/
|
24
|
+
/doc/
|
25
|
+
/rdoc/
|
26
|
+
|
27
|
+
## Environment normalization:
|
28
|
+
/.bundle/
|
29
|
+
/vendor/bundle
|
30
|
+
/lib/bundler/man/
|
31
|
+
|
32
|
+
# for a library or gem, you might want to ignore these files since the code is
|
33
|
+
# intended to run in multiple environments; otherwise, check them in:
|
34
|
+
# Gemfile.lock
|
35
|
+
# .ruby-version
|
36
|
+
# .ruby-gemset
|
37
|
+
|
38
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
39
|
+
.rvmrc
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module {{moduleName}}
|
5
|
+
{{#models}}
|
6
|
+
{{#model}}
|
7
|
+
{{#isEnum}}
|
8
|
+
{{>partial_model_enum_class}}
|
9
|
+
{{/isEnum}}
|
10
|
+
{{^isEnum}}
|
11
|
+
{{#oneOf}}
|
12
|
+
{{#-first}}
|
13
|
+
{{>partial_oneof_module}}
|
14
|
+
{{/-first}}
|
15
|
+
{{/oneOf}}
|
16
|
+
{{^oneOf}}
|
17
|
+
{{>partial_model_generic}}
|
18
|
+
{{/oneOf}}
|
19
|
+
{{/isEnum}}
|
20
|
+
{{/model}}
|
21
|
+
{{/models}}
|
22
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# Unit tests for {{moduleName}}::{{classname}}
|
6
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
7
|
+
# Please update as you see appropriate
|
8
|
+
{{#models}}
|
9
|
+
{{#model}}
|
10
|
+
describe {{moduleName}}::{{classname}} do
|
11
|
+
{{^oneOf}}
|
12
|
+
let(:instance) { {{moduleName}}::{{classname}}.new }
|
13
|
+
|
14
|
+
describe 'test an instance of {{classname}}' do
|
15
|
+
it 'should create an instance of {{classname}}' do
|
16
|
+
expect(instance).to be_instance_of({{moduleName}}::{{classname}})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
{{#vars}}
|
20
|
+
describe 'test attribute "{{{name}}}"' do
|
21
|
+
it 'should work' do
|
22
|
+
{{#isEnum}}
|
23
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
24
|
+
# validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
|
25
|
+
# validator.allowable_values.each do |value|
|
26
|
+
# expect { instance.{{name}} = value }.not_to raise_error
|
27
|
+
# end
|
28
|
+
{{/isEnum}}
|
29
|
+
{{^isEnum}}
|
30
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
31
|
+
{{/isEnum}}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
{{/vars}}
|
36
|
+
{{/oneOf}}
|
37
|
+
{{#oneOf}}
|
38
|
+
{{#-first}}
|
39
|
+
describe '.openapi_one_of' do
|
40
|
+
it 'lists the items referenced in the oneOf array' do
|
41
|
+
expect(described_class.openapi_one_of).to_not be_empty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
{{#discriminator}}
|
46
|
+
{{#propertyName}}
|
47
|
+
describe '.openapi_discriminator_name' do
|
48
|
+
it 'returns the value of the "discriminator" property' do
|
49
|
+
expect(described_class.openapi_discriminator_name).to_not be_empty
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
{{/propertyName}}
|
54
|
+
{{#mappedModels}}
|
55
|
+
{{#-first}}
|
56
|
+
describe '.openapi_discriminator_mapping' do
|
57
|
+
it 'returns the key/values of the "mapping" property' do
|
58
|
+
expect(described_class.openapi_discriminator_mapping.values.sort).to eq(described_class.openapi_one_of.sort)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
{{/-first}}
|
63
|
+
{{/mappedModels}}
|
64
|
+
{{/discriminator}}
|
65
|
+
describe '.build' do
|
66
|
+
it 'returns the correct model' do
|
67
|
+
end
|
68
|
+
end
|
69
|
+
{{/-first}}
|
70
|
+
{{/oneOf}}
|
71
|
+
end
|
72
|
+
{{/model}}
|
73
|
+
{{/models}}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class {{classname}}{{#allowableValues}}{{#enumVars}}
|
2
|
+
{{{name}}} = {{{value}}}.freeze{{/enumVars}}
|
3
|
+
|
4
|
+
{{/allowableValues}}
|
5
|
+
# Builds the enum from string
|
6
|
+
# @param [String] The enum value in the form of the string
|
7
|
+
# @return [String] The enum value
|
8
|
+
def self.build_from_hash(value)
|
9
|
+
new.build_from_hash(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Builds the enum from string
|
13
|
+
# @param [String] The enum value in the form of the string
|
14
|
+
# @return [String] The enum value
|
15
|
+
def build_from_hash(value)
|
16
|
+
constantValues = {{classname}}.constants.select { |c| {{classname}}::const_get(c) == value }
|
17
|
+
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
|
18
|
+
value
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,371 @@
|
|
1
|
+
{{#description}}
|
2
|
+
# {{{.}}}
|
3
|
+
{{/description}}
|
4
|
+
class {{classname}}{{#parent}} < {{{.}}}{{/parent}}
|
5
|
+
{{#vars}}
|
6
|
+
{{#description}}
|
7
|
+
# {{{.}}}
|
8
|
+
{{/description}}
|
9
|
+
attr_accessor :{{{name}}}
|
10
|
+
|
11
|
+
{{/vars}}
|
12
|
+
{{#hasEnums}}
|
13
|
+
class EnumAttributeValidator
|
14
|
+
attr_reader :datatype
|
15
|
+
attr_reader :allowable_values
|
16
|
+
|
17
|
+
def initialize(datatype, allowable_values)
|
18
|
+
@allowable_values = allowable_values.map do |value|
|
19
|
+
case datatype.to_s
|
20
|
+
when /Integer/i
|
21
|
+
value.to_i
|
22
|
+
when /Float/i
|
23
|
+
value.to_f
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid?(value)
|
31
|
+
!value || allowable_values.include?(value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
{{/hasEnums}}
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
{{#vars}}
|
40
|
+
:'{{{name}}}' => :'{{{baseName}}}'{{^-last}},{{/-last}}
|
41
|
+
{{/vars}}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns all the JSON keys this model knows about{{#parent}}, including the ones defined in its parent(s){{/parent}}
|
46
|
+
def self.acceptable_attributes
|
47
|
+
{{^parent}}
|
48
|
+
attribute_map.values
|
49
|
+
{{/parent}}
|
50
|
+
{{#parent}}
|
51
|
+
attribute_map.values.concat(superclass.acceptable_attributes)
|
52
|
+
{{/parent}}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.openapi_types
|
57
|
+
{
|
58
|
+
{{#vars}}
|
59
|
+
:'{{{name}}}' => :'{{{dataType}}}'{{^-last}},{{/-last}}
|
60
|
+
{{/vars}}
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# List of attributes with nullable: true
|
65
|
+
def self.openapi_nullable
|
66
|
+
Set.new([
|
67
|
+
{{#vars}}
|
68
|
+
{{#isNullable}}
|
69
|
+
:'{{{name}}}'{{^-last}},{{/-last}}
|
70
|
+
{{/isNullable}}
|
71
|
+
{{/vars}}
|
72
|
+
])
|
73
|
+
end
|
74
|
+
|
75
|
+
{{#anyOf}}
|
76
|
+
{{#-first}}
|
77
|
+
# List of class defined in anyOf (OpenAPI v3)
|
78
|
+
def self.openapi_any_of
|
79
|
+
[
|
80
|
+
{{/-first}}
|
81
|
+
:'{{{.}}}'{{^-last}},{{/-last}}
|
82
|
+
{{#-last}}
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
{{/-last}}
|
87
|
+
{{/anyOf}}
|
88
|
+
{{#allOf}}
|
89
|
+
{{#-first}}
|
90
|
+
# List of class defined in allOf (OpenAPI v3)
|
91
|
+
def self.openapi_all_of
|
92
|
+
[
|
93
|
+
{{/-first}}
|
94
|
+
:'{{{.}}}'{{^-last}},{{/-last}}
|
95
|
+
{{#-last}}
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
{{/-last}}
|
100
|
+
{{/allOf}}
|
101
|
+
{{#discriminator}}
|
102
|
+
{{#propertyName}}
|
103
|
+
# discriminator's property name in OpenAPI v3
|
104
|
+
def self.openapi_discriminator_name
|
105
|
+
:'{{{.}}}'
|
106
|
+
end
|
107
|
+
|
108
|
+
{{/propertyName}}
|
109
|
+
{{/discriminator}}
|
110
|
+
# Initializes the object
|
111
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
112
|
+
def initialize(attributes = {})
|
113
|
+
if (!attributes.is_a?(Hash))
|
114
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `{{{moduleName}}}::{{{classname}}}` initialize method"
|
115
|
+
end
|
116
|
+
|
117
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
118
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
119
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
120
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `{{{moduleName}}}::{{{classname}}}`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
121
|
+
end
|
122
|
+
h[k.to_sym] = v
|
123
|
+
}
|
124
|
+
{{#parent}}
|
125
|
+
|
126
|
+
# call parent's initialize
|
127
|
+
super(attributes)
|
128
|
+
{{/parent}}
|
129
|
+
{{#vars}}
|
130
|
+
|
131
|
+
if attributes.key?(:'{{{name}}}')
|
132
|
+
{{#isArray}}
|
133
|
+
if (value = attributes[:'{{{name}}}']).is_a?(Array)
|
134
|
+
self.{{{name}}} = value
|
135
|
+
end
|
136
|
+
{{/isArray}}
|
137
|
+
{{#isMap}}
|
138
|
+
if (value = attributes[:'{{{name}}}']).is_a?(Hash)
|
139
|
+
self.{{{name}}} = value
|
140
|
+
end
|
141
|
+
{{/isMap}}
|
142
|
+
{{^isContainer}}
|
143
|
+
self.{{{name}}} = attributes[:'{{{name}}}']
|
144
|
+
{{/isContainer}}
|
145
|
+
{{#defaultValue}}
|
146
|
+
else
|
147
|
+
self.{{{name}}} = {{{defaultValue}}}
|
148
|
+
{{/defaultValue}}
|
149
|
+
end
|
150
|
+
{{/vars}}
|
151
|
+
end
|
152
|
+
|
153
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
154
|
+
# @return Array for valid properties with the reasons
|
155
|
+
def list_invalid_properties
|
156
|
+
invalid_properties = {{^parent}}Array.new{{/parent}}{{#parent}}super{{/parent}}
|
157
|
+
{{#vars}}
|
158
|
+
{{^isNullable}}
|
159
|
+
{{#required}}
|
160
|
+
if @{{{name}}}.nil?
|
161
|
+
invalid_properties.push('invalid value for "{{{name}}}", {{{name}}} cannot be nil.')
|
162
|
+
end
|
163
|
+
|
164
|
+
{{/required}}
|
165
|
+
{{/isNullable}}
|
166
|
+
{{#hasValidation}}
|
167
|
+
{{#maxLength}}
|
168
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
|
169
|
+
invalid_properties.push('invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.')
|
170
|
+
end
|
171
|
+
|
172
|
+
{{/maxLength}}
|
173
|
+
{{#minLength}}
|
174
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
|
175
|
+
invalid_properties.push('invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.')
|
176
|
+
end
|
177
|
+
|
178
|
+
{{/minLength}}
|
179
|
+
{{#maximum}}
|
180
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
|
181
|
+
invalid_properties.push('invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.')
|
182
|
+
end
|
183
|
+
|
184
|
+
{{/maximum}}
|
185
|
+
{{#minimum}}
|
186
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
|
187
|
+
invalid_properties.push('invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.')
|
188
|
+
end
|
189
|
+
|
190
|
+
{{/minimum}}
|
191
|
+
{{#pattern}}
|
192
|
+
pattern = Regexp.new({{{pattern}}})
|
193
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ pattern
|
194
|
+
invalid_properties.push("invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}.")
|
195
|
+
end
|
196
|
+
|
197
|
+
{{/pattern}}
|
198
|
+
{{#maxItems}}
|
199
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
|
200
|
+
invalid_properties.push('invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.')
|
201
|
+
end
|
202
|
+
|
203
|
+
{{/maxItems}}
|
204
|
+
{{#minItems}}
|
205
|
+
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
|
206
|
+
invalid_properties.push('invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.')
|
207
|
+
end
|
208
|
+
|
209
|
+
{{/minItems}}
|
210
|
+
{{/hasValidation}}
|
211
|
+
{{/vars}}
|
212
|
+
invalid_properties
|
213
|
+
end
|
214
|
+
|
215
|
+
# Check to see if the all the properties in the model are valid
|
216
|
+
# @return true if the model is valid
|
217
|
+
def valid?
|
218
|
+
{{#vars}}
|
219
|
+
{{^isNullable}}
|
220
|
+
{{#required}}
|
221
|
+
return false if @{{{name}}}.nil?
|
222
|
+
{{/required}}
|
223
|
+
{{/isNullable}}
|
224
|
+
{{#isEnum}}
|
225
|
+
{{^isContainer}}
|
226
|
+
{{{name}}}_validator = EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
|
227
|
+
return false unless {{{name}}}_validator.valid?(@{{{name}}})
|
228
|
+
{{/isContainer}}
|
229
|
+
{{/isEnum}}
|
230
|
+
{{#hasValidation}}
|
231
|
+
{{#maxLength}}
|
232
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
|
233
|
+
{{/maxLength}}
|
234
|
+
{{#minLength}}
|
235
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
|
236
|
+
{{/minLength}}
|
237
|
+
{{#maximum}}
|
238
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
|
239
|
+
{{/maximum}}
|
240
|
+
{{#minimum}}
|
241
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
|
242
|
+
{{/minimum}}
|
243
|
+
{{#pattern}}
|
244
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
|
245
|
+
{{/pattern}}
|
246
|
+
{{#maxItems}}
|
247
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
|
248
|
+
{{/maxItems}}
|
249
|
+
{{#minItems}}
|
250
|
+
return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
|
251
|
+
{{/minItems}}
|
252
|
+
{{/hasValidation}}
|
253
|
+
{{/vars}}
|
254
|
+
{{#anyOf}}
|
255
|
+
{{#-first}}
|
256
|
+
_any_of_found = false
|
257
|
+
self.class.openapi_any_of.each do |_class|
|
258
|
+
_any_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
|
259
|
+
if _any_of.valid?
|
260
|
+
_any_of_found = true
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
if !_any_of_found
|
265
|
+
return false
|
266
|
+
end
|
267
|
+
|
268
|
+
{{/-first}}
|
269
|
+
{{/anyOf}}
|
270
|
+
true{{#parent}} && super{{/parent}}
|
271
|
+
end
|
272
|
+
|
273
|
+
{{#vars}}
|
274
|
+
{{#isEnum}}
|
275
|
+
{{^isContainer}}
|
276
|
+
# Custom attribute writer method checking allowed values (enum).
|
277
|
+
# @param [Object] {{{name}}} Object to be assigned
|
278
|
+
def {{{name}}}=({{{name}}})
|
279
|
+
validator = EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
|
280
|
+
unless validator.valid?({{{name}}})
|
281
|
+
fail ArgumentError, "invalid value for \"{{{name}}}\", must be one of #{validator.allowable_values}."
|
282
|
+
end
|
283
|
+
@{{{name}}} = {{{name}}}
|
284
|
+
end
|
285
|
+
|
286
|
+
{{/isContainer}}
|
287
|
+
{{/isEnum}}
|
288
|
+
{{^isEnum}}
|
289
|
+
{{#hasValidation}}
|
290
|
+
# Custom attribute writer method with validation
|
291
|
+
# @param [Object] {{{name}}} Value to be assigned
|
292
|
+
def {{{name}}}=({{{name}}})
|
293
|
+
{{^isNullable}}
|
294
|
+
{{#required}}
|
295
|
+
if {{{name}}}.nil?
|
296
|
+
fail ArgumentError, '{{{name}}} cannot be nil'
|
297
|
+
end
|
298
|
+
|
299
|
+
{{/required}}
|
300
|
+
{{/isNullable}}
|
301
|
+
{{#maxLength}}
|
302
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}}
|
303
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.'
|
304
|
+
end
|
305
|
+
|
306
|
+
{{/maxLength}}
|
307
|
+
{{#minLength}}
|
308
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length < {{{minLength}}}
|
309
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.'
|
310
|
+
end
|
311
|
+
|
312
|
+
{{/minLength}}
|
313
|
+
{{#maximum}}
|
314
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
|
315
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.'
|
316
|
+
end
|
317
|
+
|
318
|
+
{{/maximum}}
|
319
|
+
{{#minimum}}
|
320
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
|
321
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.'
|
322
|
+
end
|
323
|
+
|
324
|
+
{{/minimum}}
|
325
|
+
{{#pattern}}
|
326
|
+
pattern = Regexp.new({{{pattern}}})
|
327
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ pattern
|
328
|
+
fail ArgumentError, "invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}."
|
329
|
+
end
|
330
|
+
|
331
|
+
{{/pattern}}
|
332
|
+
{{#maxItems}}
|
333
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}}
|
334
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.'
|
335
|
+
end
|
336
|
+
|
337
|
+
{{/maxItems}}
|
338
|
+
{{#minItems}}
|
339
|
+
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}}
|
340
|
+
fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.'
|
341
|
+
end
|
342
|
+
|
343
|
+
{{/minItems}}
|
344
|
+
@{{{name}}} = {{{name}}}
|
345
|
+
end
|
346
|
+
|
347
|
+
{{/hasValidation}}
|
348
|
+
{{/isEnum}}
|
349
|
+
{{/vars}}
|
350
|
+
# Checks equality by comparing each attribute.
|
351
|
+
# @param [Object] Object to be compared
|
352
|
+
def ==(o)
|
353
|
+
return true if self.equal?(o)
|
354
|
+
self.class == o.class{{#vars}} &&
|
355
|
+
{{name}} == o.{{name}}{{/vars}}{{#parent}} && super(o){{/parent}}
|
356
|
+
end
|
357
|
+
|
358
|
+
# @see the `==` method
|
359
|
+
# @param [Object] Object to be compared
|
360
|
+
def eql?(o)
|
361
|
+
self == o
|
362
|
+
end
|
363
|
+
|
364
|
+
# Calculates hash code according to all attributes.
|
365
|
+
# @return [Integer] Hash code
|
366
|
+
def hash
|
367
|
+
[{{#vars}}{{name}}{{^-last}}, {{/-last}}{{/vars}}].hash
|
368
|
+
end
|
369
|
+
|
370
|
+
{{> base_object}}
|
371
|
+
end
|
@@ -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}} |
|
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
|
+
```
|