Merge branch 'feature/ruby_enum_support2' of https://github.com/zlx/swagger-codegen into zlx-feature/ruby_enum_support2

Conflicts:
	samples/client/petstore/ruby/README.md
	samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb
	samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb
	samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb
This commit is contained in:
wing328 2016-05-26 17:20:49 +08:00
commit aeaf60713f
35 changed files with 248 additions and 187 deletions

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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