mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
regenerate ruby client sample
This commit is contained in:
parent
942b015c8f
commit
a9b8150442
23
samples/client/petstore/ruby/.swagger-codegen-ignore
Normal file
23
samples/client/petstore/ruby/.swagger-codegen-ignore
Normal file
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-05-11T16:13:11.464+08:00
|
||||
- Build date: 2016-05-23T20:51:09.022+08:00
|
||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||
|
||||
## Installation
|
||||
@ -116,6 +116,7 @@ Class | Method | HTTP request | Description
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [Petstore::AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [Petstore::Animal](docs/Animal.md)
|
||||
- [Petstore::AnimalFarm](docs/AnimalFarm.md)
|
||||
- [Petstore::ApiResponse](docs/ApiResponse.md)
|
||||
@ -125,11 +126,13 @@ Class | Method | HTTP request | Description
|
||||
- [Petstore::EnumClass](docs/EnumClass.md)
|
||||
- [Petstore::EnumTest](docs/EnumTest.md)
|
||||
- [Petstore::FormatTest](docs/FormatTest.md)
|
||||
- [Petstore::MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Petstore::Model200Response](docs/Model200Response.md)
|
||||
- [Petstore::ModelReturn](docs/ModelReturn.md)
|
||||
- [Petstore::Name](docs/Name.md)
|
||||
- [Petstore::Order](docs/Order.md)
|
||||
- [Petstore::Pet](docs/Pet.md)
|
||||
- [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [Petstore::SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Petstore::Tag](docs/Tag.md)
|
||||
- [Petstore::User](docs/User.md)
|
||||
|
@ -0,0 +1,7 @@
|
||||
# Petstore::AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
|
@ -75,8 +75,8 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8
|
||||
- **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# Petstore::MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **String** | | [optional]
|
||||
**date_time** | **DateTime** | | [optional]
|
||||
|
||||
|
9
samples/client/petstore/ruby/docs/ReadOnlyFirst.md
Normal file
9
samples/client/petstore/ruby/docs/ReadOnlyFirst.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Petstore::ReadOnlyFirst
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional]
|
||||
**baz** | **String** | | [optional]
|
||||
|
||||
|
@ -21,6 +21,7 @@ require 'petstore/version'
|
||||
require 'petstore/configuration'
|
||||
|
||||
# Models
|
||||
require 'petstore/models/additional_properties_class'
|
||||
require 'petstore/models/animal'
|
||||
require 'petstore/models/animal_farm'
|
||||
require 'petstore/models/api_response'
|
||||
@ -30,11 +31,13 @@ require 'petstore/models/dog'
|
||||
require 'petstore/models/enum_class'
|
||||
require 'petstore/models/enum_test'
|
||||
require 'petstore/models/format_test'
|
||||
require 'petstore/models/mixed_properties_and_additional_properties_class'
|
||||
require 'petstore/models/model_200_response'
|
||||
require 'petstore/models/model_return'
|
||||
require 'petstore/models/name'
|
||||
require 'petstore/models/order'
|
||||
require 'petstore/models/pet'
|
||||
require 'petstore/models/read_only_first'
|
||||
require 'petstore/models/special_model_name'
|
||||
require 'petstore/models/tag'
|
||||
require 'petstore/models/user'
|
||||
|
@ -131,11 +131,11 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
local_header_accept = ['application/xml', 'application/json']
|
||||
local_header_accept = ['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
local_header_content_type = []
|
||||
local_header_content_type = ['application/xml; charset=utf-8', 'application/json; charset=utf-8']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
|
@ -0,0 +1,183 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class AdditionalPropertiesClass
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.swagger_types
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
return unless attributes.is_a?(Hash)
|
||||
|
||||
# convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
||||
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properies with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
return invalid_properties
|
||||
end
|
||||
|
||||
# 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.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Fixnum] Hash code
|
||||
def hash
|
||||
[].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.swagger_types.each_pair do |key, type|
|
||||
if type =~ /^Array<(.*)>/i
|
||||
# check to ensure the input is an array given that the the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :BOOLEAN
|
||||
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
temp_model = Petstore.const_get(type).new
|
||||
temp_model.build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map{ |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -17,11 +17,13 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Animal
|
||||
attr_accessor :class_name
|
||||
|
||||
attr_accessor :color
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -68,10 +70,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.
|
||||
@ -200,4 +200,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,7 +17,9 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class AnimalFarm
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -50,6 +52,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.
|
||||
@ -176,4 +179,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class ApiResponse
|
||||
attr_accessor :code
|
||||
|
||||
@ -24,6 +25,7 @@ module Petstore
|
||||
|
||||
attr_accessor :message
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -74,6 +76,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.
|
||||
@ -203,4 +206,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Cat
|
||||
attr_accessor :class_name
|
||||
|
||||
@ -24,6 +25,7 @@ module Petstore
|
||||
|
||||
attr_accessor :declawed
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -76,10 +78,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.
|
||||
@ -209,4 +209,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,11 +17,13 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Category
|
||||
attr_accessor :id
|
||||
|
||||
attr_accessor :name
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -66,6 +68,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.
|
||||
@ -194,4 +197,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Dog
|
||||
attr_accessor :class_name
|
||||
|
||||
@ -24,6 +25,7 @@ module Petstore
|
||||
|
||||
attr_accessor :breed
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -76,10 +78,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.
|
||||
@ -209,4 +209,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -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. Special characters: \" \\
|
||||
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
|
||||
@ -18,9 +18,10 @@ require 'date'
|
||||
|
||||
module Petstore
|
||||
class EnumClass
|
||||
|
||||
ABC = "_ab\"c".freeze
|
||||
|
||||
ABC = "_abc".freeze
|
||||
EFG = "-efg".freeze
|
||||
XYZ = "(xy'z)".freeze
|
||||
XYZ = "(xyz)".freeze
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class EnumTest
|
||||
attr_accessor :enum_string
|
||||
|
||||
@ -24,6 +25,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
|
||||
{
|
||||
@ -74,26 +97,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
|
||||
@ -101,9 +119,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
|
||||
@ -111,9 +129,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
|
||||
@ -245,4 +263,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class FormatTest
|
||||
attr_accessor :integer
|
||||
|
||||
@ -44,6 +45,7 @@ module Petstore
|
||||
|
||||
attr_accessor :password
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -154,74 +156,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
|
||||
@ -483,4 +435,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,201 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class MixedPropertiesAndAdditionalPropertiesClass
|
||||
attr_accessor :uuid
|
||||
|
||||
attr_accessor :date_time
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'uuid' => :'uuid',
|
||||
:'date_time' => :'dateTime'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.swagger_types
|
||||
{
|
||||
:'uuid' => :'String',
|
||||
:'date_time' => :'DateTime'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
return unless attributes.is_a?(Hash)
|
||||
|
||||
# convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
||||
|
||||
if attributes.has_key?(:'uuid')
|
||||
self.uuid = attributes[:'uuid']
|
||||
end
|
||||
|
||||
if attributes.has_key?(:'dateTime')
|
||||
self.date_time = attributes[:'dateTime']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properies with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
return invalid_properties
|
||||
end
|
||||
|
||||
# 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.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
uuid == o.uuid &&
|
||||
date_time == o.date_time
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Fixnum] Hash code
|
||||
def hash
|
||||
[uuid, date_time].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.swagger_types.each_pair do |key, type|
|
||||
if type =~ /^Array<(.*)>/i
|
||||
# check to ensure the input is an array given that the the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :BOOLEAN
|
||||
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
temp_model = Petstore.const_get(type).new
|
||||
temp_model.build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map{ |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -21,6 +21,7 @@ module Petstore
|
||||
class Model200Response
|
||||
attr_accessor :name
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -59,6 +60,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.
|
||||
@ -186,4 +188,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -21,6 +21,7 @@ module Petstore
|
||||
class ModelReturn
|
||||
attr_accessor :_return
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -59,6 +60,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.
|
||||
@ -186,4 +188,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -27,6 +27,7 @@ module Petstore
|
||||
|
||||
attr_accessor :_123_number
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -83,10 +84,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.
|
||||
@ -217,4 +216,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Order
|
||||
attr_accessor :id
|
||||
|
||||
@ -31,6 +32,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
|
||||
{
|
||||
@ -101,18 +124,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
|
||||
@ -247,4 +269,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Pet
|
||||
attr_accessor :id
|
||||
|
||||
@ -31,6 +32,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
|
||||
{
|
||||
@ -103,26 +126,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
|
||||
@ -257,4 +273,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,201 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class ReadOnlyFirst
|
||||
attr_accessor :bar
|
||||
|
||||
attr_accessor :baz
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'bar' => :'bar',
|
||||
:'baz' => :'baz'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.swagger_types
|
||||
{
|
||||
:'bar' => :'String',
|
||||
:'baz' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
return unless attributes.is_a?(Hash)
|
||||
|
||||
# convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
||||
|
||||
if attributes.has_key?(:'bar')
|
||||
self.bar = attributes[:'bar']
|
||||
end
|
||||
|
||||
if attributes.has_key?(:'baz')
|
||||
self.baz = attributes[:'baz']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properies with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
return invalid_properties
|
||||
end
|
||||
|
||||
# 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.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
bar == o.bar &&
|
||||
baz == o.baz
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Fixnum] Hash code
|
||||
def hash
|
||||
[bar, baz].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.swagger_types.each_pair do |key, type|
|
||||
if type =~ /^Array<(.*)>/i
|
||||
# check to ensure the input is an array given that the the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :BOOLEAN
|
||||
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
temp_model = Petstore.const_get(type).new
|
||||
temp_model.build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map{ |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -17,9 +17,11 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class SpecialModelName
|
||||
attr_accessor :special_property_name
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -58,6 +60,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.
|
||||
@ -185,4 +188,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,11 +17,13 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class Tag
|
||||
attr_accessor :id
|
||||
|
||||
attr_accessor :name
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -66,6 +68,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.
|
||||
@ -194,4 +197,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
|
||||
class User
|
||||
attr_accessor :id
|
||||
|
||||
@ -35,6 +36,7 @@ module Petstore
|
||||
# User Status
|
||||
attr_accessor :user_status
|
||||
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
@ -115,6 +117,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.
|
||||
@ -249,4 +252,5 @@ module Petstore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,40 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'spec_helper'
|
||||
require 'json'
|
||||
require 'date'
|
||||
|
||||
# Unit tests for Petstore::AdditionalPropertiesClass
|
||||
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||
# Please update as you see appropriate
|
||||
describe 'AdditionalPropertiesClass' do
|
||||
before do
|
||||
# run before each test
|
||||
@instance = Petstore::AdditionalPropertiesClass.new
|
||||
end
|
||||
|
||||
after do
|
||||
# run after each test
|
||||
end
|
||||
|
||||
describe 'test an instance of AdditionalPropertiesClass' do
|
||||
it 'should create an instact of AdditionalPropertiesClass' do
|
||||
expect(@instance).to be_instance_of(Petstore::AdditionalPropertiesClass)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,52 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'spec_helper'
|
||||
require 'json'
|
||||
require 'date'
|
||||
|
||||
# Unit tests for Petstore::MixedPropertiesAndAdditionalPropertiesClass
|
||||
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||
# Please update as you see appropriate
|
||||
describe 'MixedPropertiesAndAdditionalPropertiesClass' do
|
||||
before do
|
||||
# run before each test
|
||||
@instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new
|
||||
end
|
||||
|
||||
after do
|
||||
# run after each test
|
||||
end
|
||||
|
||||
describe 'test an instance of MixedPropertiesAndAdditionalPropertiesClass' do
|
||||
it 'should create an instact of MixedPropertiesAndAdditionalPropertiesClass' do
|
||||
expect(@instance).to be_instance_of(Petstore::MixedPropertiesAndAdditionalPropertiesClass)
|
||||
end
|
||||
end
|
||||
describe 'test attribute "uuid"' do
|
||||
it 'should work' do
|
||||
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
||||
end
|
||||
end
|
||||
|
||||
describe 'test attribute "date_time"' do
|
||||
it 'should work' do
|
||||
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,52 @@
|
||||
=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. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'spec_helper'
|
||||
require 'json'
|
||||
require 'date'
|
||||
|
||||
# Unit tests for Petstore::ReadOnlyFirst
|
||||
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
||||
# Please update as you see appropriate
|
||||
describe 'ReadOnlyFirst' do
|
||||
before do
|
||||
# run before each test
|
||||
@instance = Petstore::ReadOnlyFirst.new
|
||||
end
|
||||
|
||||
after do
|
||||
# run after each test
|
||||
end
|
||||
|
||||
describe 'test an instance of ReadOnlyFirst' do
|
||||
it 'should create an instact of ReadOnlyFirst' do
|
||||
expect(@instance).to be_instance_of(Petstore::ReadOnlyFirst)
|
||||
end
|
||||
end
|
||||
describe 'test attribute "bar"' do
|
||||
it 'should work' do
|
||||
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
||||
end
|
||||
end
|
||||
|
||||
describe 'test attribute "baz"' do
|
||||
it 'should work' do
|
||||
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user