diff --git a/modules/swagger-codegen/src/main/resources/ruby/model_test.mustache b/modules/swagger-codegen/src/main/resources/ruby/model_test.mustache index 305a10d6467..9425585780f 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model_test.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model_test.mustache @@ -27,7 +27,15 @@ require 'date' {{#vars}} describe 'test attribute "{{{name}}}"' do it 'should work' do + {{#isEnum}} + validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) + validator.allowable_values.each do |value| + expect { @instance.{{name}} = value }.not_to raise_error + end + {{/isEnum}} + {{^isEnum}} # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + {{/isEnum}} end end diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache index 25a71610168..0335500863f 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache @@ -4,6 +4,30 @@ attr_accessor :{{{name}}} {{/vars}} +{{#hasEnums}} + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end +{{/hasEnums}} + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -53,13 +77,6 @@ # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new - {{#isEnum}} - allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if @{{{name}}} && !allowed_values.include?({{{name}}}) - invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.") - end - - {{/isEnum}} {{#hasValidation}} if @{{{name}}}.nil? fail ArgumentError, "{{{name}}} cannot be nil" @@ -104,50 +121,31 @@ def valid? {{#vars}} {{#required}} - if @{{{name}}}.nil? - return false - end - + return false if @{{{name}}}.nil? {{/required}} {{#isEnum}} - allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if @{{{name}}} && !allowed_values.include?(@{{{name}}}) - return false - end + {{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) + return false unless {{{name}}}_validator.valid?(@{{{name}}}) {{/isEnum}} {{#hasValidation}} {{#minLength}} - if @{{{name}}}.to_s.length > {{{maxLength}}} - return false - end - + return false if @{{{name}}}.to_s.length > {{{maxLength}}} {{/minLength}} {{#maxLength}} - if @{{{name}}}.to_s.length < {{{minLength}}} - return false - end - + return false if @{{{name}}}.to_s.length < {{{minLength}}} {{/maxLength}} {{#maximum}} - if @{{{name}}} > {{{maximum}}} - return false - end - + return false if @{{{name}}} > {{{maximum}}} {{/maximum}} {{#minimum}} - if @{{{name}}} < {{{minimum}}} - return false - end - + return false if @{{{name}}} < {{{minimum}}} {{/minimum}} {{#pattern}} - if @{{{name}}} !~ Regexp.new({{{pattern}}}) - return false - end - + return false if @{{{name}}} !~ Regexp.new({{{pattern}}}) {{/pattern}} {{/hasValidation}} {{/vars}} + return true end {{#vars}} @@ -155,9 +153,9 @@ # Custom attribute writer method checking allowed values (enum). # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) - allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if {{{name}}} && !allowed_values.include?({{{name}}}) - fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) + unless validator.valid?({{{name}}}) + fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{validator.allowable_values}." end @{{{name}}} = {{{name}}} end diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 355df9f8c67..a47ea8d19de 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -30,6 +30,7 @@ module Petstore attr_accessor :color + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -76,10 +77,8 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @class_name.nil? - return false - end - + return false if @class_name.nil? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb index 244a0ca62af..8daae9c91c1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb @@ -26,6 +26,7 @@ require 'date' module Petstore class AnimalFarm + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -58,6 +59,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 8f3c8ed3193..25ad09ca813 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -32,6 +32,7 @@ module Petstore attr_accessor :message + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -82,6 +83,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index e277b6602bf..e4ca7f92fc0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -32,6 +32,7 @@ module Petstore attr_accessor :declawed + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -84,10 +85,8 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @class_name.nil? - return false - end - + return false if @class_name.nil? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index da887681789..e7c09fcc514 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -30,6 +30,7 @@ module Petstore attr_accessor :name + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -74,6 +75,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index f9db9ab7c50..ed335a91429 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -32,6 +32,7 @@ module Petstore attr_accessor :breed + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -84,10 +85,8 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @class_name.nil? - return false - end - + return false if @class_name.nil? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index f4d85b99357..8f1c4c8bec0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -32,6 +32,28 @@ module Petstore attr_accessor :enum_number + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -82,26 +104,21 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - allowed_values = ["UPPER", "lower"] - if @enum_string && !allowed_values.include?(@enum_string) - return false - end - allowed_values = ["1", "-1"] - if @enum_integer && !allowed_values.include?(@enum_integer) - return false - end - allowed_values = ["1.1", "-1.2"] - if @enum_number && !allowed_values.include?(@enum_number) - return false - end + enum_string_validator = EnumAttributeValidator.new('String', ["UPPER", "lower"]) + return false unless enum_string_validator.valid?(@enum_string) + enum_integer_validator = EnumAttributeValidator.new('Integer', ["1", "-1"]) + return false unless enum_integer_validator.valid?(@enum_integer) + enum_number_validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) + return false unless enum_number_validator.valid?(@enum_number) + return true end # Custom attribute writer method checking allowed values (enum). # @param [Object] enum_string Object to be assigned def enum_string=(enum_string) - allowed_values = ["UPPER", "lower"] - if enum_string && !allowed_values.include?(enum_string) - fail ArgumentError, "invalid value for 'enum_string', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('String', ["UPPER", "lower"]) + unless validator.valid?(enum_string) + fail ArgumentError, "invalid value for 'enum_string', must be one of #{validator.allowable_values}." end @enum_string = enum_string end @@ -109,9 +126,9 @@ module Petstore # Custom attribute writer method checking allowed values (enum). # @param [Object] enum_integer Object to be assigned def enum_integer=(enum_integer) - allowed_values = ["1", "-1"] - if enum_integer && !allowed_values.include?(enum_integer) - fail ArgumentError, "invalid value for 'enum_integer', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('Integer', ["1", "-1"]) + unless validator.valid?(enum_integer) + fail ArgumentError, "invalid value for 'enum_integer', must be one of #{validator.allowable_values}." end @enum_integer = enum_integer end @@ -119,9 +136,9 @@ module Petstore # Custom attribute writer method checking allowed values (enum). # @param [Object] enum_number Object to be assigned def enum_number=(enum_number) - allowed_values = ["1.1", "-1.2"] - if enum_number && !allowed_values.include?(enum_number) - fail ArgumentError, "invalid value for 'enum_number', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) + unless validator.valid?(enum_number) + fail ArgumentError, "invalid value for 'enum_number', must be one of #{validator.allowable_values}." end @enum_number = enum_number end diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 63107bd2128..668dab29fd7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -52,6 +52,7 @@ module Petstore attr_accessor :password + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -162,74 +163,24 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @integer > 100.0 - return false - end - - if @integer < 10.0 - return false - end - - if @int32 > 200.0 - return false - end - - if @int32 < 20.0 - return false - end - - if @number.nil? - return false - end - - if @number > 543.2 - return false - end - - if @number < 32.1 - return false - end - - if @float > 987.6 - return false - end - - if @float < 54.3 - return false - end - - if @double > 123.4 - return false - end - - if @double < 67.8 - return false - end - - if @string !~ Regexp.new(/[a-z]/i) - return false - end - - if @byte.nil? - return false - end - - if @date.nil? - return false - end - - if @password.nil? - return false - end - - if @password.to_s.length > 64 - return false - end - - if @password.to_s.length < 10 - return false - end - + return false if @integer > 100.0 + return false if @integer < 10.0 + return false if @int32 > 200.0 + return false if @int32 < 20.0 + return false if @number.nil? + return false if @number > 543.2 + return false if @number < 32.1 + return false if @float > 987.6 + return false if @float < 54.3 + return false if @double > 123.4 + return false if @double < 67.8 + return false if @string !~ Regexp.new(/[a-z]/i) + return false if @byte.nil? + return false if @date.nil? + return false if @password.nil? + return false if @password.to_s.length > 64 + return false if @password.to_s.length < 10 + return true end # Custom attribute writer method with validation diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 186f46f6b3f..5e293ef4c61 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -28,6 +28,7 @@ module Petstore class Model200Response attr_accessor :name + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -66,6 +67,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 595b1c76bec..7bda1eea5e6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -28,6 +28,7 @@ module Petstore class ModelReturn attr_accessor :_return + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -66,6 +67,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index d063138e41b..94247c1ed2f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -34,6 +34,7 @@ module Petstore attr_accessor :_123_number + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -90,10 +91,8 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @name.nil? - return false - end - + return false if @name.nil? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 5dd15cbe92d..87931c88d1d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -39,6 +39,28 @@ module Petstore attr_accessor :complete + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -109,18 +131,17 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - allowed_values = ["placed", "approved", "delivered"] - if @status && !allowed_values.include?(@status) - return false - end + status_validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) + return false unless status_validator.valid?(@status) + return true end # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) - allowed_values = ["placed", "approved", "delivered"] - if status && !allowed_values.include?(status) - fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 81330cf5c56..f499ba759db 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -39,6 +39,28 @@ module Petstore # pet status in the store attr_accessor :status + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -111,26 +133,19 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if @name.nil? - return false - end - - if @photo_urls.nil? - return false - end - - allowed_values = ["available", "pending", "sold"] - if @status && !allowed_values.include?(@status) - return false - end + return false if @name.nil? + return false if @photo_urls.nil? + status_validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"]) + return false unless status_validator.valid?(@status) + return true end # Custom attribute writer method checking allowed values (enum). # @param [Object] status Object to be assigned def status=(status) - allowed_values = ["available", "pending", "sold"] - if status && !allowed_values.include?(status) - fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." + validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index d888b01cd05..8726b4bb23f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -28,6 +28,7 @@ module Petstore class SpecialModelName attr_accessor :special_property_name + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -66,6 +67,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index bc587aabb83..72583dfb24c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -30,6 +30,7 @@ module Petstore attr_accessor :name + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -74,6 +75,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index fa311a5b123..d92a6dfdf13 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -43,6 +43,7 @@ module Petstore # User Status attr_accessor :user_status + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -123,6 +124,7 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb b/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb index 016b86fd8af..1535c7cb4ec 100644 --- a/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb +++ b/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/animal_spec.rb b/samples/client/petstore/ruby/spec/models/animal_spec.rb index 3f98b0f7b84..5c4f8dc0e69 100644 --- a/samples/client/petstore/ruby/spec/models/animal_spec.rb +++ b/samples/client/petstore/ruby/spec/models/animal_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -42,5 +42,11 @@ describe 'Animal' do end end + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + end diff --git a/samples/client/petstore/ruby/spec/models/api_response_spec.rb b/samples/client/petstore/ruby/spec/models/api_response_spec.rb index 67b0cbe1a03..18ab87bf551 100644 --- a/samples/client/petstore/ruby/spec/models/api_response_spec.rb +++ b/samples/client/petstore/ruby/spec/models/api_response_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/cat_spec.rb b/samples/client/petstore/ruby/spec/models/cat_spec.rb index 97ae668ea3b..86d600213b3 100644 --- a/samples/client/petstore/ruby/spec/models/cat_spec.rb +++ b/samples/client/petstore/ruby/spec/models/cat_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -42,6 +42,12 @@ describe 'Cat' do end end + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + describe 'test attribute "declawed"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers diff --git a/samples/client/petstore/ruby/spec/models/category_spec.rb b/samples/client/petstore/ruby/spec/models/category_spec.rb index 1481358afdc..021de250efc 100644 --- a/samples/client/petstore/ruby/spec/models/category_spec.rb +++ b/samples/client/petstore/ruby/spec/models/category_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/dog_spec.rb b/samples/client/petstore/ruby/spec/models/dog_spec.rb index e3eb4be12fc..10a5b831f25 100644 --- a/samples/client/petstore/ruby/spec/models/dog_spec.rb +++ b/samples/client/petstore/ruby/spec/models/dog_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -42,6 +42,12 @@ describe 'Dog' do end end + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + describe 'test attribute "breed"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers diff --git a/samples/client/petstore/ruby/spec/models/enum_class_spec.rb b/samples/client/petstore/ruby/spec/models/enum_class_spec.rb index b8610d74a1b..02fe0a113fe 100644 --- a/samples/client/petstore/ruby/spec/models/enum_class_spec.rb +++ b/samples/client/petstore/ruby/spec/models/enum_class_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/enum_test_spec.rb b/samples/client/petstore/ruby/spec/models/enum_test_spec.rb index 91941d8a50d..f85c15564f1 100644 --- a/samples/client/petstore/ruby/spec/models/enum_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/enum_test_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -38,19 +38,28 @@ describe 'EnumTest' do end describe 'test attribute "enum_string"' do it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["UPPER", "lower"]) + validator.allowable_values.each do |value| + expect { @instance.enum_string = value }.not_to raise_error + end end end describe 'test attribute "enum_integer"' do it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + validator = Petstore::EnumTest::EnumAttributeValidator.new('Integer', ["1", "-1"]) + validator.allowable_values.each do |value| + expect { @instance.enum_integer = value }.not_to raise_error + end end end describe 'test attribute "enum_number"' do it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + validator = Petstore::EnumTest::EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) + validator.allowable_values.each do |value| + expect { @instance.enum_number = value }.not_to raise_error + end end end diff --git a/samples/client/petstore/ruby/spec/models/format_test_spec.rb b/samples/client/petstore/ruby/spec/models/format_test_spec.rb index e7a81fe537c..fd6cf6c0381 100644 --- a/samples/client/petstore/ruby/spec/models/format_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/format_test_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/model_200_response_spec.rb b/samples/client/petstore/ruby/spec/models/model_200_response_spec.rb index 8b8879105d0..b986604e1ef 100644 --- a/samples/client/petstore/ruby/spec/models/model_200_response_spec.rb +++ b/samples/client/petstore/ruby/spec/models/model_200_response_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/model_return_spec.rb b/samples/client/petstore/ruby/spec/models/model_return_spec.rb index 5a80c97542b..d21f4f1ed3e 100644 --- a/samples/client/petstore/ruby/spec/models/model_return_spec.rb +++ b/samples/client/petstore/ruby/spec/models/model_return_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/name_spec.rb b/samples/client/petstore/ruby/spec/models/name_spec.rb index 03a9c69ece1..5ad2a851827 100644 --- a/samples/client/petstore/ruby/spec/models/name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/name_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -54,5 +54,11 @@ describe 'Name' do end end + describe 'test attribute "_123_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + end diff --git a/samples/client/petstore/ruby/spec/models/order_spec.rb b/samples/client/petstore/ruby/spec/models/order_spec.rb index 73bd5c082fd..008d226ce6e 100644 --- a/samples/client/petstore/ruby/spec/models/order_spec.rb +++ b/samples/client/petstore/ruby/spec/models/order_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -62,7 +62,10 @@ describe 'Order' do describe 'test attribute "status"' do it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) + validator.allowable_values.each do |value| + expect { @instance.status = value }.not_to raise_error + end end end diff --git a/samples/client/petstore/ruby/spec/models/pet_spec.rb b/samples/client/petstore/ruby/spec/models/pet_spec.rb index 9911ced1366..72780cf80c9 100644 --- a/samples/client/petstore/ruby/spec/models/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/models/pet_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io @@ -68,7 +68,10 @@ describe 'Pet' do describe 'test attribute "status"' do it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["available", "pending", "sold"]) + validator.allowable_values.each do |value| + expect { @instance.status = value }.not_to raise_error + end end end diff --git a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb index cd93568e8f9..5b10f4c8f9f 100644 --- a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/tag_spec.rb b/samples/client/petstore/ruby/spec/models/tag_spec.rb index 68b77e026b1..c6a5a954b7e 100644 --- a/samples/client/petstore/ruby/spec/models/tag_spec.rb +++ b/samples/client/petstore/ruby/spec/models/tag_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io diff --git a/samples/client/petstore/ruby/spec/models/user_spec.rb b/samples/client/petstore/ruby/spec/models/user_spec.rb index fc510605b5c..ae780d5d656 100644 --- a/samples/client/petstore/ruby/spec/models/user_spec.rb +++ b/samples/client/petstore/ruby/spec/models/user_spec.rb @@ -1,7 +1,7 @@ =begin Swagger Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io