forked from loafle/openapi-generator-original
[crystal-lang] Various fixes for Crystal client (#21011)
* fix(crystal): fix typos in Crystal templates * fix(crystal): various fixes for partial_oneof_module.mustache Crystal template 1. `class << self` doesn't exist in Crystal, you must prefix class methods with `self.` 2. use double quotes for String litterals (simple quotes are for Char litterals) 3. global `private` keyword doesn't exist in Crystal, you must prefix private methods with `private` 4. you must specify types when using `each_with_object({})` * fix(crystal): add isKeyInCookie in Crystal configuration.mustache * fix(crystal): wrap `rescue` in a `begin` * fix(crystal): use Spectator shard to run tests (`described_class` is not available in Crystal std lib) * fix(crystal): dry tests * fix(crystal): enable some API tests, mark others as pending * fix(crystal): update samples * fix(crystal): update sample app specs * fix(crystal): install development dependencies
This commit is contained in:
parent
c761f11a18
commit
c4a6c4a542
@ -87,7 +87,7 @@ module {{moduleName}}
|
|||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if @api_client.config.client_side_validation && {{^required}}!{{{paramName}}}.nil? && {{/required}}{{{paramName}}}.to_s.size < {{{minLength}}}
|
if @api_client.config.client_side_validation && {{^required}}!{{{paramName}}}.nil? && {{/required}}{{{paramName}}}.to_s.size < {{{minLength}}}
|
||||||
raise ArgumentError.new("invalid value for \"{{{paramName}}}\" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.")
|
raise ArgumentError.new("invalid value for \"{{{paramName}}}\" when calling {{classname}}.{{operationId}}, the character length must be greater than or equal to {{{minLength}}}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for {{moduleName}}::{{classname}}
|
# Unit tests for {{moduleName}}::{{classname}}
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
{{#operations}}describe "{{classname}}" do
|
{{#operations}}
|
||||||
|
Spectator.describe "{{classname}}" do
|
||||||
describe "test an instance of {{classname}}" do
|
describe "test an instance of {{classname}}" do
|
||||||
it "should create an instance of {{classname}}" do
|
it "should create an instance of {{classname}}" do
|
||||||
api_instance = {{moduleName}}::{{classname}}.new
|
api_instance = {{moduleName}}::{{classname}}.new
|
||||||
# TODO expect(api_instance).to be_instance_of({{moduleName}}::{{classname}})
|
expect(api_instance).to be_instance_of({{moduleName}}::{{classname}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ require "time"
|
|||||||
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
||||||
{{/required}}{{/allParams}} # @return [{{{returnType}}}{{^returnType}}nil{{/returnType}}]
|
{{/required}}{{/allParams}} # @return [{{{returnType}}}{{^returnType}}nil{{/returnType}}]
|
||||||
describe "{{operationId}} test" do
|
describe "{{operationId}} test" do
|
||||||
it "should work" do
|
skip "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -214,7 +214,7 @@ module {{moduleName}}
|
|||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
"{{name}}" => {
|
"{{name}}" => {
|
||||||
type: "api_key",
|
type: "api_key",
|
||||||
in: {{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}},
|
in: {{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}{{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}},
|
||||||
key: "{{keyParamName}}",
|
key: "{{keyParamName}}",
|
||||||
value: api_key_with_prefix(:{{keyParamName}})
|
value: api_key_with_prefix(:{{keyParamName}})
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe {{moduleName}}::Configuration do
|
Spectator.describe {{moduleName}}::Configuration do
|
||||||
let(:config) { {{moduleName}}::Configuration.default }
|
let(:config) { {{moduleName}}::Configuration.default }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for {{moduleName}}::{{classname}}
|
# Unit tests for {{moduleName}}::{{classname}}
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
describe {{moduleName}}::{{classname}} do
|
Spectator.describe {{moduleName}}::{{classname}} do
|
||||||
{{^oneOf}}
|
{{^oneOf}}
|
||||||
|
|
||||||
describe "test an instance of {{classname}}" do
|
describe "test an instance of {{classname}}" do
|
||||||
it "should create an instance of {{classname}}" do
|
skip "should create an instance of {{classname}}" do
|
||||||
#instance = {{moduleName}}::{{classname}}.new
|
#instance = {{moduleName}}::{{classname}}.new
|
||||||
#expect(instance).to be_instance_of({{moduleName}}::{{classname}})
|
#expect(instance).to be_instance_of({{moduleName}}::{{classname}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
describe "test attribute '{{{name}}}'" do
|
describe "test attribute '{{{name}}}'" do
|
||||||
it "should work" do
|
skip "should work" do
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
# validator = Petstore::EnumTest::EnumAttributeValidator.new("{{{dataType}}}", [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
|
# validator = Petstore::EnumTest::EnumAttributeValidator.new("{{{dataType}}}", [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
|
||||||
@ -65,7 +63,7 @@ describe {{moduleName}}::{{classname}} do
|
|||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
{{/discriminator}}
|
{{/discriminator}}
|
||||||
describe ".build" do
|
describe ".build" do
|
||||||
it "returns the correct model" do
|
skip "returns the correct model" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{{/-first}}
|
{{/-first}}
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size < {{{minLength}}}
|
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size < {{{minLength}}}
|
||||||
invalid_properties.push("invalid value for \"{{{name}}}\", the character length must be great than or equal to {{{minLength}}}.")
|
invalid_properties.push("invalid value for \"{{{name}}}\", the character length must be greater than or equal to {{{minLength}}}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
@ -226,7 +226,7 @@
|
|||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.size < {{{minLength}}}
|
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.size < {{{minLength}}}
|
||||||
raise ArgumentError.new("invalid value for \"{{{name}}}\", the character length must be great than or equal to {{{minLength}}}.")
|
raise ArgumentError.new("invalid value for \"{{{name}}}\", the character length must be greater than or equal to {{{minLength}}}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
|
@ -2,106 +2,104 @@
|
|||||||
# {{{.}}}
|
# {{{.}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
module {{classname}}
|
module {{classname}}
|
||||||
class << self
|
{{#oneOf}}
|
||||||
{{#oneOf}}
|
{{#-first}}
|
||||||
{{#-first}}
|
# List of class defined in oneOf (OpenAPI v3)
|
||||||
# List of class defined in oneOf (OpenAPI v3)
|
def self.openapi_one_of
|
||||||
def openapi_one_of
|
[
|
||||||
[
|
{{/-first}}
|
||||||
{{/-first}}
|
:"{{{.}}}"{{^-last}},{{/-last}}
|
||||||
:'{{{.}}}'{{^-last}},{{/-last}}
|
{{#-last}}
|
||||||
{{#-last}}
|
]
|
||||||
]
|
end
|
||||||
end
|
|
||||||
|
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/oneOf}}
|
{{/oneOf}}
|
||||||
{{#discriminator}}
|
{{#discriminator}}
|
||||||
{{#propertyName}}
|
{{#propertyName}}
|
||||||
# Discriminator's property name (OpenAPI v3)
|
# Discriminator's property name (OpenAPI v3)
|
||||||
def openapi_discriminator_name
|
def self.openapi_discriminator_name
|
||||||
:'{{{.}}}'
|
:"{{{.}}}"
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/propertyName}}
|
{{/propertyName}}
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
{{#-first}}
|
{{#-first}}
|
||||||
# Discriminator's mapping (OpenAPI v3)
|
# Discriminator's mapping (OpenAPI v3)
|
||||||
def openapi_discriminator_mapping
|
def self.openapi_discriminator_mapping
|
||||||
{
|
{
|
||||||
{{/-first}}
|
{{/-first}}
|
||||||
:'{{{mappingName}}}' => :'{{{modelName}}}'{{^-last}},{{/-last}}
|
:"{{{mappingName}}}" => :"{{{modelName}}}"{{^-last}},{{/-last}}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
{{/discriminator}}
|
{{/discriminator}}
|
||||||
# Builds the object
|
# Builds the object
|
||||||
# @param [Mixed] Data to be matched against the list of oneOf items
|
# @param [Mixed] Data to be matched against the list of oneOf items
|
||||||
# @return [Object] Returns the model or the data itself
|
# @return [Object] Returns the model or the data itself
|
||||||
def build(data)
|
def self.build(data)
|
||||||
{{#discriminator}}
|
{{#discriminator}}
|
||||||
discriminator_value = data[openapi_discriminator_name]
|
discriminator_value = data[openapi_discriminator_name]
|
||||||
return nil unless discriminator_value
|
return nil unless discriminator_value
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
{{#-first}}
|
{{#-first}}
|
||||||
|
|
||||||
klass = openapi_discriminator_mapping[discriminator_value.to_sym]
|
klass = openapi_discriminator_mapping[discriminator_value.to_sym]
|
||||||
return nil unless klass
|
return nil unless klass
|
||||||
|
|
||||||
{{moduleName}}.const_get(klass).build_from_hash(data)
|
{{moduleName}}.const_get(klass).build_from_hash(data)
|
||||||
{{/-first}}
|
{{/-first}}
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
{{^mappedModels}}
|
{{^mappedModels}}
|
||||||
{{moduleName}}.const_get(discriminator_value).build_from_hash(data)
|
{{moduleName}}.const_get(discriminator_value).build_from_hash(data)
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
{{/discriminator}}
|
{{/discriminator}}
|
||||||
{{^discriminator}}
|
{{^discriminator}}
|
||||||
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
||||||
# Note:
|
# Note:
|
||||||
# - We do not attempt to check whether exactly one item matches.
|
# - We do not attempt to check whether exactly one item matches.
|
||||||
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
||||||
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
||||||
# - TODO: scalar values are de facto behaving as if they were nullable.
|
# - TODO: scalar values are de facto behaving as if they were nullable.
|
||||||
# - TODO: logging when debugging is set.
|
# - TODO: logging when debugging is set.
|
||||||
openapi_one_of.each do |klass|
|
openapi_one_of.each do |klass|
|
||||||
begin
|
begin
|
||||||
next if klass == :AnyType # "nullable: true"
|
next if klass == :AnyType # "nullable: true"
|
||||||
typed_data = find_and_cast_into_type(klass, data)
|
typed_data = find_and_cast_into_type(klass, data)
|
||||||
return typed_data if typed_data
|
return typed_data if typed_data
|
||||||
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
openapi_one_of.includes?(:AnyType) ? data : nil
|
|
||||||
{{/discriminator}}
|
|
||||||
end
|
end
|
||||||
{{^discriminator}}
|
|
||||||
|
|
||||||
private
|
openapi_one_of.includes?(:AnyType) ? data : nil
|
||||||
|
{{/discriminator}}
|
||||||
|
end
|
||||||
|
{{^discriminator}}
|
||||||
|
|
||||||
SchemaMismatchError = Class.new(StandardError)
|
SchemaMismatchError = Class.new(StandardError)
|
||||||
|
|
||||||
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
||||||
def find_and_cast_into_type(klass, data)
|
private def self.find_and_cast_into_type(klass, data)
|
||||||
return if data.nil?
|
return if data.nil?
|
||||||
|
|
||||||
|
begin
|
||||||
case klass.to_s
|
case klass.to_s
|
||||||
when 'Boolean'
|
when "Boolean"
|
||||||
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
||||||
when 'Float'
|
when "Float"
|
||||||
return data if data.instance_of?(Float)
|
return data if data.instance_of?(Float)
|
||||||
when 'Integer'
|
when "Integer"
|
||||||
return data if data.instance_of?(Integer)
|
return data if data.instance_of?(Integer)
|
||||||
when 'Time'
|
when "Time"
|
||||||
return Time.parse(data)
|
return Time.parse(data)
|
||||||
when 'Date'
|
when "Date"
|
||||||
return Date.parse(data)
|
return Date.parse(data)
|
||||||
when 'String'
|
when "String"
|
||||||
return data if data.instance_of?(String)
|
return data if data.instance_of?(String)
|
||||||
when 'Object' # "type: object"
|
when "Object" # "type: object"
|
||||||
return data if data.instance_of?(Hash)
|
return data if data.instance_of?(Hash)
|
||||||
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
||||||
if data.instance_of?(Array)
|
if data.instance_of?(Array)
|
||||||
@ -111,7 +109,7 @@
|
|||||||
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
||||||
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
||||||
sub_type = Regexp.last_match[:sub_type]
|
sub_type = Regexp.last_match[:sub_type]
|
||||||
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
return data.each_with_object({} of String | Symbol => Bool | Float | Integer | Time | Date | String | Array | Hash) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
||||||
end
|
end
|
||||||
else # model
|
else # model
|
||||||
const = {{moduleName}}.const_get(klass)
|
const = {{moduleName}}.const_get(klass)
|
||||||
@ -132,6 +130,6 @@
|
|||||||
rescue
|
rescue
|
||||||
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
||||||
end
|
end
|
||||||
{{/discriminator}}
|
|
||||||
end
|
end
|
||||||
|
{{/discriminator}}
|
||||||
end
|
end
|
||||||
|
@ -16,5 +16,8 @@ development_dependencies:
|
|||||||
version: ~>1.5.0
|
version: ~>1.5.0
|
||||||
ameba:
|
ameba:
|
||||||
github: crystal-ameba/ameba
|
github: crystal-ameba/ameba
|
||||||
|
spectator:
|
||||||
|
gitlab: arctic-fox/spectator
|
||||||
|
version: ~> 0.12.0
|
||||||
|
|
||||||
license: {{{shardLicense}}}
|
license: {{{shardLicense}}}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
|
||||||
|
|
||||||
# load modules
|
# load modules
|
||||||
require "spec"
|
require "spectator"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "time"
|
||||||
require "../src/{{{shardName}}}"
|
require "../src/{{{shardName}}}"
|
||||||
|
|
||||||
def assert_compilation_error(path : String, message : String) : Nil
|
def assert_compilation_error(path : String, message : String) : Nil
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
<argument>install</argument>
|
<argument>install</argument>
|
||||||
<argument>--ignore-crystal-version</argument>
|
<argument>--ignore-crystal-version</argument>
|
||||||
<argument>--without-development</argument>
|
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
|
ameba:
|
||||||
|
git: https://github.com/crystal-ameba/ameba.git
|
||||||
|
version: 1.6.4
|
||||||
|
|
||||||
|
backtracer:
|
||||||
|
git: https://github.com/sija/backtracer.cr.git
|
||||||
|
version: 1.2.4
|
||||||
|
|
||||||
crest:
|
crest:
|
||||||
git: https://github.com/mamantoha/crest.git
|
git: https://github.com/mamantoha/crest.git
|
||||||
version: 1.3.13
|
version: 1.3.13
|
||||||
|
|
||||||
|
exception_page:
|
||||||
|
git: https://github.com/crystal-loot/exception_page.git
|
||||||
|
version: 0.4.1
|
||||||
|
|
||||||
http-client-digest_auth:
|
http-client-digest_auth:
|
||||||
git: https://github.com/mamantoha/http-client-digest_auth.git
|
git: https://github.com/mamantoha/http-client-digest_auth.git
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
@ -12,3 +24,15 @@ shards:
|
|||||||
git: https://github.com/mamantoha/http_proxy.git
|
git: https://github.com/mamantoha/http_proxy.git
|
||||||
version: 0.10.3
|
version: 0.10.3
|
||||||
|
|
||||||
|
kemal:
|
||||||
|
git: https://github.com/kemalcr/kemal.git
|
||||||
|
version: 1.5.0
|
||||||
|
|
||||||
|
radix:
|
||||||
|
git: https://github.com/luislavena/radix.git
|
||||||
|
version: 0.4.1
|
||||||
|
|
||||||
|
spectator:
|
||||||
|
git: https://gitlab.com/arctic-fox/spectator.git
|
||||||
|
version: 0.12.1
|
||||||
|
|
||||||
|
@ -16,5 +16,8 @@ development_dependencies:
|
|||||||
version: ~>1.5.0
|
version: ~>1.5.0
|
||||||
ameba:
|
ameba:
|
||||||
github: crystal-ameba/ameba
|
github: crystal-ameba/ameba
|
||||||
|
spectator:
|
||||||
|
gitlab: arctic-fox/spectator
|
||||||
|
version: ~> 0.12.0
|
||||||
|
|
||||||
license:
|
license:
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::FakeApi
|
# Unit tests for Petstore::FakeApi
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe "FakeApi" do
|
Spectator.describe "FakeApi" do
|
||||||
describe "test an instance of FakeApi" do
|
describe "test an instance of FakeApi" do
|
||||||
it "should create an instance of FakeApi" do
|
it "should create an instance of FakeApi" do
|
||||||
api_instance = Petstore::FakeApi.new
|
api_instance = Petstore::FakeApi.new
|
||||||
@ -37,5 +35,4 @@ describe "FakeApi" do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#OpenAPI Generator version: 5.0.1-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::PetApi
|
# Unit tests for Petstore::PetApi
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe "PetApi" do
|
Spectator.describe "PetApi" do
|
||||||
describe "test an instance of PetApi" do
|
describe "test an instance of PetApi" do
|
||||||
it "should create an instance of PetApi" do
|
it "should create an instance of PetApi" do
|
||||||
api_instance = Petstore::PetApi.new
|
api_instance = Petstore::PetApi.new
|
||||||
@ -45,12 +43,12 @@ describe "PetApi" do
|
|||||||
new_pet = Petstore::Pet.new(id: nil, category: nil, name: pet_name, photo_urls: Array(String).new, tags: nil, status: nil)
|
new_pet = Petstore::Pet.new(id: nil, category: nil, name: pet_name, photo_urls: Array(String).new, tags: nil, status: nil)
|
||||||
|
|
||||||
pet = api_instance.add_pet(new_pet)
|
pet = api_instance.add_pet(new_pet)
|
||||||
pet.id.should_not be_nil
|
expect(pet.id).to_not be_nil
|
||||||
pet.category.should be_nil
|
expect(pet.category).to be_nil
|
||||||
pet.name.should eq pet_name
|
expect(pet.name).to eq pet_name
|
||||||
pet.photo_urls.should eq Array(String).new
|
expect(pet.photo_urls).to eq Array(String).new
|
||||||
pet.status.should be_nil
|
expect(pet.status).to be_nil
|
||||||
pet.tags.should eq Array(Petstore::Tag).new
|
expect(pet.tags).to eq Array(Petstore::Tag).new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,12 +112,12 @@ describe "PetApi" do
|
|||||||
pet = api_instance.add_pet(new_pet)
|
pet = api_instance.add_pet(new_pet)
|
||||||
pet_id = pet.id.not_nil!
|
pet_id = pet.id.not_nil!
|
||||||
result = api_instance.get_pet_by_id(pet_id: pet_id)
|
result = api_instance.get_pet_by_id(pet_id: pet_id)
|
||||||
result.id.should eq pet_id
|
expect(result.id).to eq pet_id
|
||||||
result.category.should be_nil
|
expect(result.category).to be_nil
|
||||||
result.name.should eq "crystal"
|
expect(result.name).to eq "crystal"
|
||||||
result.photo_urls.should eq Array(String).new
|
expect(result.photo_urls).to eq Array(String).new
|
||||||
result.status.should be_nil
|
expect(result.status).to be_nil
|
||||||
result.tags.should eq Array(Petstore::Tag).new
|
expect(result.tags).to eq Array(Petstore::Tag).new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -159,5 +157,4 @@ describe "PetApi" do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::StoreApi
|
# Unit tests for Petstore::StoreApi
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe "StoreApi" do
|
Spectator.describe "StoreApi" do
|
||||||
describe "test an instance of StoreApi" do
|
describe "test an instance of StoreApi" do
|
||||||
it "should create an instance of StoreApi" do
|
it "should create an instance of StoreApi" do
|
||||||
api_instance = Petstore::StoreApi.new
|
api_instance = Petstore::StoreApi.new
|
||||||
@ -69,5 +67,4 @@ describe "StoreApi" do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::UserApi
|
# Unit tests for Petstore::UserApi
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe "UserApi" do
|
Spectator.describe "UserApi" do
|
||||||
describe "test an instance of UserApi" do
|
describe "test an instance of UserApi" do
|
||||||
it "should create an instance of UserApi" do
|
it "should create an instance of UserApi" do
|
||||||
api_instance = Petstore::UserApi.new
|
api_instance = Petstore::UserApi.new
|
||||||
@ -119,5 +117,4 @@ describe "UserApi" do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
describe Petstore::ApiClient do
|
Spectator.describe Petstore::ApiClient do
|
||||||
describe "#update_params_for_auth!" do
|
describe "#update_params_for_auth!" do
|
||||||
describe "oauth2" do
|
describe "oauth2" do
|
||||||
it "should add 'Authorization' to header" do
|
it "should add 'Authorization' to header" do
|
||||||
@ -13,8 +13,8 @@ describe Petstore::ApiClient do
|
|||||||
api_client = Petstore::ApiClient.new(config)
|
api_client = Petstore::ApiClient.new(config)
|
||||||
api_client.update_params_for_auth!(header_params, query_params, ["petstore_auth"])
|
api_client.update_params_for_auth!(header_params, query_params, ["petstore_auth"])
|
||||||
|
|
||||||
header_params["Authorization"].should eq "Bearer xxx"
|
expect(header_params["Authorization"]).to eq "Bearer xxx"
|
||||||
query_params.size.should eq 0
|
expect(query_params.size).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ describe Petstore::ApiClient do
|
|||||||
api_client = Petstore::ApiClient.new(config)
|
api_client = Petstore::ApiClient.new(config)
|
||||||
api_client.update_params_for_auth!(header_params, query_params, ["api_key"])
|
api_client.update_params_for_auth!(header_params, query_params, ["api_key"])
|
||||||
|
|
||||||
header_params["api_key"].should eq "xxx"
|
expect(header_params["api_key"]).to eq "xxx"
|
||||||
query_params.empty?.should be_true
|
expect(query_params.empty?).to be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ describe Petstore::ApiClient do
|
|||||||
api_client = Petstore::ApiClient.new(config)
|
api_client = Petstore::ApiClient.new(config)
|
||||||
api_client.update_params_for_auth!(header_params, query_params, ["api_key"])
|
api_client.update_params_for_auth!(header_params, query_params, ["api_key"])
|
||||||
|
|
||||||
header_params["api_key"].should eq "Token xxx"
|
expect(header_params["api_key"]).to eq "Token xxx"
|
||||||
query_params.empty?.should be_true
|
expect(query_params.empty?).to be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
describe Petstore::Configuration do
|
Spectator.describe Petstore::Configuration do
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
context "with block" do
|
context "with block" do
|
||||||
it "works" do
|
it "works" do
|
||||||
@ -8,7 +8,7 @@ describe Petstore::Configuration do
|
|||||||
config.username = "xxx"
|
config.username = "xxx"
|
||||||
end
|
end
|
||||||
|
|
||||||
config.username.should eq "xxx"
|
expect(config.username).to eq "xxx"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -20,7 +20,7 @@ describe Petstore::Configuration do
|
|||||||
config.username = "xxx"
|
config.username = "xxx"
|
||||||
end
|
end
|
||||||
|
|
||||||
config.username.should eq "xxx"
|
expect(config.username).to eq "xxx"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::AnotherPropertyNameMapping
|
# Unit tests for Petstore::AnotherPropertyNameMapping
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::AnotherPropertyNameMapping do
|
Spectator.describe Petstore::AnotherPropertyNameMapping do
|
||||||
|
|
||||||
describe "test an instance of AnotherPropertyNameMapping" do
|
describe "test an instance of AnotherPropertyNameMapping" do
|
||||||
it "should create an instance of AnotherPropertyNameMapping" do
|
it "should create an instance of AnotherPropertyNameMapping" do
|
||||||
#instance = Petstore::AnotherPropertyNameMapping.new
|
# instance = Petstore::AnotherPropertyNameMapping.new
|
||||||
#expect(instance).to be_instance_of(Petstore::AnotherPropertyNameMapping)
|
# expect(instance).to be_instance_of(Petstore::AnotherPropertyNameMapping)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'http_debug_operation'" do
|
describe "test attribute 'http_debug_operation'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -46,5 +44,4 @@ describe Petstore::AnotherPropertyNameMapping do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::ApiResponse
|
# Unit tests for Petstore::ApiResponse
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::ApiResponse do
|
Spectator.describe Petstore::ApiResponse do
|
||||||
|
|
||||||
describe "test an instance of ApiResponse" do
|
describe "test an instance of ApiResponse" do
|
||||||
it "should create an instance of ApiResponse" do
|
it "should create an instance of ApiResponse" do
|
||||||
#instance = Petstore::ApiResponse.new
|
# instance = Petstore::ApiResponse.new
|
||||||
#expect(instance).to be_instance_of(Petstore::ApiResponse)
|
# expect(instance).to be_instance_of(Petstore::ApiResponse)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'code'" do
|
describe "test attribute 'code'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -40,5 +38,4 @@ describe Petstore::ApiResponse do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::Category
|
# Unit tests for Petstore::Category
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::Category do
|
Spectator.describe Petstore::Category do
|
||||||
|
|
||||||
describe "test an instance of Category" do
|
describe "test an instance of Category" do
|
||||||
it "should create an instance of Category" do
|
it "should create an instance of Category" do
|
||||||
#instance = Petstore::Category.new
|
# instance = Petstore::Category.new
|
||||||
#expect(instance).to be_instance_of(Petstore::Category)
|
# expect(instance).to be_instance_of(Petstore::Category)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'id'" do
|
describe "test attribute 'id'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -34,5 +32,4 @@ describe Petstore::Category do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::FormatTest
|
# Unit tests for Petstore::FormatTest
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::FormatTest do
|
Spectator.describe Petstore::FormatTest do
|
||||||
|
|
||||||
describe "test an instance of FormatTest" do
|
describe "test an instance of FormatTest" do
|
||||||
it "should create an instance of FormatTest" do
|
it "should create an instance of FormatTest" do
|
||||||
#instance = Petstore::FormatTest.new
|
# instance = Petstore::FormatTest.new
|
||||||
#expect(instance).to be_instance_of(Petstore::FormatTest)
|
# expect(instance).to be_instance_of(Petstore::FormatTest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'integer'" do
|
describe "test attribute 'integer'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -118,5 +116,4 @@ describe Petstore::FormatTest do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::Order
|
# Unit tests for Petstore::Order
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::Order do
|
Spectator.describe Petstore::Order do
|
||||||
|
|
||||||
describe "test an instance of Order" do
|
describe "test an instance of Order" do
|
||||||
it "should create an instance of Order" do
|
it "should create an instance of Order" do
|
||||||
#instance = Petstore::Order.new
|
# instance = Petstore::Order.new
|
||||||
#expect(instance).to be_instance_of(Petstore::Order)
|
# expect(instance).to be_instance_of(Petstore::Order)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'id'" do
|
describe "test attribute 'id'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -62,5 +60,4 @@ describe Petstore::Order do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,61 +1,58 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#OpenAPI Generator version: 5.0.1-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::Pet
|
# Unit tests for Petstore::Pet
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::Pet do
|
Spectator.describe Petstore::Pet do
|
||||||
|
|
||||||
describe "test an instance of Pet" do
|
describe "test an instance of Pet" do
|
||||||
it "should fail to compile if any required properties is missing" do
|
# it "should fail to compile if any required properties is missing" do
|
||||||
assert_compilation_error(path: "./pet_compilation_error_spec.cr", message: "Error: expected argument 'name' to 'Petstore::Pet.new' to be String, not Nil")
|
# assert_compilation_error(path: "./pet_compilation_error_spec.cr", message: "Error: expected argument 'name' to 'Petstore::Pet.new' to be String, not Nil")
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should create an instance of Pet with only required properties" do
|
it "should create an instance of Pet with only required properties" do
|
||||||
pet = Petstore::Pet.new(id: nil, category: nil, name: "new pet", photo_urls: Array(String).new, tags: nil, status: nil)
|
pet = Petstore::Pet.new(id: nil, category: nil, name: "new pet", photo_urls: Array(String).new, tags: nil, status: nil)
|
||||||
pet.should be_a(Petstore::Pet)
|
expect(pet).to be_a(Petstore::Pet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should create an instance of Pet with all properties" do
|
it "should create an instance of Pet with all properties" do
|
||||||
pet_id = 12345_i64
|
pet_id = 12345_i64
|
||||||
pet = Petstore::Pet.new(id: pet_id, category: Petstore::Category.new(id: pet_id + 10, name: "crystal category"), name: "crystal", photo_urls: ["https://crystal-lang.org"], tags: [Petstore::Tag.new(id: pet_id + 100, name: "crystal tag")], status: "available")
|
pet = Petstore::Pet.new(id: pet_id, category: Petstore::Category.new(id: pet_id + 10, name: "crystal category"), name: "crystal", photo_urls: ["https://crystal-lang.org"], tags: [Petstore::Tag.new(id: pet_id + 100, name: "crystal tag")], status: "available")
|
||||||
pet.should be_a(Petstore::Pet)
|
expect(pet).to be_a(Petstore::Pet)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#from_json" do
|
describe "#from_json" do
|
||||||
it "should instantiate a new instance from json string with required properties" do
|
it "should instantiate a new instance from json string with required properties" do
|
||||||
pet = Petstore::Pet.from_json("{\"name\": \"json pet\", \"photoUrls\": []}")
|
pet = Petstore::Pet.from_json("{\"name\": \"json pet\", \"photoUrls\": []}")
|
||||||
pet.should be_a(Petstore::Pet)
|
expect(pet).to be_a(Petstore::Pet)
|
||||||
pet.name.should eq "json pet"
|
expect(pet.name).to eq "json pet"
|
||||||
pet.photo_urls.should eq Array(String).new
|
expect(pet.photo_urls).to eq Array(String).new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise error when instantiating a new instance from json string with missing required properties" do
|
it "should raise error when instantiating a new instance from json string with missing required properties" do
|
||||||
expect_raises(JSON::SerializableError, "Missing JSON attribute: name") do
|
expect_raises(JSON::SerializableError, /Missing JSON attribute: name/) do
|
||||||
Petstore::Pet.from_json("{\"photoUrls\": []}")
|
Petstore::Pet.from_json("{\"photoUrls\": []}")
|
||||||
end
|
end
|
||||||
expect_raises(JSON::SerializableError, "Missing JSON attribute: photoUrls") do
|
expect_raises(JSON::SerializableError, /Missing JSON attribute: photoUrls/) do
|
||||||
Petstore::Pet.from_json("{\"name\": \"json pet\"}")
|
Petstore::Pet.from_json("{\"name\": \"json pet\"}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise error when instantiating a new instance from json string with required properties set to null value" do
|
it "should raise error when instantiating a new instance from json string with required properties set to null value" do
|
||||||
expect_raises(JSON::SerializableError, "Expected String but was Null") do
|
expect_raises(JSON::SerializableError, /Expected String but was Null/) do
|
||||||
Petstore::Pet.from_json("{\"name\": null, \"photoUrls\": []}")
|
Petstore::Pet.from_json("{\"name\": null, \"photoUrls\": []}")
|
||||||
end
|
end
|
||||||
expect_raises(JSON::SerializableError, "Expected BeginArray but was Null") do
|
expect_raises(JSON::SerializableError, /Expected BeginArray but was Null/) do
|
||||||
Petstore::Pet.from_json("{\"name\": \"json pet\", \"photoUrls\": null}")
|
Petstore::Pet.from_json("{\"name\": \"json pet\", \"photoUrls\": null}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -100,5 +97,4 @@ describe Petstore::Pet do
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,26 +1,23 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#OpenAPI Generator version: 5.0.1-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::Tag
|
# Unit tests for Petstore::Tag
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::Tag do
|
Spectator.describe Petstore::Tag do
|
||||||
|
|
||||||
describe "test an instance of Tag" do
|
describe "test an instance of Tag" do
|
||||||
it "should create an instance of Tag" do
|
it "should create an instance of Tag" do
|
||||||
#instance = Petstore::Tag.new
|
# instance = Petstore::Tag.new
|
||||||
#expect(instance).to be_instance_of(Petstore::Tag)
|
# expect(instance).to be_instance_of(Petstore::Tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,13 +25,13 @@ describe Petstore::Tag do
|
|||||||
it "should equal to itself" do
|
it "should equal to itself" do
|
||||||
tag1 = Petstore::Tag.new(id: 0, name: "same")
|
tag1 = Petstore::Tag.new(id: 0, name: "same")
|
||||||
tag2 = tag1
|
tag2 = tag1
|
||||||
(tag1 == tag2).should be_true
|
expect(tag1 == tag2).to be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should equal to another instance with same attributes" do
|
it "should equal to another instance with same attributes" do
|
||||||
tag1 = Petstore::Tag.new(id: 0, name: "tag")
|
tag1 = Petstore::Tag.new(id: 0, name: "tag")
|
||||||
tag2 = Petstore::Tag.new(id: 0, name: "tag")
|
tag2 = Petstore::Tag.new(id: 0, name: "tag")
|
||||||
(tag1 == tag2).should be_true
|
expect(tag1 == tag2).to be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,5 +46,4 @@ describe Petstore::Tag do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.11.0-SNAPSHOT
|
# Generator version: 7.11.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "json"
|
|
||||||
require "time"
|
|
||||||
|
|
||||||
# Unit tests for Petstore::User
|
# Unit tests for Petstore::User
|
||||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
# Please update as you see appropriate
|
# Please update as you see appropriate
|
||||||
describe Petstore::User do
|
Spectator.describe Petstore::User do
|
||||||
|
|
||||||
describe "test an instance of User" do
|
describe "test an instance of User" do
|
||||||
it "should create an instance of User" do
|
it "should create an instance of User" do
|
||||||
#instance = Petstore::User.new
|
# instance = Petstore::User.new
|
||||||
#expect(instance).to be_instance_of(Petstore::User)
|
# expect(instance).to be_instance_of(Petstore::User)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "test attribute 'id'" do
|
describe "test attribute 'id'" do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
@ -70,5 +68,4 @@ describe Petstore::User do
|
|||||||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
describe Petstore do
|
Spectator.describe Petstore do
|
||||||
describe "#configure" do
|
describe "#configure" do
|
||||||
it "works" do
|
it "works" do
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
@ -9,8 +9,8 @@ describe Petstore do
|
|||||||
|
|
||||||
config = Petstore.configure
|
config = Petstore.configure
|
||||||
|
|
||||||
config.should eq Petstore::Configuration.default
|
expect(config).to eq Petstore::Configuration.default
|
||||||
config.username.should eq "xxx"
|
expect(config.username).to eq "xxx"
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
Petstore::Configuration.default.username = nil
|
Petstore::Configuration.default.username = nil
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
# #OpenAPI Petstore
|
# OpenAPI Petstore
|
||||||
#
|
#
|
||||||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
#
|
#
|
||||||
#The version of the OpenAPI document: 1.0.0
|
# The version of the OpenAPI document: 1.0.0
|
||||||
#
|
#
|
||||||
#Generated by: https://openapi-generator.tech
|
# Generated by: https://openapi-generator.tech
|
||||||
#Generator version: 7.13.0-SNAPSHOT
|
# Generator version: 7.13.0-SNAPSHOT
|
||||||
#
|
#
|
||||||
|
|
||||||
# load modules
|
# load modules
|
||||||
require "spec"
|
require "spectator"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "time"
|
||||||
require "../src/petstore"
|
require "../src/petstore"
|
||||||
|
|
||||||
def assert_compilation_error(path : String, message : String) : Nil
|
def assert_compilation_error(path : String, message : String) : Nil
|
||||||
buffer = IO::Memory.new
|
buffer = IO::Memory.new
|
||||||
result = Process.run("crystal", ["run", "--no-color", "--no-codegen", path], error: buffer)
|
result = Process.run("crystal", ["run", "--no-color", "--no-codegen", path], error: buffer)
|
||||||
result.success?.should be_false
|
expect(result.success?).to be_false
|
||||||
buffer.to_s.should contain message
|
expect(buffer.to_s).to contain message
|
||||||
buffer.close
|
buffer.close
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if @password.to_s.size < 10
|
if @password.to_s.size < 10
|
||||||
invalid_properties.push("invalid value for \"password\", the character length must be great than or equal to 10.")
|
invalid_properties.push("invalid value for \"password\", the character length must be greater than or equal to 10.")
|
||||||
end
|
end
|
||||||
|
|
||||||
pattern = Regexp.new(/^\d{10}$/)
|
pattern = Regexp.new(/^\d{10}$/)
|
||||||
@ -253,7 +253,7 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if password.to_s.size < 10
|
if password.to_s.size < 10
|
||||||
raise ArgumentError.new("invalid value for \"password\", the character length must be great than or equal to 10.")
|
raise ArgumentError.new("invalid value for \"password\", the character length must be greater than or equal to 10.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@password = password
|
@password = password
|
||||||
|
Loading…
x
Reference in New Issue
Block a user