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}} {{#vars}}
describe 'test attribute "{{{name}}}"' do describe 'test attribute "{{{name}}}"' do
it 'should work' 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 # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
{{/isEnum}}
end end
end end

View File

@ -4,6 +4,30 @@
attr_accessor :{{{name}}} attr_accessor :{{{name}}}
{{/vars}} {{/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. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -53,13 +77,6 @@
# @return Array for valid properies with the reasons # @return Array for valid properies with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new 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}} {{#hasValidation}}
if @{{{name}}}.nil? if @{{{name}}}.nil?
fail ArgumentError, "{{{name}}} cannot be nil" fail ArgumentError, "{{{name}}} cannot be nil"
@ -104,50 +121,31 @@
def valid? def valid?
{{#vars}} {{#vars}}
{{#required}} {{#required}}
if @{{{name}}}.nil? return false if @{{{name}}}.nil?
return false
end
{{/required}} {{/required}}
{{#isEnum}} {{#isEnum}}
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] {{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
if @{{{name}}} && !allowed_values.include?(@{{{name}}}) return false unless {{{name}}}_validator.valid?(@{{{name}}})
return false
end
{{/isEnum}} {{/isEnum}}
{{#hasValidation}} {{#hasValidation}}
{{#minLength}} {{#minLength}}
if @{{{name}}}.to_s.length > {{{maxLength}}} return false if @{{{name}}}.to_s.length > {{{maxLength}}}
return false
end
{{/minLength}} {{/minLength}}
{{#maxLength}} {{#maxLength}}
if @{{{name}}}.to_s.length < {{{minLength}}} return false if @{{{name}}}.to_s.length < {{{minLength}}}
return false
end
{{/maxLength}} {{/maxLength}}
{{#maximum}} {{#maximum}}
if @{{{name}}} > {{{maximum}}} return false if @{{{name}}} > {{{maximum}}}
return false
end
{{/maximum}} {{/maximum}}
{{#minimum}} {{#minimum}}
if @{{{name}}} < {{{minimum}}} return false if @{{{name}}} < {{{minimum}}}
return false
end
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if @{{{name}}} !~ Regexp.new({{{pattern}}}) return false if @{{{name}}} !~ Regexp.new({{{pattern}}})
return false
end
{{/pattern}} {{/pattern}}
{{/hasValidation}} {{/hasValidation}}
{{/vars}} {{/vars}}
return true
end end
{{#vars}} {{#vars}}
@ -155,9 +153,9 @@
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] {{{name}}} Object to be assigned # @param [Object] {{{name}}} Object to be assigned
def {{{name}}}=({{{name}}}) def {{{name}}}=({{{name}}})
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
if {{{name}}} && !allowed_values.include?({{{name}}}) unless validator.valid?({{{name}}})
fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{validator.allowable_values}."
end end
@{{{name}}} = {{{name}}} @{{{name}}} = {{{name}}}
end end

View File

@ -30,6 +30,7 @@ module Petstore
attr_accessor :color attr_accessor :color
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -76,10 +77,8 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @class_name.nil? return false if @class_name.nil?
return false return true
end
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -26,6 +26,7 @@ require 'date'
module Petstore module Petstore
class AnimalFarm class AnimalFarm
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -58,6 +59,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -32,6 +32,7 @@ module Petstore
attr_accessor :message attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -82,6 +83,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -32,6 +32,7 @@ module Petstore
attr_accessor :declawed attr_accessor :declawed
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -84,10 +85,8 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @class_name.nil? return false if @class_name.nil?
return false return true
end
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -30,6 +30,7 @@ module Petstore
attr_accessor :name attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -74,6 +75,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -32,6 +32,7 @@ module Petstore
attr_accessor :breed attr_accessor :breed
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -84,10 +85,8 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @class_name.nil? return false if @class_name.nil?
return false return true
end
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -32,6 +32,28 @@ module Petstore
attr_accessor :enum_number 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. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -82,26 +104,21 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
allowed_values = ["UPPER", "lower"] enum_string_validator = EnumAttributeValidator.new('String', ["UPPER", "lower"])
if @enum_string && !allowed_values.include?(@enum_string) return false unless enum_string_validator.valid?(@enum_string)
return false enum_integer_validator = EnumAttributeValidator.new('Integer', ["1", "-1"])
end return false unless enum_integer_validator.valid?(@enum_integer)
allowed_values = ["1", "-1"] enum_number_validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"])
if @enum_integer && !allowed_values.include?(@enum_integer) return false unless enum_number_validator.valid?(@enum_number)
return false return true
end
allowed_values = ["1.1", "-1.2"]
if @enum_number && !allowed_values.include?(@enum_number)
return false
end
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_string Object to be assigned # @param [Object] enum_string Object to be assigned
def enum_string=(enum_string) def enum_string=(enum_string)
allowed_values = ["UPPER", "lower"] validator = EnumAttributeValidator.new('String', ["UPPER", "lower"])
if enum_string && !allowed_values.include?(enum_string) unless validator.valid?(enum_string)
fail ArgumentError, "invalid value for 'enum_string', must be one of #{allowed_values}." fail ArgumentError, "invalid value for 'enum_string', must be one of #{validator.allowable_values}."
end end
@enum_string = enum_string @enum_string = enum_string
end end
@ -109,9 +126,9 @@ module Petstore
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_integer Object to be assigned # @param [Object] enum_integer Object to be assigned
def enum_integer=(enum_integer) def enum_integer=(enum_integer)
allowed_values = ["1", "-1"] validator = EnumAttributeValidator.new('Integer', ["1", "-1"])
if enum_integer && !allowed_values.include?(enum_integer) unless validator.valid?(enum_integer)
fail ArgumentError, "invalid value for 'enum_integer', must be one of #{allowed_values}." fail ArgumentError, "invalid value for 'enum_integer', must be one of #{validator.allowable_values}."
end end
@enum_integer = enum_integer @enum_integer = enum_integer
end end
@ -119,9 +136,9 @@ module Petstore
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_number Object to be assigned # @param [Object] enum_number Object to be assigned
def enum_number=(enum_number) def enum_number=(enum_number)
allowed_values = ["1.1", "-1.2"] validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"])
if enum_number && !allowed_values.include?(enum_number) unless validator.valid?(enum_number)
fail ArgumentError, "invalid value for 'enum_number', must be one of #{allowed_values}." fail ArgumentError, "invalid value for 'enum_number', must be one of #{validator.allowable_values}."
end end
@enum_number = enum_number @enum_number = enum_number
end end

View File

@ -52,6 +52,7 @@ module Petstore
attr_accessor :password attr_accessor :password
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -162,74 +163,24 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @integer > 100.0 return false if @integer > 100.0
return false return false if @integer < 10.0
end return false if @int32 > 200.0
return false if @int32 < 20.0
if @integer < 10.0 return false if @number.nil?
return false return false if @number > 543.2
end return false if @number < 32.1
return false if @float > 987.6
if @int32 > 200.0 return false if @float < 54.3
return false return false if @double > 123.4
end return false if @double < 67.8
return false if @string !~ Regexp.new(/[a-z]/i)
if @int32 < 20.0 return false if @byte.nil?
return false return false if @date.nil?
end return false if @password.nil?
return false if @password.to_s.length > 64
if @number.nil? return false if @password.to_s.length < 10
return false return true
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
end end
# Custom attribute writer method with validation # Custom attribute writer method with validation

View File

@ -28,6 +28,7 @@ module Petstore
class Model200Response class Model200Response
attr_accessor :name attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -66,6 +67,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -28,6 +28,7 @@ module Petstore
class ModelReturn class ModelReturn
attr_accessor :_return attr_accessor :_return
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -66,6 +67,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -34,6 +34,7 @@ module Petstore
attr_accessor :_123_number attr_accessor :_123_number
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -90,10 +91,8 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @name.nil? return false if @name.nil?
return false return true
end
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -39,6 +39,28 @@ module Petstore
attr_accessor :complete 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. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -109,18 +131,17 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
allowed_values = ["placed", "approved", "delivered"] status_validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"])
if @status && !allowed_values.include?(@status) return false unless status_validator.valid?(@status)
return false return true
end
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned # @param [Object] status Object to be assigned
def status=(status) def status=(status)
allowed_values = ["placed", "approved", "delivered"] validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"])
if status && !allowed_values.include?(status) unless validator.valid?(status)
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}."
end end
@status = status @status = status
end end

View File

@ -39,6 +39,28 @@ module Petstore
# pet status in the store # pet status in the store
attr_accessor :status 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. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -111,26 +133,19 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
if @name.nil? return false if @name.nil?
return false return false if @photo_urls.nil?
end status_validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"])
return false unless status_validator.valid?(@status)
if @photo_urls.nil? return true
return false
end
allowed_values = ["available", "pending", "sold"]
if @status && !allowed_values.include?(@status)
return false
end
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned # @param [Object] status Object to be assigned
def status=(status) def status=(status)
allowed_values = ["available", "pending", "sold"] validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"])
if status && !allowed_values.include?(status) unless validator.valid?(status)
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}."
end end
@status = status @status = status
end end

View File

@ -28,6 +28,7 @@ module Petstore
class SpecialModelName class SpecialModelName
attr_accessor :special_property_name attr_accessor :special_property_name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -66,6 +67,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -30,6 +30,7 @@ module Petstore
attr_accessor :name attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -74,6 +75,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -43,6 +43,7 @@ module Petstore
# User Status # User Status
attr_accessor :user_status attr_accessor :user_status
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -123,6 +124,7 @@ module Petstore
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -42,5 +42,11 @@ describe 'Animal' do
end end
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 end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -42,6 +42,12 @@ describe 'Cat' do
end end
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 describe 'test attribute "declawed"' do
it 'should work' do it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -42,6 +42,12 @@ describe 'Dog' do
end end
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 describe 'test attribute "breed"' do
it 'should work' do it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -38,19 +38,28 @@ describe 'EnumTest' do
end end
describe 'test attribute "enum_string"' do describe 'test attribute "enum_string"' do
it 'should work' 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
end end
describe 'test attribute "enum_integer"' do describe 'test attribute "enum_integer"' do
it 'should work' 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
end end
describe 'test attribute "enum_number"' do describe 'test attribute "enum_number"' do
it 'should work' 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
end end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -54,5 +54,11 @@ describe 'Name' do
end end
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 end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -62,7 +62,10 @@ describe 'Order' do
describe 'test attribute "status"' do describe 'test attribute "status"' do
it 'should work' 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
end end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -68,7 +68,10 @@ describe 'Pet' do
describe 'test attribute "status"' do describe 'test attribute "status"' do
it 'should work' 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
end end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore 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 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io