From 2c64b885bbb9dd4c7a7df85519e3aaa0dd33cddd Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Mar 2016 17:18:15 +0800 Subject: [PATCH 1/8] Ruby: add auto-generated documentation in Markdown --- .../codegen/languages/RubyClientCodegen.java | 38 +- .../src/main/resources/ruby/README.mustache | 107 ++++ .../src/main/resources/ruby/api_doc.mustache | 59 ++ .../main/resources/ruby/model_doc.mustache | 9 + samples/client/petstore/ruby/.gitignore | 36 ++ samples/client/petstore/ruby/README.md | 111 +++- samples/client/petstore/ruby/docs/category.md | 9 + .../petstore/ruby/docs/inline_response_200.md | 13 + .../client/petstore/ruby/docs/model_return.md | 8 + samples/client/petstore/ruby/docs/order.md | 13 + samples/client/petstore/ruby/docs/pet.md | 13 + samples/client/petstore/ruby/docs/pet_api.md | 502 +++++++++++++++++ .../petstore/ruby/docs/special_model_name.md | 8 + .../client/petstore/ruby/docs/store_api.md | 264 +++++++++ samples/client/petstore/ruby/docs/tag.md | 9 + samples/client/petstore/ruby/docs/user.md | 15 + samples/client/petstore/ruby/docs/user_api.md | 360 ++++++++++++ samples/client/petstore/ruby/lib/petstore.rb | 14 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 516 +++++++++--------- .../ruby/lib/petstore/api/store_api.rb | 158 +++--- .../ruby/lib/petstore/api/user_api.rb | 238 ++++---- .../petstore/models/inline_response_200.rb | 52 +- .../ruby/lib/petstore/models/model_return.rb | 165 ++++++ .../petstore/ruby/spec/api/pet_api_spec.rb | 128 ++--- .../petstore/ruby/spec/api/store_api_spec.rb | 44 +- .../petstore/ruby/spec/api/user_api_spec.rb | 64 +-- .../spec/models/inline_response_200_spec.rb | 30 + .../ruby/spec/models/model_return_spec.rb | 50 ++ 28 files changed, 2443 insertions(+), 590 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/ruby/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/ruby/model_doc.mustache create mode 100644 samples/client/petstore/ruby/.gitignore create mode 100644 samples/client/petstore/ruby/docs/category.md create mode 100644 samples/client/petstore/ruby/docs/inline_response_200.md create mode 100644 samples/client/petstore/ruby/docs/model_return.md create mode 100644 samples/client/petstore/ruby/docs/order.md create mode 100644 samples/client/petstore/ruby/docs/pet.md create mode 100644 samples/client/petstore/ruby/docs/pet_api.md create mode 100644 samples/client/petstore/ruby/docs/special_model_name.md create mode 100644 samples/client/petstore/ruby/docs/store_api.md create mode 100644 samples/client/petstore/ruby/docs/tag.md create mode 100644 samples/client/petstore/ruby/docs/user.md create mode 100644 samples/client/petstore/ruby/docs/user_api.md create mode 100644 samples/client/petstore/ruby/lib/petstore/models/model_return.rb create mode 100644 samples/client/petstore/ruby/spec/models/model_return_spec.rb diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 667fdad1a23..85a68b3c35b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -3,6 +3,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -40,6 +41,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { protected String gemDescription = "This gem maps to a swagger API"; protected String gemAuthor = ""; protected String gemAuthorEmail = ""; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; protected static int emptyMethodNameCounter = 0; @@ -50,6 +53,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { outputFolder = "generated-code" + File.separator + "ruby"; modelTemplateFiles.put("model.mustache", ".rb"); apiTemplateFiles.put("api.mustache", ".rb"); + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); embeddedTemplateDir = templateDir = "ruby"; modelTestTemplateFiles.put("model_test.mustache", ".rb"); @@ -206,6 +211,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb")); supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb")); supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); } @@ -271,6 +277,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { return outputFolder + File.separator + specFolder + File.separator + modelPackage.replace("/", File.separator); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + @Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty) { @@ -328,7 +344,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { String type = null; if (typeMapping.containsKey(swaggerType)) { type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type)) { + if (languageSpecificPrimitives.contains(type)) { return type; } } else { @@ -414,6 +430,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { return underscore(name); } + @Override + public String toModelDocFilename(String name) { + return toModelFilename(name); + } + @Override public String toApiFilename(String name) { // replace - with _ e.g. created-at => created_at @@ -423,6 +444,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { return underscore(name) + "_api"; } + @Override + public String toApiDocFilename(String name) { + return toApiFilename(name); + } + @Override public String toApiTestFilename(String name) { return toApiFilename(name) + "_spec"; @@ -466,6 +492,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { return gemName + "/" + apiPackage() + "/" + toApiFilename(name); } + @Override + public void setParameterExampleValue(CodegenParameter p) { + if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || + Boolean.TRUE.equals(p.isByteArray) || Boolean.TRUE.equals(p.isFile)) { + p.example = "\"" + escapeText(p.example) + "\""; + } else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) { + p.example = "Date.parse(\"" + escapeText(p.example) + "\")"; + } + } + public void setGemName(String gemName) { this.gemName = gemName; } diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache new file mode 100644 index 00000000000..58f4b881e86 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -0,0 +1,107 @@ +# {{gemName}} + +{{moduleName}} - the Ruby gem for the {{appName}} + +Version: {{gemVersion}} + +Automatically generated by the Ruby Swagger Codegen project: + +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} + +## Installation + +### Build a gem + +You can build the generated client into a gem: + +```shell +gem build {{gemName}}.gemspec +``` + +Then you can either install the gem: + +```shell +gem install ./{{gemName}}-{{gemVersion}}.gem +``` + +or publish the gem to a gem server like [RubyGems](https://rubygems.org/). + +Finally add this to your Gemfile: + + gem '{{gemName}}', '~> {{gemVersion}}' + +### Host as a git repository + +You can also choose to host the generated client as a git repository, e.g. on github: +https://github.com/YOUR_USERNAME/YOUR_REPO + +Then you can reference it in Gemfile: + + gem '{{gemName}}', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git' + +### Use without installation + +You can also use the client directly like this: + +```shell +ruby -Ilib script.rb +``` + +## Getting Started + +```ruby +require '{{gemName}}' + +{{moduleName}}.configure do |config| + # Use the line below to configure API key authorization if needed: + #config.api_key['api_key'] = 'your api key' + + config.host = 'petstore.swagger.io' + config.base_path = '/v2' + # Enable debugging (default is disabled). + config.debugging = true +end + +# Assuming there's a `PetApi` containing a `get_pet_by_id` method +# which returns a model object: +pet_api = Petstore::PetApi.new +pet = pet_api.get_pet_by_id(5) +puts pet.to_body +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{moduleName}}::{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation for Models + +{{#models}}{{#model}} - [{{moduleName}}::{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +## Documentation for Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}### {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}}-- {{{scope}}}: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache new file mode 100644 index 00000000000..66b97fb19be --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -0,0 +1,59 @@ +# {{moduleName}}::{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```ruby +api = {{moduleName}}::{{classname}}.new +{{#allParams}}{{#required}}{{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{dataType}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}} # [{{{dataType}}}] {{description}} +{{/required}}{{/allParams}} +opts = { {{#allParams}}{{^required}} + {{paramName}}: {{{example}}},{{/required}}{{/allParams}} +} + +begin + {{#returnType}}result = {{/returnType}}api.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) +rescue {{moduleName}}::ApiError => e + puts "Exception when calling {{operationId}}: #{e}" +end +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP reuqest headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + + + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/model_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/model_doc.mustache new file mode 100644 index 00000000000..00befadc578 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/ruby/model_doc.mustache @@ -0,0 +1,9 @@ +{{#models}}{{#model}}# {{moduleName}}::{{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/vars}} + +{{/model}}{{/models}} diff --git a/samples/client/petstore/ruby/.gitignore b/samples/client/petstore/ruby/.gitignore new file mode 100644 index 00000000000..a8b1cda23f8 --- /dev/null +++ b/samples/client/petstore/ruby/.gitignore @@ -0,0 +1,36 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index dd6258ec696..35720bfe3a1 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -1,3 +1,14 @@ +# petstore + +Petstore - the Ruby gem for the Swagger Petstore + +Version: 1.0.0 + +Automatically generated by the Ruby Swagger Codegen project: + +- Build date: 2016-03-09T17:12:59.008+08:00 +- Build package: class io.swagger.codegen.languages.RubyClientCodegen + ## Installation ### Build a gem @@ -23,11 +34,11 @@ Finally add this to your Gemfile: ### Host as a git repository You can also choose to host the generated client as a git repository, e.g. on github: -https://github.com/xhh/swagger-petstore-ruby +https://github.com/YOUR_USERNAME/YOUR_REPO Then you can reference it in Gemfile: - gem 'petstore', :git => 'https://github.com/xhh/swagger-petstore-ruby.git' + gem 'petstore', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git' ### Use without installation @@ -43,14 +54,106 @@ ruby -Ilib script.rb require 'petstore' Petstore.configure do |config| - config.api_key['api_key'] = 'special-key' + # Use the line below to configure API key authorization if needed: + #config.api_key['api_key'] = 'your api key' + config.host = 'petstore.swagger.io' config.base_path = '/v2' - # enable debugging (default is disabled) + # Enable debugging (default is disabled). config.debugging = true end +# Assuming there's a `PetApi` containing a `get_pet_by_id` method +# which returns a model object: pet_api = Petstore::PetApi.new pet = pet_api.get_pet_by_id(5) puts pet.to_body ``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*Petstore::PetApi* | [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*Petstore::PetApi* | [**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*Petstore::PetApi* | [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*Petstore::PetApi* | [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*Petstore::PetApi* | [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*Petstore::PetApi* | [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*Petstore::PetApi* | [**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*Petstore::PetApi* | [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*Petstore::PetApi* | [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*Petstore::PetApi* | [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*Petstore::StoreApi* | [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*Petstore::StoreApi* | [**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +*Petstore::StoreApi* | [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*Petstore::StoreApi* | [**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*Petstore::StoreApi* | [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*Petstore::StoreApi* | [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*Petstore::UserApi* | [**create_user**](UserApi.md#create_user) | **POST** /user | Create user +*Petstore::UserApi* | [**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*Petstore::UserApi* | [**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*Petstore::UserApi* | [**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*Petstore::UserApi* | [**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*Petstore::UserApi* | [**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*Petstore::UserApi* | [**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*Petstore::UserApi* | [**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Petstore::Category](Category.md) + - [Petstore::InlineResponse200](InlineResponse200.md) + - [Petstore::ModelReturn](ModelReturn.md) + - [Petstore::Order](Order.md) + - [Petstore::Pet](Pet.md) + - [Petstore::SpecialModelName](SpecialModelName.md) + - [Petstore::Tag](Tag.md) + - [Petstore::User](User.md) + + +## Documentation for Authorization + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: +-- write:pets: modify pets in your account +-- read:pets: read your pets + +### test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +### test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +### test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + diff --git a/samples/client/petstore/ruby/docs/category.md b/samples/client/petstore/ruby/docs/category.md new file mode 100644 index 00000000000..f642a3d6b86 --- /dev/null +++ b/samples/client/petstore/ruby/docs/category.md @@ -0,0 +1,9 @@ +# Petstore::Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/inline_response_200.md b/samples/client/petstore/ruby/docs/inline_response_200.md new file mode 100644 index 00000000000..d06f729f2f8 --- /dev/null +++ b/samples/client/petstore/ruby/docs/inline_response_200.md @@ -0,0 +1,13 @@ +# Petstore::InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photo_urls** | **Array<String>** | | [optional] +**name** | **String** | | [optional] +**id** | **Integer** | | +**category** | **Object** | | [optional] +**tags** | [**Array<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/ruby/docs/model_return.md b/samples/client/petstore/ruby/docs/model_return.md new file mode 100644 index 00000000000..dfcfff1dd06 --- /dev/null +++ b/samples/client/petstore/ruby/docs/model_return.md @@ -0,0 +1,8 @@ +# Petstore::ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/order.md b/samples/client/petstore/ruby/docs/order.md new file mode 100644 index 00000000000..ed1b69874ee --- /dev/null +++ b/samples/client/petstore/ruby/docs/order.md @@ -0,0 +1,13 @@ +# Petstore::Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**pet_id** | **Integer** | | [optional] +**quantity** | **Integer** | | [optional] +**ship_date** | **DateTime** | | [optional] +**status** | **String** | Order Status | [optional] +**complete** | **BOOLEAN** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/pet.md b/samples/client/petstore/ruby/docs/pet.md new file mode 100644 index 00000000000..f4320a0b72b --- /dev/null +++ b/samples/client/petstore/ruby/docs/pet.md @@ -0,0 +1,13 @@ +# Petstore::Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photo_urls** | **Array<String>** | | +**tags** | [**Array<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/ruby/docs/pet_api.md b/samples/client/petstore/ruby/docs/pet_api.md new file mode 100644 index 00000000000..672ed6dd1c5 --- /dev/null +++ b/samples/client/petstore/ruby/docs/pet_api.md @@ -0,0 +1,502 @@ +# Petstore::PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(opts) + +Add a new pet to the store + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: , +} + +begin + api.add_pet(opts) +rescue Petstore::ApiError => e + puts "Exception when calling add_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **add_pet_using_byte_array** +> add_pet_using_byte_array(opts) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: "B", +} + +begin + api.add_pet_using_byte_array(opts) +rescue Petstore::ApiError => e + puts "Exception when calling add_pet_using_byte_array: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **String**| Pet object in the form of byte array | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **delete_pet** +> delete_pet(pet_id, opts) + +Deletes a pet + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] Pet id to delete + +opts = { + api_key: "api_key_example", +} + +begin + api.delete_pet(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| Pet id to delete | + **api_key** | **String**| | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_pets_by_status** +> Array find_pets_by_status(opts) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + status: , +} + +begin + result = api.find_pets_by_status(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_pets_by_status: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**Array<String>**](String.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**Array**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_pets_by_tags** +> Array find_pets_by_tags(opts) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + tags: , +} + +begin + result = api.find_pets_by_tags(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_pets_by_tags: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**Array<String>**](String.md)| Tags to filter by | [optional] + +### Return type + +[**Array**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id, opts) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_pet_by_id(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_pet_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_pet_by_id_in_object** +> InlineResponse200 get_pet_by_id_in_object(pet_id, opts) + +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_pet_by_id_in_object(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_pet_by_id_in_object: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **pet_pet_idtesting_byte_arraytrue_get** +> String pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) + +Fake endpoint to test byte array return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +**String** + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **update_pet** +> update_pet(opts) + +Update an existing pet + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: , +} + +begin + api.update_pet(opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **update_pet_with_form** +> update_pet_with_form(pet_id, opts) + +Updates a pet in the store with form data + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = "pet_id_example" # [String] ID of pet that needs to be updated + +opts = { + name: "name_example", + status: "status_example", +} + +begin + api.update_pet_with_form(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_pet_with_form: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **String**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + + + +# **upload_file** +> upload_file(pet_id, opts) + +uploads an image + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet to update + +opts = { + additional_metadata: "additional_metadata_example", + file: "/path/to/file.txt", +} + +begin + api.upload_file(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling upload_file: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to update | + **additional_metadata** | **String**| Additional data to pass to server | [optional] + **file** | [**File**](.md)| file to upload | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + + + diff --git a/samples/client/petstore/ruby/docs/special_model_name.md b/samples/client/petstore/ruby/docs/special_model_name.md new file mode 100644 index 00000000000..581ab6907ef --- /dev/null +++ b/samples/client/petstore/ruby/docs/special_model_name.md @@ -0,0 +1,8 @@ +# Petstore::SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/store_api.md b/samples/client/petstore/ruby/docs/store_api.md new file mode 100644 index 00000000000..794c93e32f5 --- /dev/null +++ b/samples/client/petstore/ruby/docs/store_api.md @@ -0,0 +1,264 @@ +# Petstore::StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id, opts) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```ruby +api = Petstore::StoreApi.new +order_id = "order_id_example" # [String] ID of the order that needs to be deleted + +opts = { +} + +begin + api.delete_order(order_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **String**| ID of the order that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_orders_by_status** +> Array find_orders_by_status(opts) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { + status: "status_example", +} + +begin + result = api.find_orders_by_status(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_orders_by_status: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **String**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**Array**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_inventory** +> Hash get_inventory(opts) + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { +} + +begin + result = api.get_inventory(opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_inventory: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Hash** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_inventory_in_object** +> Object get_inventory_in_object(opts) + +Fake endpoint to test arbitrary object return by 'Get inventory' + +Returns an arbitrary object which is actually a map of status codes to quantities + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { +} + +begin + result = api.get_inventory_in_object(opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_inventory_in_object: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_order_by_id** +> Order get_order_by_id(order_id, opts) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```ruby +api = Petstore::StoreApi.new +order_id = "order_id_example" # [String] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_order_by_id(order_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_order_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **String**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **place_order** +> Order place_order(opts) + +Place an order for a pet + + + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { + body: , +} + +begin + result = api.place_order(opts) +rescue Petstore::ApiError => e + puts "Exception when calling place_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + diff --git a/samples/client/petstore/ruby/docs/tag.md b/samples/client/petstore/ruby/docs/tag.md new file mode 100644 index 00000000000..5bd94d6c04e --- /dev/null +++ b/samples/client/petstore/ruby/docs/tag.md @@ -0,0 +1,9 @@ +# Petstore::Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/user.md b/samples/client/petstore/ruby/docs/user.md new file mode 100644 index 00000000000..bd76116e023 --- /dev/null +++ b/samples/client/petstore/ruby/docs/user.md @@ -0,0 +1,15 @@ +# Petstore::User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**username** | **String** | | [optional] +**first_name** | **String** | | [optional] +**last_name** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**user_status** | **Integer** | User Status | [optional] + + diff --git a/samples/client/petstore/ruby/docs/user_api.md b/samples/client/petstore/ruby/docs/user_api.md new file mode 100644 index 00000000000..504f1e8de95 --- /dev/null +++ b/samples/client/petstore/ruby/docs/user_api.md @@ -0,0 +1,360 @@ +# Petstore::UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(opts) + +Create user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **create_users_with_array_input** +> create_users_with_array_input(opts) + +Creates list of users with given input array + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_users_with_array_input(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_users_with_array_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Array<User>**](User.md)| List of user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **create_users_with_list_input** +> create_users_with_list_input(opts) + +Creates list of users with given input array + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_users_with_list_input(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_users_with_list_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Array<User>**](User.md)| List of user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **delete_user** +> delete_user(username, opts) + +Delete user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] The name that needs to be deleted + +opts = { +} + +begin + api.delete_user(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_user_by_name** +> User get_user_by_name(username, opts) + +Get user by user name + + + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. + +opts = { +} + +begin + result = api.get_user_by_name(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_user_by_name: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **login_user** +> String login_user(opts) + +Logs user into the system + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + username: "username_example", + password: "password_example", +} + +begin + result = api.login_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling login_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | [optional] + **password** | **String**| The password for login in clear text | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **logout_user** +> logout_user(opts) + +Logs out current logged in user session + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { +} + +begin + api.logout_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling logout_user: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **update_user** +> update_user(username, opts) + +Updated user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] name that need to be deleted + +opts = { + body: , +} + +begin + api.update_user(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index a493758e7d0..d42b7daef8b 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -21,19 +21,19 @@ require 'petstore/version' require 'petstore/configuration' # Models -require 'petstore/models/order' -require 'petstore/models/special_model_name' -require 'petstore/models/user' require 'petstore/models/category' -require 'petstore/models/object_return' require 'petstore/models/inline_response_200' -require 'petstore/models/tag' +require 'petstore/models/model_return' +require 'petstore/models/order' require 'petstore/models/pet' +require 'petstore/models/special_model_name' +require 'petstore/models/tag' +require 'petstore/models/user' # APIs -require 'petstore/api/user_api' -require 'petstore/api/store_api' require 'petstore/api/pet_api' +require 'petstore/api/store_api' +require 'petstore/api/user_api' module Petstore class << self diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 8f7e91495b5..4a5d45d766c 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -24,62 +24,6 @@ module Petstore @api_client = api_client end - # Update an existing pet - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [nil] - def update_pet(opts = {}) - update_pet_with_http_info(opts) - return nil - end - - # Update an existing pet - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def update_pet_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet ..." - end - - # resource path - local_var_path = "/pet".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = @api_client.object_to_http_body(opts[:'body']) - - auth_names = ['petstore_auth'] - data, status_code, headers = @api_client.call_api(:PUT, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - # Add a new pet to the store # # @param [Hash] opts the optional parameters @@ -136,6 +80,124 @@ module Petstore return data, status_code, headers end + # Fake endpoint to test byte array in body parameter for adding a new pet to the store + # + # @param [Hash] opts the optional parameters + # @option opts [String] :body Pet object in the form of byte array + # @return [nil] + def add_pet_using_byte_array(opts = {}) + add_pet_using_byte_array_with_http_info(opts) + return nil + end + + # Fake endpoint to test byte array in body parameter for adding a new pet to the store + # + # @param [Hash] opts the optional parameters + # @option opts [String] :body Pet object in the form of byte array + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def add_pet_using_byte_array_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..." + end + + # resource path + local_var_path = "/pet?testing_byte_array=true".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(opts[:'body']) + + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [nil] + def delete_pet(pet_id, opts = {}) + delete_pet_with_http_info(pet_id, opts) + return nil + end + + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_pet_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: PetApi#delete_pet ..." + end + + # verify the required parameter 'pet_id' is set + fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? + + # resource path + local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key'] + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Finds Pets by status # Multiple status values can be provided with comma separated strings # @param [Hash] opts the optional parameters @@ -312,198 +374,6 @@ module Petstore return data, status_code, headers end - # Updates a pet in the store with form data - # - # @param pet_id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [String] :name Updated name of the pet - # @option opts [String] :status Updated status of the pet - # @return [nil] - def update_pet_with_form(pet_id, opts = {}) - update_pet_with_form_with_http_info(pet_id, opts) - return nil - end - - # Updates a pet in the store with form data - # - # @param pet_id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [String] :name Updated name of the pet - # @option opts [String] :status Updated status of the pet - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def update_pet_with_form_with_http_info(pet_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..." - end - - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? - - # resource path - local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['application/x-www-form-urlencoded'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - form_params["name"] = opts[:'name'] if opts[:'name'] - form_params["status"] = opts[:'status'] if opts[:'status'] - - # http body (model) - post_body = nil - - auth_names = ['petstore_auth'] - data, status_code, headers = @api_client.call_api(:POST, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Deletes a pet - # - # @param pet_id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [String] :api_key - # @return [nil] - def delete_pet(pet_id, opts = {}) - delete_pet_with_http_info(pet_id, opts) - return nil - end - - # Deletes a pet - # - # @param pet_id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [String] :api_key - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def delete_pet_with_http_info(pet_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#delete_pet ..." - end - - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? - - # resource path - local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key'] - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - auth_names = ['petstore_auth'] - data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # uploads an image - # - # @param pet_id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [String] :additional_metadata Additional data to pass to server - # @option opts [File] :file file to upload - # @return [nil] - def upload_file(pet_id, opts = {}) - upload_file_with_http_info(pet_id, opts) - return nil - end - - # uploads an image - # - # @param pet_id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [String] :additional_metadata Additional data to pass to server - # @option opts [File] :file file to upload - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def upload_file_with_http_info(pet_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#upload_file ..." - end - - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? - - # resource path - local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['multipart/form-data'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata'] - form_params["file"] = opts[:'file'] if opts[:'file'] - - # http body (model) - post_body = nil - - auth_names = ['petstore_auth'] - data, status_code, headers = @api_client.call_api(:POST, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - # Fake endpoint to test inline arbitrary object return by 'Find pet by ID' # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions # @param pet_id ID of pet that needs to be fetched @@ -624,28 +494,28 @@ module Petstore return data, status_code, headers end - # Fake endpoint to test byte array in body parameter for adding a new pet to the store + # Update an existing pet # # @param [Hash] opts the optional parameters - # @option opts [String] :body Pet object in the form of byte array + # @option opts [Pet] :body Pet object that needs to be added to the store # @return [nil] - def add_pet_using_byte_array(opts = {}) - add_pet_using_byte_array_with_http_info(opts) + def update_pet(opts = {}) + update_pet_with_http_info(opts) return nil end - # Fake endpoint to test byte array in body parameter for adding a new pet to the store + # Update an existing pet # # @param [Hash] opts the optional parameters - # @option opts [String] :body Pet object in the form of byte array + # @option opts [Pet] :body Pet object that needs to be added to the store # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def add_pet_using_byte_array_with_http_info(opts = {}) + def update_pet_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..." + @api_client.config.logger.debug "Calling API: PetApi#update_pet ..." end # resource path - local_var_path = "/pet?testing_byte_array=true".sub('{format}','json') + local_var_path = "/pet".sub('{format}','json') # query parameters query_params = {} @@ -667,6 +537,71 @@ module Petstore # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [nil] + def update_pet_with_form(pet_id, opts = {}) + update_pet_with_form_with_http_info(pet_id, opts) + return nil + end + + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def update_pet_with_form_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..." + end + + # verify the required parameter 'pet_id' is set + fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? + + # resource path + local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['application/x-www-form-urlencoded'] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + form_params["name"] = opts[:'name'] if opts[:'name'] + form_params["status"] = opts[:'status'] if opts[:'status'] + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -675,7 +610,72 @@ module Petstore :body => post_body, :auth_names => auth_names) if @api_client.config.debugging - @api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [nil] + def upload_file(pet_id, opts = {}) + upload_file_with_http_info(pet_id, opts) + return nil + end + + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def upload_file_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: PetApi#upload_file ..." + end + + # verify the required parameter 'pet_id' is set + fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? + + # resource path + local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['multipart/form-data'] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata'] + form_params["file"] = opts[:'file'] if opts[:'file'] + + # http body (model) + post_body = nil + + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index a6bb3a33938..7bdfd013bf6 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -24,6 +24,65 @@ module Petstore @api_client = api_client end + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_order(order_id, opts = {}) + delete_order_with_http_info(order_id, opts) + return nil + end + + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_order_with_http_info(order_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: StoreApi#delete_order ..." + end + + # verify the required parameter 'order_id' is set + fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? + + # resource path + local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + auth_names = [] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Finds orders by status # A single status value can be provided as a string # @param [Hash] opts the optional parameters @@ -196,63 +255,6 @@ module Petstore return data, status_code, headers end - # Place an order for a pet - # - # @param [Hash] opts the optional parameters - # @option opts [Order] :body order placed for purchasing the pet - # @return [Order] - def place_order(opts = {}) - data, status_code, headers = place_order_with_http_info(opts) - return data - end - - # Place an order for a pet - # - # @param [Hash] opts the optional parameters - # @option opts [Order] :body order placed for purchasing the pet - # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers - def place_order_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#place_order ..." - end - - # resource path - local_var_path = "/store/order".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = @api_client.object_to_http_body(opts[:'body']) - - auth_names = ['test_api_client_id', 'test_api_client_secret'] - data, status_code, headers = @api_client.call_api(:POST, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => 'Order') - if @api_client.config.debugging - @api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - # Find purchase order by ID # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # @param order_id ID of pet that needs to be fetched @@ -313,31 +315,28 @@ module Petstore return data, status_code, headers end - # Delete purchase order by ID - # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order_id ID of the order that needs to be deleted + # Place an order for a pet + # # @param [Hash] opts the optional parameters - # @return [nil] - def delete_order(order_id, opts = {}) - delete_order_with_http_info(order_id, opts) - return nil + # @option opts [Order] :body order placed for purchasing the pet + # @return [Order] + def place_order(opts = {}) + data, status_code, headers = place_order_with_http_info(opts) + return data end - # Delete purchase order by ID - # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order_id ID of the order that needs to be deleted + # Place an order for a pet + # # @param [Hash] opts the optional parameters - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def delete_order_with_http_info(order_id, opts = {}) + # @option opts [Order] :body order placed for purchasing the pet + # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers + def place_order_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#delete_order ..." + @api_client.config.logger.debug "Calling API: StoreApi#place_order ..." end - # verify the required parameter 'order_id' is set - fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? - # resource path - local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) + local_var_path = "/store/order".sub('{format}','json') # query parameters query_params = {} @@ -357,17 +356,18 @@ module Petstore form_params = {} # http body (model) - post_body = nil + post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] - data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + auth_names = ['test_api_client_id', 'test_api_client_secret'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, - :auth_names => auth_names) + :auth_names => auth_names, + :return_type => 'Order') if @api_client.config.debugging - @api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 9b883755347..0a295335eda 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -192,6 +192,125 @@ module Petstore return data, status_code, headers end + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_user(username, opts = {}) + delete_user_with_http_info(username, opts) + return nil + end + + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_user_with_http_info(username, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: UserApi#delete_user ..." + end + + # verify the required parameter 'username' is set + fail "Missing the required parameter 'username' when calling delete_user" if username.nil? + + # resource path + local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + auth_names = [] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [User] + def get_user_by_name(username, opts = {}) + data, status_code, headers = get_user_by_name_with_http_info(username, opts) + return data + end + + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers + def get_user_by_name_with_http_info(username, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..." + end + + # verify the required parameter 'username' is set + fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? + + # resource path + local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'User') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Logs user into the system # # @param [Hash] opts the optional parameters @@ -307,66 +426,6 @@ module Petstore return data, status_code, headers end - # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters - # @return [User] - def get_user_by_name(username, opts = {}) - data, status_code, headers = get_user_by_name_with_http_info(username, opts) - return data - end - - # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters - # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers - def get_user_by_name_with_http_info(username, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..." - end - - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? - - # resource path - local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - auth_names = [] - data, status_code, headers = @api_client.call_api(:GET, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => 'User') - if @api_client.config.debugging - @api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - # Updated user # This can only be done by the logged in user. # @param username name that need to be deleted @@ -427,64 +486,5 @@ module Petstore end return data, status_code, headers end - - # Delete user - # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - def delete_user(username, opts = {}) - delete_user_with_http_info(username, opts) - return nil - end - - # Delete user - # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def delete_user_with_http_info(username, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#delete_user ..." - end - - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling delete_user" if username.nil? - - # resource path - local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - auth_names = [] - data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index 4f45295d374..a793250e45b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -18,21 +18,34 @@ require 'date' module Petstore class InlineResponse200 + attr_accessor :photo_urls + attr_accessor :name attr_accessor :id attr_accessor :category + attr_accessor :tags + + # pet status in the store + attr_accessor :status + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'photo_urls' => :'photoUrls', + :'name' => :'name', :'id' => :'id', - :'category' => :'category' + :'category' => :'category', + + :'tags' => :'tags', + + :'status' => :'status' } end @@ -40,9 +53,12 @@ module Petstore # Attribute type mapping. def self.swagger_types { + :'photo_urls' => :'Array', :'name' => :'String', :'id' => :'Integer', - :'category' => :'Object' + :'category' => :'Object', + :'tags' => :'Array', + :'status' => :'String' } end @@ -54,6 +70,12 @@ module Petstore attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + if attributes[:'photoUrls'] + if (value = attributes[:'photoUrls']).is_a?(Array) + self.photo_urls = value + end + end + if attributes[:'name'] self.name = attributes[:'name'] end @@ -66,15 +88,37 @@ module Petstore self.category = attributes[:'category'] end + if attributes[:'tags'] + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes[:'status'] + self.status = attributes[:'status'] + end + + end + + # Custom attribute writer method checking allowed values (enum). + def status=(status) + allowed_values = ["available", "pending", "sold"] + if status && !allowed_values.include?(status) + fail "invalid value for 'status', must be one of #{allowed_values}" + end + @status = status end # Check equality by comparing each attribute. def ==(o) return true if self.equal?(o) self.class == o.class && + photo_urls == o.photo_urls && name == o.name && id == o.id && - category == o.category + category == o.category && + tags == o.tags && + status == o.status end # @see the `==` method @@ -84,7 +128,7 @@ module Petstore # Calculate hash code according to all attributes. def hash - [name, id, category].hash + [photo_urls, name, id, category, tags, status].hash end # build the object from hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb new file mode 100644 index 00000000000..4f8cb498690 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -0,0 +1,165 @@ +=begin +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +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 ModelReturn + attr_accessor :_return + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + + :'_return' => :'return' + + } + end + + # Attribute type mapping. + def self.swagger_types + { + :'_return' => :'Integer' + + } + end + + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'return'] + self._return = attributes[:'return'] + end + + end + + # Check equality by comparing each attribute. + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _return == o._return + end + + # @see the `==` method + def eql?(o) + self == o + end + + # Calculate hash code according to all attributes. + def hash + [_return].hash + end + + # build the object from hash + 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 + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) + else + #TODO show warning in debug mode + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + else + # data not found in attributes(hash), not an issue as the data can be optional + end + end + + self + end + + 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<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+), (?.+)>\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 + _model = Petstore.const_get(type).new + _model.build_from_hash(value) + end + end + + def to_s + to_hash.to_s + end + + # to_body is an alias to to_body (backward compatibility)) + def to_body + to_hash + end + + # return 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 + + # Method to output non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + 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 diff --git a/samples/client/petstore/ruby/spec/api/pet_api_spec.rb b/samples/client/petstore/ruby/spec/api/pet_api_spec.rb index bf2f747cbdc..12cdc70dc57 100644 --- a/samples/client/petstore/ruby/spec/api/pet_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/pet_api_spec.rb @@ -36,13 +36,13 @@ describe 'PetApi' do end end - # unit tests for update_pet - # Update an existing pet + # unit tests for add_pet + # Add a new pet to the store # # @param [Hash] opts the optional parameters # @option opts [Pet] :body Pet object that needs to be added to the store # @return [nil] - describe 'update_pet test' do + describe 'add_pet test' do it "should work" do # assertion here # should be_a() @@ -52,13 +52,30 @@ describe 'PetApi' do end end - # unit tests for add_pet - # Add a new pet to the store + # unit tests for add_pet_using_byte_array + # Fake endpoint to test byte array in body parameter for adding a new pet to the store # # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store + # @option opts [String] :body Pet object in the form of byte array # @return [nil] - describe 'add_pet test' do + describe 'add_pet_using_byte_array test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + # unit tests for delete_pet + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [nil] + describe 'delete_pet test' do it "should work" do # assertion here # should be_a() @@ -116,59 +133,6 @@ describe 'PetApi' do end end - # unit tests for update_pet_with_form - # Updates a pet in the store with form data - # - # @param pet_id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [String] :name Updated name of the pet - # @option opts [String] :status Updated status of the pet - # @return [nil] - describe 'update_pet_with_form test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for delete_pet - # Deletes a pet - # - # @param pet_id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [String] :api_key - # @return [nil] - describe 'delete_pet test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for upload_file - # uploads an image - # - # @param pet_id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [String] :additional_metadata Additional data to pass to server - # @option opts [File] :file file to upload - # @return [nil] - describe 'upload_file test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - # unit tests for get_pet_by_id_in_object # Fake endpoint to test inline arbitrary object return by 'Find pet by ID' # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -201,13 +165,49 @@ describe 'PetApi' do end end - # unit tests for add_pet_using_byte_array - # Fake endpoint to test byte array in body parameter for adding a new pet to the store + # unit tests for update_pet + # Update an existing pet # # @param [Hash] opts the optional parameters - # @option opts [String] :body Pet object in the form of byte array + # @option opts [Pet] :body Pet object that needs to be added to the store # @return [nil] - describe 'add_pet_using_byte_array test' do + describe 'update_pet test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + # unit tests for update_pet_with_form + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [nil] + describe 'update_pet_with_form test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + # unit tests for upload_file + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [nil] + describe 'upload_file test' do it "should work" do # assertion here # should be_a() diff --git a/samples/client/petstore/ruby/spec/api/store_api_spec.rb b/samples/client/petstore/ruby/spec/api/store_api_spec.rb index bd388e1a32b..3c6e2f2deac 100644 --- a/samples/client/petstore/ruby/spec/api/store_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/store_api_spec.rb @@ -36,6 +36,22 @@ describe 'StoreApi' do end end + # unit tests for delete_order + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'delete_order test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + # unit tests for find_orders_by_status # Finds orders by status # A single status value can be provided as a string @@ -82,22 +98,6 @@ describe 'StoreApi' do end end - # unit tests for place_order - # Place an order for a pet - # - # @param [Hash] opts the optional parameters - # @option opts [Order] :body order placed for purchasing the pet - # @return [Order] - describe 'place_order test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - # unit tests for get_order_by_id # Find purchase order by ID # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -114,13 +114,13 @@ describe 'StoreApi' do end end - # unit tests for delete_order - # Delete purchase order by ID - # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order_id ID of the order that needs to be deleted + # unit tests for place_order + # Place an order for a pet + # # @param [Hash] opts the optional parameters - # @return [nil] - describe 'delete_order test' do + # @option opts [Order] :body order placed for purchasing the pet + # @return [Order] + describe 'place_order test' do it "should work" do # assertion here # should be_a() diff --git a/samples/client/petstore/ruby/spec/api/user_api_spec.rb b/samples/client/petstore/ruby/spec/api/user_api_spec.rb index 894a62f6cc0..408e4544c51 100644 --- a/samples/client/petstore/ruby/spec/api/user_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/user_api_spec.rb @@ -84,6 +84,38 @@ describe 'UserApi' do end end + # unit tests for delete_user + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'delete_user test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + # unit tests for get_user_by_name + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [User] + describe 'get_user_by_name test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + # unit tests for login_user # Logs user into the system # @@ -116,22 +148,6 @@ describe 'UserApi' do end end - # unit tests for get_user_by_name - # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters - # @return [User] - describe 'get_user_by_name test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - # unit tests for update_user # Updated user # This can only be done by the logged in user. @@ -149,20 +165,4 @@ describe 'UserApi' do end end - # unit tests for delete_user - # Delete user - # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - describe 'delete_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - end diff --git a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb index 503b1a528ff..72394650478 100644 --- a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb +++ b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb @@ -36,6 +36,16 @@ describe 'InlineResponse200' do @instance.should be_a(Petstore::InlineResponse200) end end + describe 'test attribute "photo_urls"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + describe 'test attribute "name"' do it 'should work' do # assertion here @@ -66,5 +76,25 @@ describe 'InlineResponse200' do end end + describe 'test attribute "tags"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + describe 'test attribute "status"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + end diff --git a/samples/client/petstore/ruby/spec/models/model_return_spec.rb b/samples/client/petstore/ruby/spec/models/model_return_spec.rb new file mode 100644 index 00000000000..4081c495457 --- /dev/null +++ b/samples/client/petstore/ruby/spec/models/model_return_spec.rb @@ -0,0 +1,50 @@ +=begin +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +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:: +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ModelReturn' do + before do + # run before each test + @instance = Petstore::ModelReturn.new + end + + after do + # run after each test + end + + describe 'test an instance of ModelReturn' do + it 'should create an instact of ModelReturn' do + @instance.should be_a(Petstore::ModelReturn) + end + end + describe 'test attribute "_return"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end + From a9042e241038cde50ee87f4565265f2e2f9a1416 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Mar 2016 17:40:27 +0800 Subject: [PATCH 2/8] Ruby: add gitignore --- .../codegen/languages/RubyClientCodegen.java | 1 + .../main/resources/ruby/gitignore.mustache | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 modules/swagger-codegen/src/main/resources/ruby/gitignore.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 85a68b3c35b..198350b3903 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -212,6 +212,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb")); supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } diff --git a/modules/swagger-codegen/src/main/resources/ruby/gitignore.mustache b/modules/swagger-codegen/src/main/resources/ruby/gitignore.mustache new file mode 100644 index 00000000000..a8b1cda23f8 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/ruby/gitignore.mustache @@ -0,0 +1,36 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc From 43d2df975305ab954b2eee14629061c24e8fa139 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Mar 2016 19:34:59 +0800 Subject: [PATCH 3/8] Delete docs files of Ruby Petstore for regenerating with same file names but in different case --- samples/client/petstore/ruby/docs/category.md | 9 - .../petstore/ruby/docs/inline_response_200.md | 13 - .../client/petstore/ruby/docs/model_return.md | 8 - samples/client/petstore/ruby/docs/order.md | 13 - samples/client/petstore/ruby/docs/pet.md | 13 - samples/client/petstore/ruby/docs/pet_api.md | 502 ------------------ .../petstore/ruby/docs/special_model_name.md | 8 - .../client/petstore/ruby/docs/store_api.md | 264 --------- samples/client/petstore/ruby/docs/tag.md | 9 - samples/client/petstore/ruby/docs/user.md | 15 - samples/client/petstore/ruby/docs/user_api.md | 360 ------------- 11 files changed, 1214 deletions(-) delete mode 100644 samples/client/petstore/ruby/docs/category.md delete mode 100644 samples/client/petstore/ruby/docs/inline_response_200.md delete mode 100644 samples/client/petstore/ruby/docs/model_return.md delete mode 100644 samples/client/petstore/ruby/docs/order.md delete mode 100644 samples/client/petstore/ruby/docs/pet.md delete mode 100644 samples/client/petstore/ruby/docs/pet_api.md delete mode 100644 samples/client/petstore/ruby/docs/special_model_name.md delete mode 100644 samples/client/petstore/ruby/docs/store_api.md delete mode 100644 samples/client/petstore/ruby/docs/tag.md delete mode 100644 samples/client/petstore/ruby/docs/user.md delete mode 100644 samples/client/petstore/ruby/docs/user_api.md diff --git a/samples/client/petstore/ruby/docs/category.md b/samples/client/petstore/ruby/docs/category.md deleted file mode 100644 index f642a3d6b86..00000000000 --- a/samples/client/petstore/ruby/docs/category.md +++ /dev/null @@ -1,9 +0,0 @@ -# Petstore::Category - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Integer** | | [optional] -**name** | **String** | | [optional] - - diff --git a/samples/client/petstore/ruby/docs/inline_response_200.md b/samples/client/petstore/ruby/docs/inline_response_200.md deleted file mode 100644 index d06f729f2f8..00000000000 --- a/samples/client/petstore/ruby/docs/inline_response_200.md +++ /dev/null @@ -1,13 +0,0 @@ -# Petstore::InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**photo_urls** | **Array<String>** | | [optional] -**name** | **String** | | [optional] -**id** | **Integer** | | -**category** | **Object** | | [optional] -**tags** | [**Array<Tag>**](Tag.md) | | [optional] -**status** | **String** | pet status in the store | [optional] - - diff --git a/samples/client/petstore/ruby/docs/model_return.md b/samples/client/petstore/ruby/docs/model_return.md deleted file mode 100644 index dfcfff1dd06..00000000000 --- a/samples/client/petstore/ruby/docs/model_return.md +++ /dev/null @@ -1,8 +0,0 @@ -# Petstore::ModelReturn - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **Integer** | | [optional] - - diff --git a/samples/client/petstore/ruby/docs/order.md b/samples/client/petstore/ruby/docs/order.md deleted file mode 100644 index ed1b69874ee..00000000000 --- a/samples/client/petstore/ruby/docs/order.md +++ /dev/null @@ -1,13 +0,0 @@ -# Petstore::Order - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Integer** | | [optional] -**pet_id** | **Integer** | | [optional] -**quantity** | **Integer** | | [optional] -**ship_date** | **DateTime** | | [optional] -**status** | **String** | Order Status | [optional] -**complete** | **BOOLEAN** | | [optional] - - diff --git a/samples/client/petstore/ruby/docs/pet.md b/samples/client/petstore/ruby/docs/pet.md deleted file mode 100644 index f4320a0b72b..00000000000 --- a/samples/client/petstore/ruby/docs/pet.md +++ /dev/null @@ -1,13 +0,0 @@ -# Petstore::Pet - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Integer** | | [optional] -**category** | [**Category**](Category.md) | | [optional] -**name** | **String** | | -**photo_urls** | **Array<String>** | | -**tags** | [**Array<Tag>**](Tag.md) | | [optional] -**status** | **String** | pet status in the store | [optional] - - diff --git a/samples/client/petstore/ruby/docs/pet_api.md b/samples/client/petstore/ruby/docs/pet_api.md deleted file mode 100644 index 672ed6dd1c5..00000000000 --- a/samples/client/petstore/ruby/docs/pet_api.md +++ /dev/null @@ -1,502 +0,0 @@ -# Petstore::PetApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet -[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status -[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags -[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet -[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data -[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image - - -# **add_pet** -> add_pet(opts) - -Add a new pet to the store - - - -### Example -```ruby -api = Petstore::PetApi.new - -opts = { - body: , -} - -begin - api.add_pet(opts) -rescue Petstore::ApiError => e - puts "Exception when calling add_pet: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - - - -# **add_pet_using_byte_array** -> add_pet_using_byte_array(opts) - -Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - -### Example -```ruby -api = Petstore::PetApi.new - -opts = { - body: "B", -} - -begin - api.add_pet_using_byte_array(opts) -rescue Petstore::ApiError => e - puts "Exception when calling add_pet_using_byte_array: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | **String**| Pet object in the form of byte array | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - - - -# **delete_pet** -> delete_pet(pet_id, opts) - -Deletes a pet - - - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = 789 # [Integer] Pet id to delete - -opts = { - api_key: "api_key_example", -} - -begin - api.delete_pet(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling delete_pet: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| Pet id to delete | - **api_key** | **String**| | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **find_pets_by_status** -> Array find_pets_by_status(opts) - -Finds Pets by status - -Multiple status values can be provided with comma separated strings - -### Example -```ruby -api = Petstore::PetApi.new - -opts = { - status: , -} - -begin - result = api.find_pets_by_status(opts) -rescue Petstore::ApiError => e - puts "Exception when calling find_pets_by_status: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | [**Array<String>**](String.md)| Status values that need to be considered for query | [optional] [default to available] - -### Return type - -[**Array**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **find_pets_by_tags** -> Array find_pets_by_tags(opts) - -Finds Pets by tags - -Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - -### Example -```ruby -api = Petstore::PetApi.new - -opts = { - tags: , -} - -begin - result = api.find_pets_by_tags(opts) -rescue Petstore::ApiError => e - puts "Exception when calling find_pets_by_tags: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **tags** | [**Array<String>**](String.md)| Tags to filter by | [optional] - -### Return type - -[**Array**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_pet_by_id** -> Pet get_pet_by_id(pet_id, opts) - -Find pet by ID - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = 789 # [Integer] ID of pet that needs to be fetched - -opts = { -} - -begin - result = api.get_pet_by_id(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_pet_by_id: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | - -### Return type - -[**Pet**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_pet_by_id_in_object** -> InlineResponse200 get_pet_by_id_in_object(pet_id, opts) - -Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = 789 # [Integer] ID of pet that needs to be fetched - -opts = { -} - -begin - result = api.get_pet_by_id_in_object(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_pet_by_id_in_object: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | - -### Return type - -[**InlineResponse200**](InlineResponse200.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **pet_pet_idtesting_byte_arraytrue_get** -> String pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) - -Fake endpoint to test byte array return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = 789 # [Integer] ID of pet that needs to be fetched - -opts = { -} - -begin - result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | - -### Return type - -**String** - -### Authorization - -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **update_pet** -> update_pet(opts) - -Update an existing pet - - - -### Example -```ruby -api = Petstore::PetApi.new - -opts = { - body: , -} - -begin - api.update_pet(opts) -rescue Petstore::ApiError => e - puts "Exception when calling update_pet: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - - - -# **update_pet_with_form** -> update_pet_with_form(pet_id, opts) - -Updates a pet in the store with form data - - - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = "pet_id_example" # [String] ID of pet that needs to be updated - -opts = { - name: "name_example", - status: "status_example", -} - -begin - api.update_pet_with_form(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling update_pet_with_form: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **String**| ID of pet that needs to be updated | - **name** | **String**| Updated name of the pet | [optional] - **status** | **String**| Updated status of the pet | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json, application/xml - - - -# **upload_file** -> upload_file(pet_id, opts) - -uploads an image - - - -### Example -```ruby -api = Petstore::PetApi.new -pet_id = 789 # [Integer] ID of pet to update - -opts = { - additional_metadata: "additional_metadata_example", - file: "/path/to/file.txt", -} - -begin - api.upload_file(pet_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling upload_file: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet to update | - **additional_metadata** | **String**| Additional data to pass to server | [optional] - **file** | [**File**](.md)| file to upload | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP reuqest headers - - - **Content-Type**: multipart/form-data - - **Accept**: application/json, application/xml - - - diff --git a/samples/client/petstore/ruby/docs/special_model_name.md b/samples/client/petstore/ruby/docs/special_model_name.md deleted file mode 100644 index 581ab6907ef..00000000000 --- a/samples/client/petstore/ruby/docs/special_model_name.md +++ /dev/null @@ -1,8 +0,0 @@ -# Petstore::SpecialModelName - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**special_property_name** | **Integer** | | [optional] - - diff --git a/samples/client/petstore/ruby/docs/store_api.md b/samples/client/petstore/ruby/docs/store_api.md deleted file mode 100644 index 794c93e32f5..00000000000 --- a/samples/client/petstore/ruby/docs/store_api.md +++ /dev/null @@ -1,264 +0,0 @@ -# Petstore::StoreApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status -[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID -[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet - - -# **delete_order** -> delete_order(order_id, opts) - -Delete purchase order by ID - -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - -### Example -```ruby -api = Petstore::StoreApi.new -order_id = "order_id_example" # [String] ID of the order that needs to be deleted - -opts = { -} - -begin - api.delete_order(order_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling delete_order: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **order_id** | **String**| ID of the order that needs to be deleted | - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **find_orders_by_status** -> Array find_orders_by_status(opts) - -Finds orders by status - -A single status value can be provided as a string - -### Example -```ruby -api = Petstore::StoreApi.new - -opts = { - status: "status_example", -} - -begin - result = api.find_orders_by_status(opts) -rescue Petstore::ApiError => e - puts "Exception when calling find_orders_by_status: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | **String**| Status value that needs to be considered for query | [optional] [default to placed] - -### Return type - -[**Array**](Order.md) - -### Authorization - -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_inventory** -> Hash get_inventory(opts) - -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Example -```ruby -api = Petstore::StoreApi.new - -opts = { -} - -begin - result = api.get_inventory(opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_inventory: #{e}" -end -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**Hash** - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_inventory_in_object** -> Object get_inventory_in_object(opts) - -Fake endpoint to test arbitrary object return by 'Get inventory' - -Returns an arbitrary object which is actually a map of status codes to quantities - -### Example -```ruby -api = Petstore::StoreApi.new - -opts = { -} - -begin - result = api.get_inventory_in_object(opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_inventory_in_object: #{e}" -end -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**Object** - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_order_by_id** -> Order get_order_by_id(order_id, opts) - -Find purchase order by ID - -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - -### Example -```ruby -api = Petstore::StoreApi.new -order_id = "order_id_example" # [String] ID of pet that needs to be fetched - -opts = { -} - -begin - result = api.get_order_by_id(order_id, opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_order_by_id: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **order_id** | **String**| ID of pet that needs to be fetched | - -### Return type - -[**Order**](Order.md) - -### Authorization - -[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **place_order** -> Order place_order(opts) - -Place an order for a pet - - - -### Example -```ruby -api = Petstore::StoreApi.new - -opts = { - body: , -} - -begin - result = api.place_order(opts) -rescue Petstore::ApiError => e - puts "Exception when calling place_order: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] - -### Return type - -[**Order**](Order.md) - -### Authorization - -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - diff --git a/samples/client/petstore/ruby/docs/tag.md b/samples/client/petstore/ruby/docs/tag.md deleted file mode 100644 index 5bd94d6c04e..00000000000 --- a/samples/client/petstore/ruby/docs/tag.md +++ /dev/null @@ -1,9 +0,0 @@ -# Petstore::Tag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Integer** | | [optional] -**name** | **String** | | [optional] - - diff --git a/samples/client/petstore/ruby/docs/user.md b/samples/client/petstore/ruby/docs/user.md deleted file mode 100644 index bd76116e023..00000000000 --- a/samples/client/petstore/ruby/docs/user.md +++ /dev/null @@ -1,15 +0,0 @@ -# Petstore::User - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Integer** | | [optional] -**username** | **String** | | [optional] -**first_name** | **String** | | [optional] -**last_name** | **String** | | [optional] -**email** | **String** | | [optional] -**password** | **String** | | [optional] -**phone** | **String** | | [optional] -**user_status** | **Integer** | User Status | [optional] - - diff --git a/samples/client/petstore/ruby/docs/user_api.md b/samples/client/petstore/ruby/docs/user_api.md deleted file mode 100644 index 504f1e8de95..00000000000 --- a/samples/client/petstore/ruby/docs/user_api.md +++ /dev/null @@ -1,360 +0,0 @@ -# Petstore::UserApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_user**](UserApi.md#create_user) | **POST** /user | Create user -[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array -[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array -[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user -[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name -[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system -[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session -[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user - - -# **create_user** -> create_user(opts) - -Create user - -This can only be done by the logged in user. - -### Example -```ruby -api = Petstore::UserApi.new - -opts = { - body: , -} - -begin - api.create_user(opts) -rescue Petstore::ApiError => e - puts "Exception when calling create_user: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **create_users_with_array_input** -> create_users_with_array_input(opts) - -Creates list of users with given input array - - - -### Example -```ruby -api = Petstore::UserApi.new - -opts = { - body: , -} - -begin - api.create_users_with_array_input(opts) -rescue Petstore::ApiError => e - puts "Exception when calling create_users_with_array_input: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Array<User>**](User.md)| List of user object | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **create_users_with_list_input** -> create_users_with_list_input(opts) - -Creates list of users with given input array - - - -### Example -```ruby -api = Petstore::UserApi.new - -opts = { - body: , -} - -begin - api.create_users_with_list_input(opts) -rescue Petstore::ApiError => e - puts "Exception when calling create_users_with_list_input: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Array<User>**](User.md)| List of user object | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **delete_user** -> delete_user(username, opts) - -Delete user - -This can only be done by the logged in user. - -### Example -```ruby -api = Petstore::UserApi.new -username = "username_example" # [String] The name that needs to be deleted - -opts = { -} - -begin - api.delete_user(username, opts) -rescue Petstore::ApiError => e - puts "Exception when calling delete_user: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be deleted | - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_user_by_name** -> User get_user_by_name(username, opts) - -Get user by user name - - - -### Example -```ruby -api = Petstore::UserApi.new -username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. - -opts = { -} - -begin - result = api.get_user_by_name(username, opts) -rescue Petstore::ApiError => e - puts "Exception when calling get_user_by_name: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**User**](User.md) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **login_user** -> String login_user(opts) - -Logs user into the system - - - -### Example -```ruby -api = Petstore::UserApi.new - -opts = { - username: "username_example", - password: "password_example", -} - -begin - result = api.login_user(opts) -rescue Petstore::ApiError => e - puts "Exception when calling login_user: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | [optional] - **password** | **String**| The password for login in clear text | [optional] - -### Return type - -**String** - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **logout_user** -> logout_user(opts) - -Logs out current logged in user session - - - -### Example -```ruby -api = Petstore::UserApi.new - -opts = { -} - -begin - api.logout_user(opts) -rescue Petstore::ApiError => e - puts "Exception when calling logout_user: #{e}" -end -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **update_user** -> update_user(username, opts) - -Updated user - -This can only be done by the logged in user. - -### Example -```ruby -api = Petstore::UserApi.new -username = "username_example" # [String] name that need to be deleted - -opts = { - body: , -} - -begin - api.update_user(username, opts) -rescue Petstore::ApiError => e - puts "Exception when calling update_user: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP reuqest headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - From 91bae765ef13654ef99a0011f39e72f3c4315d6c Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Mar 2016 19:36:28 +0800 Subject: [PATCH 4/8] Some fixes to Ruby docs on links and File parameter --- .../codegen/languages/RubyClientCodegen.java | 7 +- .../src/main/resources/ruby/README.mustache | 2 +- .../src/main/resources/ruby/api_doc.mustache | 2 +- samples/client/petstore/ruby/README.md | 68 +-- samples/client/petstore/ruby/docs/Category.md | 9 + .../petstore/ruby/docs/InlineResponse200.md | 13 + .../client/petstore/ruby/docs/ModelReturn.md | 8 + samples/client/petstore/ruby/docs/Order.md | 13 + samples/client/petstore/ruby/docs/Pet.md | 13 + samples/client/petstore/ruby/docs/PetApi.md | 502 ++++++++++++++++++ .../petstore/ruby/docs/SpecialModelName.md | 8 + samples/client/petstore/ruby/docs/StoreApi.md | 264 +++++++++ samples/client/petstore/ruby/docs/Tag.md | 9 + samples/client/petstore/ruby/docs/User.md | 15 + samples/client/petstore/ruby/docs/UserApi.md | 360 +++++++++++++ 15 files changed, 1255 insertions(+), 38 deletions(-) create mode 100644 samples/client/petstore/ruby/docs/Category.md create mode 100644 samples/client/petstore/ruby/docs/InlineResponse200.md create mode 100644 samples/client/petstore/ruby/docs/ModelReturn.md create mode 100644 samples/client/petstore/ruby/docs/Order.md create mode 100644 samples/client/petstore/ruby/docs/Pet.md create mode 100644 samples/client/petstore/ruby/docs/PetApi.md create mode 100644 samples/client/petstore/ruby/docs/SpecialModelName.md create mode 100644 samples/client/petstore/ruby/docs/StoreApi.md create mode 100644 samples/client/petstore/ruby/docs/Tag.md create mode 100644 samples/client/petstore/ruby/docs/User.md create mode 100644 samples/client/petstore/ruby/docs/UserApi.md diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 198350b3903..dde9f6a65f6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -199,6 +199,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { setGemAuthorEmail((String) additionalProperties.get(GEM_AUTHOR_EMAIL)); } + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); // use constant model/api package (folder path) setModelPackage("models"); @@ -433,7 +436,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toModelDocFilename(String name) { - return toModelFilename(name); + return toModelName(name); } @Override @@ -447,7 +450,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toApiDocFilename(String name) { - return toApiFilename(name); + return toApiName(name); } @Override diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index 58f4b881e86..b016412053f 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -65,7 +65,7 @@ end # Assuming there's a `PetApi` containing a `get_pet_by_id` method # which returns a model object: -pet_api = Petstore::PetApi.new +pet_api = {{moduleName}}::PetApi.new pet = pet_api.get_pet_by_id(5) puts pet.to_body ``` diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index 66b97fb19be..b97938467c2 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -37,7 +37,7 @@ end {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/allParams}} ### Return type diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 35720bfe3a1..29a02930399 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-09T17:12:59.008+08:00 +- Build date: 2016-03-09T19:35:57.300+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -76,43 +76,43 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*Petstore::PetApi* | [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -*Petstore::PetApi* | [**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -*Petstore::PetApi* | [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet -*Petstore::PetApi* | [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status -*Petstore::PetApi* | [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags -*Petstore::PetApi* | [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -*Petstore::PetApi* | [**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -*Petstore::PetApi* | [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet -*Petstore::PetApi* | [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data -*Petstore::PetApi* | [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image -*Petstore::StoreApi* | [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*Petstore::StoreApi* | [**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status -*Petstore::StoreApi* | [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -*Petstore::StoreApi* | [**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -*Petstore::StoreApi* | [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID -*Petstore::StoreApi* | [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet -*Petstore::UserApi* | [**create_user**](UserApi.md#create_user) | **POST** /user | Create user -*Petstore::UserApi* | [**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array -*Petstore::UserApi* | [**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array -*Petstore::UserApi* | [**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user -*Petstore::UserApi* | [**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name -*Petstore::UserApi* | [**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system -*Petstore::UserApi* | [**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session -*Petstore::UserApi* | [**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user +*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*Petstore::PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*Petstore::PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*Petstore::PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*Petstore::PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*Petstore::PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*Petstore::PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*Petstore::PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*Petstore::StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*Petstore::StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +*Petstore::StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*Petstore::StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*Petstore::StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*Petstore::StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*Petstore::UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*Petstore::UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*Petstore::UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*Petstore::UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*Petstore::UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*Petstore::UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*Petstore::UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*Petstore::UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user ## Documentation for Models - - [Petstore::Category](Category.md) - - [Petstore::InlineResponse200](InlineResponse200.md) - - [Petstore::ModelReturn](ModelReturn.md) - - [Petstore::Order](Order.md) - - [Petstore::Pet](Pet.md) - - [Petstore::SpecialModelName](SpecialModelName.md) - - [Petstore::Tag](Tag.md) - - [Petstore::User](User.md) + - [Petstore::Category](docs/Category.md) + - [Petstore::InlineResponse200](docs/InlineResponse200.md) + - [Petstore::ModelReturn](docs/ModelReturn.md) + - [Petstore::Order](docs/Order.md) + - [Petstore::Pet](docs/Pet.md) + - [Petstore::SpecialModelName](docs/SpecialModelName.md) + - [Petstore::Tag](docs/Tag.md) + - [Petstore::User](docs/User.md) ## Documentation for Authorization diff --git a/samples/client/petstore/ruby/docs/Category.md b/samples/client/petstore/ruby/docs/Category.md new file mode 100644 index 00000000000..f642a3d6b86 --- /dev/null +++ b/samples/client/petstore/ruby/docs/Category.md @@ -0,0 +1,9 @@ +# Petstore::Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/InlineResponse200.md b/samples/client/petstore/ruby/docs/InlineResponse200.md new file mode 100644 index 00000000000..d06f729f2f8 --- /dev/null +++ b/samples/client/petstore/ruby/docs/InlineResponse200.md @@ -0,0 +1,13 @@ +# Petstore::InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photo_urls** | **Array<String>** | | [optional] +**name** | **String** | | [optional] +**id** | **Integer** | | +**category** | **Object** | | [optional] +**tags** | [**Array<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/ruby/docs/ModelReturn.md b/samples/client/petstore/ruby/docs/ModelReturn.md new file mode 100644 index 00000000000..dfcfff1dd06 --- /dev/null +++ b/samples/client/petstore/ruby/docs/ModelReturn.md @@ -0,0 +1,8 @@ +# Petstore::ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/Order.md b/samples/client/petstore/ruby/docs/Order.md new file mode 100644 index 00000000000..ed1b69874ee --- /dev/null +++ b/samples/client/petstore/ruby/docs/Order.md @@ -0,0 +1,13 @@ +# Petstore::Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**pet_id** | **Integer** | | [optional] +**quantity** | **Integer** | | [optional] +**ship_date** | **DateTime** | | [optional] +**status** | **String** | Order Status | [optional] +**complete** | **BOOLEAN** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/Pet.md b/samples/client/petstore/ruby/docs/Pet.md new file mode 100644 index 00000000000..f4320a0b72b --- /dev/null +++ b/samples/client/petstore/ruby/docs/Pet.md @@ -0,0 +1,13 @@ +# Petstore::Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photo_urls** | **Array<String>** | | +**tags** | [**Array<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md new file mode 100644 index 00000000000..d776fdd1be7 --- /dev/null +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -0,0 +1,502 @@ +# Petstore::PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(opts) + +Add a new pet to the store + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: , +} + +begin + api.add_pet(opts) +rescue Petstore::ApiError => e + puts "Exception when calling add_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **add_pet_using_byte_array** +> add_pet_using_byte_array(opts) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: "B", +} + +begin + api.add_pet_using_byte_array(opts) +rescue Petstore::ApiError => e + puts "Exception when calling add_pet_using_byte_array: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **String**| Pet object in the form of byte array | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **delete_pet** +> delete_pet(pet_id, opts) + +Deletes a pet + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] Pet id to delete + +opts = { + api_key: "api_key_example", +} + +begin + api.delete_pet(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| Pet id to delete | + **api_key** | **String**| | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_pets_by_status** +> Array find_pets_by_status(opts) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + status: , +} + +begin + result = api.find_pets_by_status(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_pets_by_status: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**Array<String>**](String.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**Array**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_pets_by_tags** +> Array find_pets_by_tags(opts) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + tags: , +} + +begin + result = api.find_pets_by_tags(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_pets_by_tags: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**Array<String>**](String.md)| Tags to filter by | [optional] + +### Return type + +[**Array**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id, opts) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_pet_by_id(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_pet_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_pet_by_id_in_object** +> InlineResponse200 get_pet_by_id_in_object(pet_id, opts) + +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_pet_by_id_in_object(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_pet_by_id_in_object: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **pet_pet_idtesting_byte_arraytrue_get** +> String pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) + +Fake endpoint to test byte array return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +**String** + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **update_pet** +> update_pet(opts) + +Update an existing pet + + + +### Example +```ruby +api = Petstore::PetApi.new + +opts = { + body: , +} + +begin + api.update_pet(opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + + +# **update_pet_with_form** +> update_pet_with_form(pet_id, opts) + +Updates a pet in the store with form data + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = "pet_id_example" # [String] ID of pet that needs to be updated + +opts = { + name: "name_example", + status: "status_example", +} + +begin + api.update_pet_with_form(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_pet_with_form: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **String**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + + + +# **upload_file** +> upload_file(pet_id, opts) + +uploads an image + + + +### Example +```ruby +api = Petstore::PetApi.new +pet_id = 789 # [Integer] ID of pet to update + +opts = { + additional_metadata: "additional_metadata_example", + file: "/path/to/file.txt", +} + +begin + api.upload_file(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling upload_file: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to update | + **additional_metadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + + + diff --git a/samples/client/petstore/ruby/docs/SpecialModelName.md b/samples/client/petstore/ruby/docs/SpecialModelName.md new file mode 100644 index 00000000000..581ab6907ef --- /dev/null +++ b/samples/client/petstore/ruby/docs/SpecialModelName.md @@ -0,0 +1,8 @@ +# Petstore::SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md new file mode 100644 index 00000000000..794c93e32f5 --- /dev/null +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -0,0 +1,264 @@ +# Petstore::StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id, opts) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```ruby +api = Petstore::StoreApi.new +order_id = "order_id_example" # [String] ID of the order that needs to be deleted + +opts = { +} + +begin + api.delete_order(order_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **String**| ID of the order that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **find_orders_by_status** +> Array find_orders_by_status(opts) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { + status: "status_example", +} + +begin + result = api.find_orders_by_status(opts) +rescue Petstore::ApiError => e + puts "Exception when calling find_orders_by_status: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **String**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**Array**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_inventory** +> Hash get_inventory(opts) + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { +} + +begin + result = api.get_inventory(opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_inventory: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Hash** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_inventory_in_object** +> Object get_inventory_in_object(opts) + +Fake endpoint to test arbitrary object return by 'Get inventory' + +Returns an arbitrary object which is actually a map of status codes to quantities + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { +} + +begin + result = api.get_inventory_in_object(opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_inventory_in_object: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_order_by_id** +> Order get_order_by_id(order_id, opts) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```ruby +api = Petstore::StoreApi.new +order_id = "order_id_example" # [String] ID of pet that needs to be fetched + +opts = { +} + +begin + result = api.get_order_by_id(order_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_order_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **String**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **place_order** +> Order place_order(opts) + +Place an order for a pet + + + +### Example +```ruby +api = Petstore::StoreApi.new + +opts = { + body: , +} + +begin + result = api.place_order(opts) +rescue Petstore::ApiError => e + puts "Exception when calling place_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + diff --git a/samples/client/petstore/ruby/docs/Tag.md b/samples/client/petstore/ruby/docs/Tag.md new file mode 100644 index 00000000000..5bd94d6c04e --- /dev/null +++ b/samples/client/petstore/ruby/docs/Tag.md @@ -0,0 +1,9 @@ +# Petstore::Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/User.md b/samples/client/petstore/ruby/docs/User.md new file mode 100644 index 00000000000..bd76116e023 --- /dev/null +++ b/samples/client/petstore/ruby/docs/User.md @@ -0,0 +1,15 @@ +# Petstore::User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**username** | **String** | | [optional] +**first_name** | **String** | | [optional] +**last_name** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**user_status** | **Integer** | User Status | [optional] + + diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md new file mode 100644 index 00000000000..504f1e8de95 --- /dev/null +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -0,0 +1,360 @@ +# Petstore::UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(opts) + +Create user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **create_users_with_array_input** +> create_users_with_array_input(opts) + +Creates list of users with given input array + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_users_with_array_input(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_users_with_array_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Array<User>**](User.md)| List of user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **create_users_with_list_input** +> create_users_with_list_input(opts) + +Creates list of users with given input array + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + body: , +} + +begin + api.create_users_with_list_input(opts) +rescue Petstore::ApiError => e + puts "Exception when calling create_users_with_list_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Array<User>**](User.md)| List of user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **delete_user** +> delete_user(username, opts) + +Delete user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] The name that needs to be deleted + +opts = { +} + +begin + api.delete_user(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling delete_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **get_user_by_name** +> User get_user_by_name(username, opts) + +Get user by user name + + + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. + +opts = { +} + +begin + result = api.get_user_by_name(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling get_user_by_name: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **login_user** +> String login_user(opts) + +Logs user into the system + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { + username: "username_example", + password: "password_example", +} + +begin + result = api.login_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling login_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | [optional] + **password** | **String**| The password for login in clear text | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **logout_user** +> logout_user(opts) + +Logs out current logged in user session + + + +### Example +```ruby +api = Petstore::UserApi.new + +opts = { +} + +begin + api.logout_user(opts) +rescue Petstore::ApiError => e + puts "Exception when calling logout_user: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + +# **update_user** +> update_user(username, opts) + +Updated user + +This can only be done by the logged in user. + +### Example +```ruby +api = Petstore::UserApi.new +username = "username_example" # [String] name that need to be deleted + +opts = { + body: , +} + +begin + api.update_user(username, opts) +rescue Petstore::ApiError => e + puts "Exception when calling update_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + + From 96707e1feac329fb7a5ead94229b774b37af0943 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Mar 2016 19:53:19 +0800 Subject: [PATCH 5/8] Remove obsolete test files --- .../petstore/ruby/spec/api/PetApi_spec.rb | 204 ------------------ .../petstore/ruby/spec/api/StoreApi_spec.rb | 118 ---------- .../petstore/ruby/spec/api/UserApi_spec.rb | 168 --------------- .../ruby/spec/models/object_return_spec.rb | 50 ----- 4 files changed, 540 deletions(-) delete mode 100644 samples/client/petstore/ruby/spec/api/PetApi_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/api/StoreApi_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/api/UserApi_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/object_return_spec.rb diff --git a/samples/client/petstore/ruby/spec/api/PetApi_spec.rb b/samples/client/petstore/ruby/spec/api/PetApi_spec.rb deleted file mode 100644 index 0d4b6ac3519..00000000000 --- a/samples/client/petstore/ruby/spec/api/PetApi_spec.rb +++ /dev/null @@ -1,204 +0,0 @@ -=begin -Swagger Petstore - -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -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' - -# Unit tests for Petstore::PetApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'PetApi' do - before do - # run before each test - @instance = Petstore::PetApi.new - end - - after do - # run after each test - end - - describe 'test an instance of PetApi' do - it 'should create an instact of PetApi' do - @instance.should be_a(Petstore::PetApi) - end - end - - # unit tests for update_pet - # Update an existing pet - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [nil] - describe 'update_pet test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for add_pet - # Add a new pet to the store - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [nil] - describe 'add_pet test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for find_pets_by_status - # Finds Pets by status - # Multiple status values can be provided with comma separated strings - # @param [Hash] opts the optional parameters - # @option opts [Array] :status Status values that need to be considered for query - # @return [Array] - describe 'find_pets_by_status test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for find_pets_by_tags - # Finds Pets by tags - # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - # @param [Hash] opts the optional parameters - # @option opts [Array] :tags Tags to filter by - # @return [Array] - describe 'find_pets_by_tags test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for get_pet_by_id - # Find pet by ID - # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - # @param pet_id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters - # @return [Pet] - describe 'get_pet_by_id test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for update_pet_with_form - # Updates a pet in the store with form data - # - # @param pet_id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [String] :name Updated name of the pet - # @option opts [String] :status Updated status of the pet - # @return [nil] - describe 'update_pet_with_form test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for delete_pet - # Deletes a pet - # - # @param pet_id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [String] :api_key - # @return [nil] - describe 'delete_pet test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for upload_file - # uploads an image - # - # @param pet_id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [String] :additional_metadata Additional data to pass to server - # @option opts [File] :file file to upload - # @return [nil] - describe 'upload_file test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for pet_pet_idtesting_byte_arraytrue_get - # Fake endpoint to test byte array return by 'Find pet by ID' - # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - # @param pet_id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters - # @return [String] - describe 'pet_pet_idtesting_byte_arraytrue_get test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for add_pet_using_byte_array - # Fake endpoint to test byte array in body parameter for adding a new pet to the store - # - # @param [Hash] opts the optional parameters - # @option opts [String] :body Pet object in the form of byte array - # @return [nil] - describe 'add_pet_using_byte_array test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - -end diff --git a/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb b/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb deleted file mode 100644 index a64b24ebca6..00000000000 --- a/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -=begin -Swagger Petstore - -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -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' - -# Unit tests for Petstore::StoreApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'StoreApi' do - before do - # run before each test - @instance = Petstore::StoreApi.new - end - - after do - # run after each test - end - - describe 'test an instance of StoreApi' do - it 'should create an instact of StoreApi' do - @instance.should be_a(Petstore::StoreApi) - end - end - - # unit tests for find_orders_by_status - # Finds orders by status - # A single status value can be provided as a string - # @param [Hash] opts the optional parameters - # @option opts [String] :status Status value that needs to be considered for query - # @return [Array] - describe 'find_orders_by_status test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for get_inventory - # Returns pet inventories by status - # Returns a map of status codes to quantities - # @param [Hash] opts the optional parameters - # @return [Hash] - describe 'get_inventory test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for place_order - # Place an order for a pet - # - # @param [Hash] opts the optional parameters - # @option opts [Order] :body order placed for purchasing the pet - # @return [Order] - describe 'place_order test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for get_order_by_id - # Find purchase order by ID - # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - # @param order_id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters - # @return [Order] - describe 'get_order_by_id test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for delete_order - # Delete purchase order by ID - # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order_id ID of the order that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - describe 'delete_order test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - -end diff --git a/samples/client/petstore/ruby/spec/api/UserApi_spec.rb b/samples/client/petstore/ruby/spec/api/UserApi_spec.rb deleted file mode 100644 index 894a62f6cc0..00000000000 --- a/samples/client/petstore/ruby/spec/api/UserApi_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -=begin -Swagger Petstore - -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -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' - -# Unit tests for Petstore::UserApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'UserApi' do - before do - # run before each test - @instance = Petstore::UserApi.new - end - - after do - # run after each test - end - - describe 'test an instance of UserApi' do - it 'should create an instact of UserApi' do - @instance.should be_a(Petstore::UserApi) - end - end - - # unit tests for create_user - # Create user - # This can only be done by the logged in user. - # @param [Hash] opts the optional parameters - # @option opts [User] :body Created user object - # @return [nil] - describe 'create_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for create_users_with_array_input - # Creates list of users with given input array - # - # @param [Hash] opts the optional parameters - # @option opts [Array] :body List of user object - # @return [nil] - describe 'create_users_with_array_input test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for create_users_with_list_input - # Creates list of users with given input array - # - # @param [Hash] opts the optional parameters - # @option opts [Array] :body List of user object - # @return [nil] - describe 'create_users_with_list_input test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for login_user - # Logs user into the system - # - # @param [Hash] opts the optional parameters - # @option opts [String] :username The user name for login - # @option opts [String] :password The password for login in clear text - # @return [String] - describe 'login_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for logout_user - # Logs out current logged in user session - # - # @param [Hash] opts the optional parameters - # @return [nil] - describe 'logout_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for get_user_by_name - # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters - # @return [User] - describe 'get_user_by_name test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for update_user - # Updated user - # This can only be done by the logged in user. - # @param username name that need to be deleted - # @param [Hash] opts the optional parameters - # @option opts [User] :body Updated user object - # @return [nil] - describe 'update_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - # unit tests for delete_user - # Delete user - # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - describe 'delete_user test' do - it "should work" do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/object_return_spec.rb b/samples/client/petstore/ruby/spec/models/object_return_spec.rb deleted file mode 100644 index c63169bd410..00000000000 --- a/samples/client/petstore/ruby/spec/models/object_return_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -=begin -Swagger Petstore - -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -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:: -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'ObjectReturn' do - before do - # run before each test - @instance = Petstore::ObjectReturn.new - end - - after do - # run after each test - end - - describe 'test an instance of ObjectReturn' do - it 'should create an instact of ObjectReturn' do - @instance.should be_a(Petstore::ObjectReturn) - end - end - describe 'test attribute "_return"' do - it 'should work' do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - -end - From eafcc2427df9a01ef459de32181fedda210691c0 Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 10 Mar 2016 17:19:18 +0800 Subject: [PATCH 6/8] Some improvements on Ruby docs --- .../codegen/languages/RubyClientCodegen.java | 45 +++++++++++++- .../src/main/resources/ruby/README.mustache | 24 +++---- .../src/main/resources/ruby/api_doc.mustache | 29 ++++----- samples/client/petstore/ruby/README.md | 2 +- samples/client/petstore/ruby/docs/PetApi.md | 62 +++++++++---------- samples/client/petstore/ruby/docs/StoreApi.md | 44 ++++++------- samples/client/petstore/ruby/docs/UserApi.md | 34 +++++----- 7 files changed, 135 insertions(+), 105 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index dde9f6a65f6..ede3a23c898 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -3,16 +3,21 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; +import io.swagger.models.Model; +import io.swagger.models.Operation; +import io.swagger.models.Swagger; import io.swagger.models.properties.*; import java.io.File; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -218,6 +223,35 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } + @Override + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, Swagger swagger) { + CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger); + // Set vendor-extension to be used in template: + // x-codegen-hasMoreRequired + // x-codegen-hasMoreOptional + // x-codegen-hasRequiredParams + CodegenParameter lastRequired = null; + CodegenParameter lastOptional = null; + for (CodegenParameter p : op.allParams) { + if (p.required != null && p.required) { + lastRequired = p; + } else { + lastOptional = p; + } + } + for (CodegenParameter p : op.allParams) { + if (p == lastRequired) { + p.vendorExtensions.put("x-codegen-hasMoreRequired", false); + } else if (p == lastOptional) { + p.vendorExtensions.put("x-codegen-hasMoreOptional", false); + } else { + p.vendorExtensions.put("x-codegen-hasMoreRequired", true); + p.vendorExtensions.put("x-codegen-hasMoreOptional", true); + } + } + op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null); + return op; + } @Override public CodegenType getTag() { @@ -498,9 +532,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void setParameterExampleValue(CodegenParameter p) { - if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || - Boolean.TRUE.equals(p.isByteArray) || Boolean.TRUE.equals(p.isFile)) { + // NOTE: Can not get default value from ArrayProperty + //String defaultValue = p.defaultValue; + //if (!StringUtils.isEmpty(defaultValue)) { + // p.example = defaultValue; + // return; + //} + if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || Boolean.TRUE.equals(p.isByteArray)) { p.example = "\"" + escapeText(p.example) + "\""; + } else if (Boolean.TRUE.equals(p.isFile)) { + p.example = "File.new(\"" + escapeText(p.example) + "\")"; } else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) { p.example = "Date.parse(\"" + escapeText(p.example) + "\")"; } diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index b016412053f..c9a21277c77 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -16,20 +16,20 @@ Automatically generated by the Ruby Swagger Codegen project: You can build the generated client into a gem: ```shell -gem build {{gemName}}.gemspec +gem build {{{gemName}}}.gemspec ``` Then you can either install the gem: ```shell -gem install ./{{gemName}}-{{gemVersion}}.gem +gem install ./{{{gemName}}}-{{{gemVersion}}}.gem ``` or publish the gem to a gem server like [RubyGems](https://rubygems.org/). Finally add this to your Gemfile: - gem '{{gemName}}', '~> {{gemVersion}}' + gem '{{{gemName}}}', '~> {{{gemVersion}}}' ### Host as a git repository @@ -38,7 +38,7 @@ https://github.com/YOUR_USERNAME/YOUR_REPO Then you can reference it in Gemfile: - gem '{{gemName}}', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git' + gem '{{{gemName}}}', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git' ### Use without installation @@ -51,9 +51,9 @@ ruby -Ilib script.rb ## Getting Started ```ruby -require '{{gemName}}' +require '{{{gemName}}}' -{{moduleName}}.configure do |config| +{{{moduleName}}}.configure do |config| # Use the line below to configure API key authorization if needed: #config.api_key['api_key'] = 'your api key' @@ -65,7 +65,7 @@ end # Assuming there's a `PetApi` containing a `get_pet_by_id` method # which returns a model object: -pet_api = {{moduleName}}::PetApi.new +pet_api = {{{moduleName}}}::PetApi.new pet = pet_api.get_pet_by_id(5) puts pet.to_body ``` @@ -88,19 +88,19 @@ Class | Method | HTTP request | Description {{^authMethods}} All endpoints do not require authorization. {{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} -{{#authMethods}}### {{{name}}} +{{#authMethods}}### {{name}} {{#isApiKey}}- **Type**: API key -- **API key parameter name**: {{{keyParamName}}} +- **API key parameter name**: {{keyParamName}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} {{#isBasic}}- **Type**: HTTP basic authentication {{/isBasic}} {{#isOAuth}}- **Type**: OAuth -- **Flow**: {{{flow}}} -- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Flow**: {{flow}} +- **Authorizatoin URL**: {{authorizationUrl}} - **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}}-- {{{scope}}}: {{{description}}} +{{#scopes}}-- {{scope}}: {{description}} {{/scopes}} {{/isOAuth}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index b97938467c2..08050f3949e 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -10,26 +10,27 @@ Method | HTTP request | Description {{#operations}} {{#operation}} -# **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} -{{{summary}}}{{#notes}} +{{summary}}{{#notes}} -{{{notes}}}{{/notes}} +{{notes}}{{/notes}} ### Example ```ruby -api = {{moduleName}}::{{classname}}.new -{{#allParams}}{{#required}}{{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{dataType}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}} # [{{{dataType}}}] {{description}} -{{/required}}{{/allParams}} +api = {{{moduleName}}}::{{{classname}}}.new{{#hasParams}} +{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} +{{{paramName}}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{{baseType}}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}} # [{{{dataType}}}] {{{description}}} +{{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} opts = { {{#allParams}}{{^required}} - {{paramName}}: {{{example}}},{{/required}}{{/allParams}} -} + {{{paramName}}}: {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{{baseType}}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} # [{{{dataType}}}] {{{description}}}{{/required}}{{/allParams}} +}{{/hasOptionalParams}}{{/hasParams}} begin - {{#returnType}}result = {{/returnType}}api.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) -rescue {{moduleName}}::ApiError => e - puts "Exception when calling {{operationId}}: #{e}" + {{#returnType}}result = {{/returnType}}api.{{{operationId}}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} +rescue {{{moduleName}}}::ApiError => e + puts "Exception when calling {{{operationId}}}: #{e}" end ``` @@ -42,11 +43,11 @@ Name | Type | Description | Notes ### Return type -{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}} +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}} ### Authorization -{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} ### HTTP reuqest headers diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 29a02930399..9c9b686c5b5 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-09T19:35:57.300+08:00 +- Build date: 2016-03-10T17:17:33.736+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index d776fdd1be7..fc9d4ecb276 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -29,7 +29,7 @@ Add a new pet to the store api = Petstore::PetApi.new opts = { - body: , + body: Petstore::Pet.new # [Pet] Pet object that needs to be added to the store } begin @@ -72,7 +72,7 @@ Fake endpoint to test byte array in body parameter for adding a new pet to the s api = Petstore::PetApi.new opts = { - body: "B", + body: Petstore::String.new # [String] Pet object in the form of byte array } begin @@ -113,10 +113,11 @@ Deletes a pet ### Example ```ruby api = Petstore::PetApi.new + pet_id = 789 # [Integer] Pet id to delete opts = { - api_key: "api_key_example", + api_key: "api_key_example" # [String] } begin @@ -149,7 +150,7 @@ nil (empty response body) # **find_pets_by_status** -> Array find_pets_by_status(opts) +> Array<Pet> find_pets_by_status(opts) Finds Pets by status @@ -160,7 +161,7 @@ Multiple status values can be provided with comma separated strings api = Petstore::PetApi.new opts = { - status: , + status: [] # [Array] Status values that need to be considered for query } begin @@ -178,7 +179,7 @@ Name | Type | Description | Notes ### Return type -[**Array**](Pet.md) +[**Array<Pet>**](Pet.md) ### Authorization @@ -192,7 +193,7 @@ Name | Type | Description | Notes # **find_pets_by_tags** -> Array find_pets_by_tags(opts) +> Array<Pet> find_pets_by_tags(opts) Finds Pets by tags @@ -203,7 +204,7 @@ Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 api = Petstore::PetApi.new opts = { - tags: , + tags: [] # [Array] Tags to filter by } begin @@ -221,7 +222,7 @@ Name | Type | Description | Notes ### Return type -[**Array**](Pet.md) +[**Array<Pet>**](Pet.md) ### Authorization @@ -235,22 +236,21 @@ Name | Type | Description | Notes # **get_pet_by_id** -> Pet get_pet_by_id(pet_id, opts) +> Pet get_pet_by_id(pet_id) Find pet by ID -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example ```ruby api = Petstore::PetApi.new + pet_id = 789 # [Integer] ID of pet that needs to be fetched -opts = { -} begin - result = api.get_pet_by_id(pet_id, opts) + result = api.get_pet_by_id(pet_id) rescue Petstore::ApiError => e puts "Exception when calling get_pet_by_id: #{e}" end @@ -278,22 +278,21 @@ Name | Type | Description | Notes # **get_pet_by_id_in_object** -> InlineResponse200 get_pet_by_id_in_object(pet_id, opts) +> InlineResponse200 get_pet_by_id_in_object(pet_id) -Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example ```ruby api = Petstore::PetApi.new + pet_id = 789 # [Integer] ID of pet that needs to be fetched -opts = { -} begin - result = api.get_pet_by_id_in_object(pet_id, opts) + result = api.get_pet_by_id_in_object(pet_id) rescue Petstore::ApiError => e puts "Exception when calling get_pet_by_id_in_object: #{e}" end @@ -321,22 +320,21 @@ Name | Type | Description | Notes # **pet_pet_idtesting_byte_arraytrue_get** -> String pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) +> String pet_pet_idtesting_byte_arraytrue_get(pet_id) -Fake endpoint to test byte array return by 'Find pet by ID' +Fake endpoint to test byte array return by 'Find pet by ID' -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example ```ruby api = Petstore::PetApi.new + pet_id = 789 # [Integer] ID of pet that needs to be fetched -opts = { -} begin - result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id, opts) + result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id) rescue Petstore::ApiError => e puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}" end @@ -375,7 +373,7 @@ Update an existing pet api = Petstore::PetApi.new opts = { - body: , + body: Petstore::Pet.new # [Pet] Pet object that needs to be added to the store } begin @@ -416,11 +414,12 @@ Updates a pet in the store with form data ### Example ```ruby api = Petstore::PetApi.new + pet_id = "pet_id_example" # [String] ID of pet that needs to be updated opts = { - name: "name_example", - status: "status_example", + name: "name_example", # [String] Updated name of the pet + status: "status_example" # [String] Updated status of the pet } begin @@ -463,11 +462,12 @@ uploads an image ### Example ```ruby api = Petstore::PetApi.new + pet_id = 789 # [Integer] ID of pet to update opts = { - additional_metadata: "additional_metadata_example", - file: "/path/to/file.txt", + additional_metadata: "additional_metadata_example", # [String] Additional data to pass to server + file: File.new("/path/to/file.txt") # [File] file to upload } begin diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 794c93e32f5..da2b4219680 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -13,22 +13,21 @@ Method | HTTP request | Description # **delete_order** -> delete_order(order_id, opts) +> delete_order(order_id) Delete purchase order by ID -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors ### Example ```ruby api = Petstore::StoreApi.new + order_id = "order_id_example" # [String] ID of the order that needs to be deleted -opts = { -} begin - api.delete_order(order_id, opts) + api.delete_order(order_id) rescue Petstore::ApiError => e puts "Exception when calling delete_order: #{e}" end @@ -56,7 +55,7 @@ No authorization required # **find_orders_by_status** -> Array find_orders_by_status(opts) +> Array<Order> find_orders_by_status(opts) Finds orders by status @@ -67,7 +66,7 @@ A single status value can be provided as a string api = Petstore::StoreApi.new opts = { - status: "status_example", + status: "status_example" # [String] Status value that needs to be considered for query } begin @@ -85,7 +84,7 @@ Name | Type | Description | Notes ### Return type -[**Array**](Order.md) +[**Array<Order>**](Order.md) ### Authorization @@ -99,7 +98,7 @@ Name | Type | Description | Notes # **get_inventory** -> Hash get_inventory(opts) +> Hash<String, Integer> get_inventory Returns pet inventories by status @@ -109,11 +108,8 @@ Returns a map of status codes to quantities ```ruby api = Petstore::StoreApi.new -opts = { -} - begin - result = api.get_inventory(opts) + result = api.get_inventory rescue Petstore::ApiError => e puts "Exception when calling get_inventory: #{e}" end @@ -124,7 +120,7 @@ This endpoint does not need any parameter. ### Return type -**Hash** +**Hash<String, Integer>** ### Authorization @@ -138,9 +134,9 @@ This endpoint does not need any parameter. # **get_inventory_in_object** -> Object get_inventory_in_object(opts) +> Object get_inventory_in_object -Fake endpoint to test arbitrary object return by 'Get inventory' +Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities @@ -148,11 +144,8 @@ Returns an arbitrary object which is actually a map of status codes to quantitie ```ruby api = Petstore::StoreApi.new -opts = { -} - begin - result = api.get_inventory_in_object(opts) + result = api.get_inventory_in_object rescue Petstore::ApiError => e puts "Exception when calling get_inventory_in_object: #{e}" end @@ -177,22 +170,21 @@ This endpoint does not need any parameter. # **get_order_by_id** -> Order get_order_by_id(order_id, opts) +> Order get_order_by_id(order_id) Find purchase order by ID -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions ### Example ```ruby api = Petstore::StoreApi.new + order_id = "order_id_example" # [String] ID of pet that needs to be fetched -opts = { -} begin - result = api.get_order_by_id(order_id, opts) + result = api.get_order_by_id(order_id) rescue Petstore::ApiError => e puts "Exception when calling get_order_by_id: #{e}" end @@ -231,7 +223,7 @@ Place an order for a pet api = Petstore::StoreApi.new opts = { - body: , + body: Petstore::Order.new # [Order] order placed for purchasing the pet } begin diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md index 504f1e8de95..b7dbb9c69aa 100644 --- a/samples/client/petstore/ruby/docs/UserApi.md +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -26,7 +26,7 @@ This can only be done by the logged in user. api = Petstore::UserApi.new opts = { - body: , + body: Petstore::User.new # [User] Created user object } begin @@ -69,7 +69,7 @@ Creates list of users with given input array api = Petstore::UserApi.new opts = { - body: , + body: [Petstore::User.new] # [Array] List of user object } begin @@ -112,7 +112,7 @@ Creates list of users with given input array api = Petstore::UserApi.new opts = { - body: , + body: [Petstore::User.new] # [Array] List of user object } begin @@ -144,7 +144,7 @@ No authorization required # **delete_user** -> delete_user(username, opts) +> delete_user(username) Delete user @@ -153,13 +153,12 @@ This can only be done by the logged in user. ### Example ```ruby api = Petstore::UserApi.new + username = "username_example" # [String] The name that needs to be deleted -opts = { -} begin - api.delete_user(username, opts) + api.delete_user(username) rescue Petstore::ApiError => e puts "Exception when calling delete_user: #{e}" end @@ -187,7 +186,7 @@ No authorization required # **get_user_by_name** -> User get_user_by_name(username, opts) +> User get_user_by_name(username) Get user by user name @@ -196,13 +195,12 @@ Get user by user name ### Example ```ruby api = Petstore::UserApi.new + username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. -opts = { -} begin - result = api.get_user_by_name(username, opts) + result = api.get_user_by_name(username) rescue Petstore::ApiError => e puts "Exception when calling get_user_by_name: #{e}" end @@ -241,8 +239,8 @@ Logs user into the system api = Petstore::UserApi.new opts = { - username: "username_example", - password: "password_example", + username: "username_example", # [String] The user name for login + password: "password_example" # [String] The password for login in clear text } begin @@ -275,7 +273,7 @@ No authorization required # **logout_user** -> logout_user(opts) +> logout_user Logs out current logged in user session @@ -285,11 +283,8 @@ Logs out current logged in user session ```ruby api = Petstore::UserApi.new -opts = { -} - begin - api.logout_user(opts) + api.logout_user rescue Petstore::ApiError => e puts "Exception when calling logout_user: #{e}" end @@ -323,10 +318,11 @@ This can only be done by the logged in user. ### Example ```ruby api = Petstore::UserApi.new + username = "username_example" # [String] name that need to be deleted opts = { - body: , + body: Petstore::User.new # [User] Updated user object } begin From 1df0923525035d7ef939c6a25f3fd0961b1f0df6 Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 11 Mar 2016 15:23:55 +0800 Subject: [PATCH 7/8] Ruby: improve handling of default values and examples for parameters in docs --- .../codegen/languages/RubyClientCodegen.java | 70 +++++++++++++++---- .../src/main/resources/ruby/api_doc.mustache | 4 +- samples/client/petstore/ruby/README.md | 2 +- samples/client/petstore/ruby/docs/PetApi.md | 6 +- samples/client/petstore/ruby/docs/StoreApi.md | 2 +- .../{Category_spec.rb => category_spec.rb} | 0 .../models/{Order_spec.rb => order_spec.rb} | 0 .../spec/models/{Pet_spec.rb => pet_spec.rb} | 0 .../spec/models/{Tag_spec.rb => tag_spec.rb} | 0 .../models/{User_spec.rb => user_spec.rb} | 0 10 files changed, 65 insertions(+), 19 deletions(-) rename samples/client/petstore/ruby/spec/models/{Category_spec.rb => category_spec.rb} (100%) rename samples/client/petstore/ruby/spec/models/{Order_spec.rb => order_spec.rb} (100%) rename samples/client/petstore/ruby/spec/models/{Pet_spec.rb => pet_spec.rb} (100%) rename samples/client/petstore/ruby/spec/models/{Tag_spec.rb => tag_spec.rb} (100%) rename samples/client/petstore/ruby/spec/models/{User_spec.rb => user_spec.rb} (100%) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index ede3a23c898..5c03720a20d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -532,19 +532,65 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void setParameterExampleValue(CodegenParameter p) { - // NOTE: Can not get default value from ArrayProperty - //String defaultValue = p.defaultValue; - //if (!StringUtils.isEmpty(defaultValue)) { - // p.example = defaultValue; - // return; - //} - if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || Boolean.TRUE.equals(p.isByteArray)) { - p.example = "\"" + escapeText(p.example) + "\""; - } else if (Boolean.TRUE.equals(p.isFile)) { - p.example = "File.new(\"" + escapeText(p.example) + "\")"; - } else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) { - p.example = "Date.parse(\"" + escapeText(p.example) + "\")"; + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equals(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Integer".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Float".equals(type)) { + if (example == null) { + example = "3.4"; + } + } else if ("BOOLEAN".equals(type)) { + if (example == null) { + example = "true"; + } + } else if ("File".equals(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "File.new(\"" + escapeText(example) + "\")"; + } else if ("Date".equals(type)) { + if (example == null) { + example = "2013-10-20"; + } + example = "Date.parse(\"" + escapeText(example) + "\")"; + } else if ("DateTime".equals(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "DateTime.parse(\"" + escapeText(example) + "\")"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = moduleName + "::" + type + ".new"; + } + + if (example == null) { + example = "nil"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "[" + example + "]"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "{'key': " + example + "}"; + } + + p.example = example; } public void setGemName(String gemName) { diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index 08050f3949e..74dcf9c6454 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -21,10 +21,10 @@ Method | HTTP request | Description ```ruby api = {{{moduleName}}}::{{{classname}}}.new{{#hasParams}} {{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} -{{{paramName}}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{{baseType}}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}} # [{{{dataType}}}] {{{description}}} +{{{paramName}}} = {{{example}}} # [{{{dataType}}}] {{{description}}} {{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} opts = { {{#allParams}}{{^required}} - {{{paramName}}}: {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{{baseType}}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} # [{{{dataType}}}] {{{description}}}{{/required}}{{/allParams}} + {{{paramName}}}: {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} # [{{{dataType}}}] {{{description}}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}{{/hasParams}} begin diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9c9b686c5b5..6674e022074 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-10T17:17:33.736+08:00 +- Build date: 2016-03-11T15:13:56.730+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index fc9d4ecb276..5218d4dc3b5 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -72,7 +72,7 @@ Fake endpoint to test byte array in body parameter for adding a new pet to the s api = Petstore::PetApi.new opts = { - body: Petstore::String.new # [String] Pet object in the form of byte array + body: "B" # [String] Pet object in the form of byte array } begin @@ -161,7 +161,7 @@ Multiple status values can be provided with comma separated strings api = Petstore::PetApi.new opts = { - status: [] # [Array] Status values that need to be considered for query + status: ["available"] # [Array] Status values that need to be considered for query } begin @@ -204,7 +204,7 @@ Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 api = Petstore::PetApi.new opts = { - tags: [] # [Array] Tags to filter by + tags: ["tags_example"] # [Array] Tags to filter by } begin diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index da2b4219680..4655955d246 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -66,7 +66,7 @@ A single status value can be provided as a string api = Petstore::StoreApi.new opts = { - status: "status_example" # [String] Status value that needs to be considered for query + status: "placed" # [String] Status value that needs to be considered for query } begin diff --git a/samples/client/petstore/ruby/spec/models/Category_spec.rb b/samples/client/petstore/ruby/spec/models/category_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/Category_spec.rb rename to samples/client/petstore/ruby/spec/models/category_spec.rb diff --git a/samples/client/petstore/ruby/spec/models/Order_spec.rb b/samples/client/petstore/ruby/spec/models/order_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/Order_spec.rb rename to samples/client/petstore/ruby/spec/models/order_spec.rb diff --git a/samples/client/petstore/ruby/spec/models/Pet_spec.rb b/samples/client/petstore/ruby/spec/models/pet_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/Pet_spec.rb rename to samples/client/petstore/ruby/spec/models/pet_spec.rb diff --git a/samples/client/petstore/ruby/spec/models/Tag_spec.rb b/samples/client/petstore/ruby/spec/models/tag_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/Tag_spec.rb rename to samples/client/petstore/ruby/spec/models/tag_spec.rb diff --git a/samples/client/petstore/ruby/spec/models/User_spec.rb b/samples/client/petstore/ruby/spec/models/user_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/User_spec.rb rename to samples/client/petstore/ruby/spec/models/user_spec.rb From d274af4d4a1a258cf00cdf029c831c1a46374901 Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 11 Mar 2016 19:05:27 +0800 Subject: [PATCH 8/8] Ruby docs: add sample code of configuring auths --- .../src/main/resources/ruby/api_doc.mustache | 15 +++- samples/client/petstore/ruby/README.md | 2 +- samples/client/petstore/ruby/docs/PetApi.md | 70 +++++++++++++++++++ samples/client/petstore/ruby/docs/StoreApi.md | 50 +++++++++++++ 4 files changed, 135 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index 74dcf9c6454..f71a066b74f 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -18,7 +18,20 @@ Method | HTTP request | Description {{notes}}{{/notes}} ### Example -```ruby +```ruby{{#hasAuthMethods}} +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} + # Configure HTTP basic authorization: {{{name}}} + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} + # Configure API key authorization: {{{name}}} + config.api_key['{{{keyParamName}}}'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}} + # Configure OAuth2 access token for authorization: {{{name}}} + config.access_token = "YOUR ACCESS TOKEN"{{/isOAuth}} +{{/authMethods}}end +{{/hasAuthMethods}} + api = {{{moduleName}}}::{{{classname}}}.new{{#hasParams}} {{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} {{{paramName}}} = {{{example}}} # [{{{dataType}}}] {{{description}}} diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 6674e022074..9ec5c8ccc69 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-11T15:13:56.730+08:00 +- Build date: 2016-03-11T18:59:01.854+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index 5218d4dc3b5..b0dc8f82cee 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -26,6 +26,11 @@ Add a new pet to the store ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new opts = { @@ -69,6 +74,11 @@ Fake endpoint to test byte array in body parameter for adding a new pet to the s ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new opts = { @@ -112,6 +122,11 @@ Deletes a pet ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new pet_id = 789 # [Integer] Pet id to delete @@ -158,6 +173,11 @@ Multiple status values can be provided with comma separated strings ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new opts = { @@ -201,6 +221,11 @@ Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new opts = { @@ -244,6 +269,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" + + # Configure API key authorization: api_key + config.api_key['api_key'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['api_key'] = "Token" +end + api = Petstore::PetApi.new pet_id = 789 # [Integer] ID of pet that needs to be fetched @@ -286,6 +321,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" + + # Configure API key authorization: api_key + config.api_key['api_key'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['api_key'] = "Token" +end + api = Petstore::PetApi.new pet_id = 789 # [Integer] ID of pet that needs to be fetched @@ -328,6 +373,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" + + # Configure API key authorization: api_key + config.api_key['api_key'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['api_key'] = "Token" +end + api = Petstore::PetApi.new pet_id = 789 # [Integer] ID of pet that needs to be fetched @@ -370,6 +425,11 @@ Update an existing pet ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new opts = { @@ -413,6 +473,11 @@ Updates a pet in the store with form data ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new pet_id = "pet_id_example" # [String] ID of pet that needs to be updated @@ -461,6 +526,11 @@ uploads an image ### Example ```ruby +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = "YOUR ACCESS TOKEN" +end + api = Petstore::PetApi.new pet_id = 789 # [Integer] ID of pet to update diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 4655955d246..071a42e08ff 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -63,6 +63,18 @@ A single status value can be provided as a string ### Example ```ruby +Petstore.configure do |config| + # Configure API key authorization: test_api_client_id + config.api_key['x-test_api_client_id'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['x-test_api_client_id'] = "Token" + + # Configure API key authorization: test_api_client_secret + config.api_key['x-test_api_client_secret'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['x-test_api_client_secret'] = "Token" +end + api = Petstore::StoreApi.new opts = { @@ -106,6 +118,13 @@ Returns a map of status codes to quantities ### Example ```ruby +Petstore.configure do |config| + # Configure API key authorization: api_key + config.api_key['api_key'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['api_key'] = "Token" +end + api = Petstore::StoreApi.new begin @@ -142,6 +161,13 @@ Returns an arbitrary object which is actually a map of status codes to quantitie ### Example ```ruby +Petstore.configure do |config| + # Configure API key authorization: api_key + config.api_key['api_key'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['api_key'] = "Token" +end + api = Petstore::StoreApi.new begin @@ -178,6 +204,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w ### Example ```ruby +Petstore.configure do |config| + # Configure API key authorization: test_api_key_query + config.api_key['test_api_key_query'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['test_api_key_query'] = "Token" + + # Configure API key authorization: test_api_key_header + config.api_key['test_api_key_header'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['test_api_key_header'] = "Token" +end + api = Petstore::StoreApi.new order_id = "order_id_example" # [String] ID of pet that needs to be fetched @@ -220,6 +258,18 @@ Place an order for a pet ### Example ```ruby +Petstore.configure do |config| + # Configure API key authorization: test_api_client_id + config.api_key['x-test_api_client_id'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['x-test_api_client_id'] = "Token" + + # Configure API key authorization: test_api_client_secret + config.api_key['x-test_api_client_secret'] = "YOUR API KEY" + # Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil) + #config.api_key_prefix['x-test_api_client_secret'] = "Token" +end + api = Petstore::StoreApi.new opts = {