[ruby] Improve ruby client examples (#8040)

* [ruby] Improve ruby client examples

* samples

* quote fixes

* Keep enum value

* better string type handling

* fix failing tests

* add space after comment

* update samples

* use Time

Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
Hippolyte HENRY
2020-12-15 17:10:04 +01:00
committed by GitHub
parent 6f5076edb7
commit 81a5e44a6c
20 changed files with 397 additions and 199 deletions

View File

@@ -17,28 +17,20 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class RubyClientCodegen extends AbstractRubyCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
private static final String NUMERIC_ENUM_PREFIX = "N";
public static final String GEM_VERSION = "gemVersion";
public static final String GEM_LICENSE = "gemLicense";
public static final String GEM_REQUIRED_RUBY_VERSION = "gemRequiredRubyVersion";
@@ -49,7 +41,9 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
public static final String GEM_AUTHOR_EMAIL = "gemAuthorEmail";
public static final String FARADAY = "faraday";
public static final String TYPHOEUS = "typhoeus";
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
private static final String NUMERIC_ENUM_PREFIX = "N";
protected static int emptyMethodNameCounter = 0;
protected String gemName;
protected String moduleName;
protected String gemVersion = "1.0.0";
@@ -65,8 +59,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected static int emptyMethodNameCounter = 0;
public RubyClientCodegen() {
super();
@@ -266,7 +258,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
// for Faraday
additionalProperties.put("isFaraday", Boolean.TRUE);
} else {
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus are supported.");
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus are supported.");
}
// test files should not be overwritten
@@ -299,6 +291,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
* Generate Ruby module name from the gem name, e.g. use "OpenAPIClient" for "openapi_client".
*
* @param gemName Ruby gem name
*
* @return Ruby module naame
*/
@SuppressWarnings("static-method")
@@ -310,6 +303,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
* Generate Ruby gem name from the module name, e.g. use "openapi_client" for "OpenAPIClient".
*
* @param moduleName Ruby module naame
*
* @return Ruby gem name
*/
@SuppressWarnings("static-method")
@@ -413,7 +407,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
// replace - with _ e.g. created-at => created_at
String filename = name;
if (apiNameSuffix != null && apiNameSuffix.length() > 0) {
filename = filename + "_" + apiNameSuffix;
filename = filename + "_" + apiNameSuffix;
}
filename = filename.replaceAll("-", "_");
@@ -527,98 +521,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
return gemName + "/" + apiPackage() + "/" + toApiFilename(name);
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;
if (p.defaultValue == null) {
example = p.example;
} else {
p.example = p.defaultValue;
return;
}
String type = p.baseType;
if (type == null) {
type = p.dataType;
}
if ("String".equalsIgnoreCase(type)) {
if (example == null) {
example = p.paramName + "_example";
}
example = "'" + escapeText(example) + "'";
} else if ("Integer".equalsIgnoreCase(type)) {
if (example == null) {
example = "56";
}
} else if ("Float".equalsIgnoreCase(type)) {
if (example == null) {
example = "3.4";
}
} else if ("BOOLEAN".equalsIgnoreCase(type)) {
if (example == null) {
example = "true";
}
} else if ("File".equalsIgnoreCase(type)) {
if (example == null) {
example = "/path/to/file";
}
example = "File.new('" + escapeText(example) + "')";
} else if ("Date".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20";
}
example = "Date.parse('" + escapeText(example) + "')";
} else if ("Time".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20T19:20:30+01:00";
}
example = "Time.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.isArray)) {
example = "[" + example + "]";
} else if (Boolean.TRUE.equals(p.isMap)) {
example = "{'key' => " + example + "}";
}
p.example = example;
}
/**
* Return the example value of the parameter. Overrides the
* setParameterExampleValue(CodegenParameter, Parameter) method in
* DefaultCodegen to always call setParameterExampleValue(CodegenParameter)
* in this class, which adds single quotes around strings from the
* x-example property.
*
* @param codegenParameter Codegen parameter
* @param parameter Parameter
*/
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
if (parameter.getExample() != null) {
codegenParameter.example = parameter.getExample().toString();
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
Example example = parameter.getExamples().values().iterator().next();
if (example.getValue() != null) {
codegenParameter.example = example.getValue().toString();
}
} else {
Schema schema = parameter.getSchema();
if (schema != null && schema.getExample() != null) {
codegenParameter.example = schema.getExample().toString();
}
}
setParameterExampleValue(codegenParameter);
}
public void setGemName(String gemName) {
this.gemName = gemName;
}
@@ -667,4 +569,200 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
codegenModel.additionalPropertiesType = getSchemaType(additionalProperties);
}
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
HashMap<String, Integer> processedModelMaps = new HashMap<String, Integer>();
for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o;
CodegenModel m = (CodegenModel) h.get("model");
modelMaps.put(m.classname, m);
}
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
for (CodegenParameter p : op.allParams) {
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
}
processedModelMaps.clear();
for (CodegenParameter p : op.requiredParams) {
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
}
processedModelMaps.clear();
for (CodegenParameter p : op.optionalParams) {
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
}
processedModelMaps.clear();
for (CodegenParameter p : op.bodyParams) {
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
}
processedModelMaps.clear();
for (CodegenParameter p : op.pathParams) {
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
}
processedModelMaps.clear();
}
return objs;
}
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
if (codegenParameter.isArray) { // array
return "[" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "]";
} else if (codegenParameter.isMap) {
return "{ key: " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
} else if (codegenParameter.isPrimitiveType) { // primitive type
if (codegenParameter.isEnum) {
// When inline enum, set example to first allowable value
List<Object> values = (List<Object>) codegenParameter.allowableValues.get("values");
codegenParameter.example = String.valueOf(values.get(0));
}
if (codegenParameter.isString || "String".equalsIgnoreCase(codegenParameter.baseType)) {
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return "'" + codegenParameter.example + "'";
}
return "'" + codegenParameter.paramName + "_example'";
} else if (codegenParameter.isBoolean) { // boolean
if (Boolean.parseBoolean(codegenParameter.example)) {
return "true";
}
return "false";
} else if (codegenParameter.isUri) {
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return "'" + codegenParameter.example + "'";
}
return "'https://example.com'";
} else if (codegenParameter.isDateTime) {
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return "Time.parse('" + codegenParameter.example + "')";
}
return "Time.now";
} else if (codegenParameter.isDate) {
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return "Date.parse('" + codegenParameter.example + "')";
}
return "Date.today";
} else if (codegenParameter.isFile) {
return "File.new('/path/to/some/file')";
} else if (codegenParameter.isInteger) {
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return codegenParameter.example;
}
return "37";
} else { // number
if (!StringUtils.isEmpty(codegenParameter.example) && !"null".equals(codegenParameter.example)) {
return codegenParameter.example;
}
return "3.56";
}
} else { // model
// look up the model
if (modelMaps.containsKey(codegenParameter.dataType)) {
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
return "TODO";
}
}
}
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
if (codegenProperty.isArray) { // array
return "[" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "]";
} else if (codegenProperty.isMap) {
return "{ key: " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
} else if (codegenProperty.isPrimitiveType) { // primitive type
if (codegenProperty.isEnum) {
// When inline enum, set example to first allowable value
List<Object> values = (List<Object>) codegenProperty.allowableValues.get("values");
codegenProperty.example = String.valueOf(values.get(0));
}
if (codegenProperty.isString || "String".equalsIgnoreCase(codegenProperty.baseType)) {
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return "'" + codegenProperty.example + "'";
} else {
return "'" + codegenProperty.name + "_example'";
}
} else if (codegenProperty.isBoolean) { // boolean
if (Boolean.parseBoolean(codegenProperty.example)) {
return "true";
} else {
return "false";
}
} else if (codegenProperty.isUri) {
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return "'" + codegenProperty.example + "'";
}
return "'https://example.com'";
} else if (codegenProperty.isDateTime) {
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return "Time.parse('" + codegenProperty.example + "')";
}
return "Time.now";
} else if (codegenProperty.isDate) {
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return "Date.parse('" + codegenProperty.example + "')";
}
return "Date.today";
} else if (codegenProperty.isFile) {
return "File.new('/path/to/some/file')";
} else if (codegenProperty.isInteger) {
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return codegenProperty.example;
}
return "37";
} else { // number
if (!StringUtils.isEmpty(codegenProperty.example) && !"null".equals(codegenProperty.example)) {
return codegenProperty.example;
}
return "3.56";
}
} else { // model
// look up the model
if (modelMaps.containsKey(codegenProperty.dataType)) {
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
} else {
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
return "TODO";
}
}
}
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
// break infinite recursion. Return, in case a model is already processed in the current context.
String model = codegenModel.name;
if (processedModelMap.containsKey(model)) {
int count = processedModelMap.get(model);
if (count == 1) {
processedModelMap.put(model, 2);
} else if (count == 2) {
return "";
} else {
throw new RuntimeException("Invalid count when constructing example: " + count);
}
} else if (codegenModel.isEnum) {
List<Map<String, String>> enumVars = (List<Map<String, String>>) codegenModel.allowableValues.get("enumVars");
return moduleName + "::" + codegenModel.classname + "::" + enumVars.get(0).get("name");
} else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
String subModel = (String) codegenModel.oneOf.toArray()[0];
String oneOf = constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap);
return oneOf;
} else {
processedModelMap.put(model, 1);
}
List<String> propertyExamples = new ArrayList<>();
for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
propertyExamples.add(codegenProperty.name + ": " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
}
String example = moduleName + "::" + toModelName(model) + ".new";
if (!propertyExamples.isEmpty()) {
example += "({" + StringUtils.join(propertyExamples, ", ") + "})";
}
return example;
}
}

View File

@@ -82,13 +82,13 @@ require '{{{gemName}}}'
api_instance = {{{moduleName}}}::{{{classname}}}.new
{{#requiredParams}}
{{{paramName}}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{{paramName}}} = {{{vendorExtensions.x-ruby-example}}} # {{{dataType}}} | {{{description}}}
{{/requiredParams}}
{{#optionalParams}}
{{#-first}}
opts = {
{{/-first}}
{{{paramName}}}: {{{example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
{{#-last}}
}
{{/-last}}

View File

@@ -26,6 +26,7 @@ All URIs are relative to *{{basePath}}*
### Examples
```ruby
require 'time'
require '{{{gemName}}}'
{{#hasAuthMethods}}
# setup authorization
@@ -38,7 +39,7 @@ require '{{{gemName}}}'
# 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. 'Bearer' (defaults to nil)
#config.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
# config.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
# Configure OAuth2 access token for authorization: {{{name}}}
config.access_token = 'YOUR ACCESS TOKEN'{{/isOAuth}}
{{/authMethods}}end
@@ -46,13 +47,13 @@ require '{{{gemName}}}'
api_instance = {{{moduleName}}}::{{{classname}}}.new
{{#requiredParams}}
{{{paramName}}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{{paramName}}} = {{{vendorExtensions.x-ruby-example}}} # {{{dataType}}} | {{{description}}}
{{/requiredParams}}
{{#optionalParams}}
{{#-first}}
opts = {
{{/-first}}
{{{paramName}}}: {{{example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
{{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}}
{{#-last}}
}
{{/-last}}

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen.ruby;
import com.google.common.collect.ImmutableMap;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
@@ -29,12 +30,8 @@ import org.testng.annotations.Test;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.TreeSet;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -157,12 +154,22 @@ public class RubyClientCodegenTest {
final RubyClientCodegen codegen = new RubyClientCodegen();
codegen.setModuleName("OnlinePetstore");
codegen.setOpenAPI(openAPI);
final String path = "/pet";
final Operation p = openAPI.getPaths().get(path).getPost();
Schema schema = openAPI.getComponents().getSchemas().get("Pet");
CodegenModel model = codegen.fromModel("Pet", schema);
Map<String, Object> modelMap = new HashMap<>();
modelMap.put("model", model);
final CodegenOperation op = codegen.fromOperation(path, "post", p, null);
Assert.assertEquals(op.bodyParams.size(), 1);
CodegenParameter bp = op.bodyParams.get(0);
Assert.assertEquals(bp.example, "OnlinePetstore::Pet.new");
Map<String, Object> operations = ImmutableMap.<String, Object>of("operation", Collections.singletonList(op));
Map<String, Object> objs = ImmutableMap.of("operations", operations, "imports", new ArrayList<Map<String, String>>());
objs = codegen.postProcessOperationsWithModels(objs, Collections.singletonList(modelMap));
CodegenOperation postProcessedOp = ((List<CodegenOperation>) ((Map<String, Object>) objs.get("operations")).get("operation")).get(0);
Assert.assertEquals(postProcessedOp.bodyParams.size(), 1);
CodegenParameter bp = postProcessedOp.bodyParams.get(0);
Assert.assertEquals(bp.vendorExtensions.get("x-ruby-example"), "OnlinePetstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']})");
}
@@ -620,8 +627,13 @@ public class RubyClientCodegenTest {
final Operation p = openAPI.getPaths().get(path).getDelete();
final CodegenOperation op = codegen.fromOperation(path, "delete", p, null);
CodegenParameter pp = op.pathParams.get(0);
Assert.assertEquals(pp.example, "'orderid123'");
Map<String, Object> operations = ImmutableMap.<String, Object>of("operation", Collections.singletonList(op));
Map<String, Object> objs = ImmutableMap.of("operations", operations, "imports", new ArrayList<Map<String, String>>());
objs = codegen.postProcessOperationsWithModels(objs, Collections.emptyList());
CodegenOperation postProcessedOp = ((List<CodegenOperation>) ((Map<String, Object>) objs.get("operations")).get("operation")).get(0);
CodegenParameter pp = postProcessedOp.pathParams.get(0);
Assert.assertEquals(pp.vendorExtensions.get("x-ruby-example"), "'orderid123'");
}
@Test(description = "test example string imported from example in schema (OAS3)")
@@ -635,8 +647,13 @@ public class RubyClientCodegenTest {
final Operation p = openAPI.getPaths().get(path).getDelete();
final CodegenOperation op = codegen.fromOperation(path, "delete", p, null);
CodegenParameter pp = op.pathParams.get(0);
Assert.assertEquals(pp.example, "'orderid123'");
Map<String, Object> operations = ImmutableMap.<String, Object>of("operation", Collections.singletonList(op));
Map<String, Object> objs = ImmutableMap.of("operations", operations, "imports", new ArrayList<Map<String, String>>());
objs = codegen.postProcessOperationsWithModels(objs, Collections.emptyList());
CodegenOperation postProcessedOp = ((List<CodegenOperation>) ((Map<String, Object>) objs.get("operations")).get("operation")).get(0);
CodegenParameter pp = postProcessedOp.pathParams.get(0);
Assert.assertEquals(pp.vendorExtensions.get("x-ruby-example"), "'orderid123'");
}
/**

View File

@@ -18,6 +18,7 @@ To test special tags and operation ID starting with number
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::AnotherFakeApi.new

View File

@@ -16,6 +16,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::DefaultApi.new

View File

@@ -30,6 +30,7 @@ Health check endpoint
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -88,13 +89,14 @@ test http signature authentication
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
end
api_instance = Petstore::FakeApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
opts = {
query_1: 'query_1_example', # String | query parameter
header_1: 'header_1_example' # String | header parameter
@@ -159,6 +161,7 @@ Test serialization of outer boolean types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -224,6 +227,7 @@ Test serialization of object with outer number type
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -289,11 +293,12 @@ Test serialization of outer number types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
body: 3.4 # Float | Input number as post body
body: 8.14 # Float | Input number as post body
}
begin
@@ -354,6 +359,7 @@ Test serialization of outer string types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -419,6 +425,7 @@ For this test, the body for this request much reference a schema named `File`.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -479,6 +486,7 @@ No authorization required
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -543,6 +551,7 @@ To test \"client\" model
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -606,6 +615,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -615,17 +625,17 @@ Petstore.configure do |config|
end
api_instance = Petstore::FakeApi.new
number = 3.4 # Float | None
double = 3.4 # Float | None
number = 8.14 # Float | None
double = 1.2 # Float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # String | None
byte = 'byte_example' # String | None
byte = 'BYTE_ARRAY_DATA_HERE' # String | None
opts = {
integer: 56, # Integer | None
int32: 56, # Integer | None
int64: 56, # Integer | None
int64: 789, # Integer | None
float: 3.4, # Float | None
string: 'string_example', # String | None
binary: File.new('/path/to/file'), # File | None
binary: File.new('/path/to/some/file'), # File | None
date: Date.parse('2013-10-20'), # Date | None
date_time: Time.parse('2013-10-20T19:20:30+01:00'), # Time | None
password: 'password_example', # String | None
@@ -702,18 +712,19 @@ To test enum parameters
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
enum_header_string_array: ['enum_header_string_array_example'], # Array<String> | Header parameter enum test (string array)
enum_header_string: '-efg', # String | Header parameter enum test (string)
enum_query_string_array: ['enum_query_string_array_example'], # Array<String> | Query parameter enum test (string array)
enum_query_string: '-efg', # String | Query parameter enum test (string)
enum_query_integer: 56, # Integer | Query parameter enum test (double)
enum_query_double: 3.4, # Float | Query parameter enum test (double)
enum_form_string_array: '$', # Array<String> | Form parameter enum test (string array)
enum_form_string: '-efg' # String | Form parameter enum test (string)
enum_header_string_array: ['>'], # Array<String> | Header parameter enum test (string array)
enum_header_string: '_abc', # String | Header parameter enum test (string)
enum_query_string_array: ['>'], # Array<String> | Query parameter enum test (string array)
enum_query_string: '_abc', # String | Query parameter enum test (string)
enum_query_integer: 1, # Integer | Query parameter enum test (double)
enum_query_double: 1.1, # Float | Query parameter enum test (double)
enum_form_string_array: ['>'], # Array<String> | Form parameter enum test (string array)
enum_form_string: '_abc' # String | Form parameter enum test (string)
}
begin
@@ -780,6 +791,7 @@ Fake endpoint to test group parameters (optional)
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -790,11 +802,11 @@ end
api_instance = Petstore::FakeApi.new
required_string_group = 56 # Integer | Required String in group parameters
required_boolean_group = true # Boolean | Required Boolean in group parameters
required_int64_group = 56 # Integer | Required Integer in group parameters
required_int64_group = 789 # Integer | Required Integer in group parameters
opts = {
string_group: 56, # Integer | String in group parameters
boolean_group: true, # Boolean | Boolean in group parameters
int64_group: 56 # Integer | Integer in group parameters
int64_group: 789 # Integer | Integer in group parameters
}
begin
@@ -857,10 +869,11 @@ test inline additionalProperties
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
request_body = {'key' => 'request_body_example'} # Hash<String, String> | request body
request_body = { key: 'inner_example'} # Hash<String, String> | request body
begin
# test inline additionalProperties
@@ -917,6 +930,7 @@ test json serialization of form data
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -981,14 +995,15 @@ To test the collection format in query parameters
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
pipe = ['pipe_example'] # Array<String> |
ioutil = ['ioutil_example'] # Array<String> |
http = ['http_example'] # Array<String> |
url = ['url_example'] # Array<String> |
context = ['context_example'] # Array<String> |
pipe = ['inner_example'] # Array<String> |
ioutil = ['inner_example'] # Array<String> |
http = ['inner_example'] # Array<String> |
url = ['inner_example'] # Array<String> |
context = ['inner_example'] # Array<String> |
begin

View File

@@ -18,13 +18,14 @@ To test class name in snake case
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
# Configure API key authorization: api_key_query
config.api_key['api_key_query'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key_query'] = 'Bearer'
# config.api_key_prefix['api_key_query'] = 'Bearer'
end
api_instance = Petstore::FakeClassnameTags123Api.new

View File

@@ -24,6 +24,7 @@ Add a new pet to the store
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -32,7 +33,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
begin
# Add a new pet to the store
@@ -89,6 +90,7 @@ Deletes a pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -97,7 +99,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | Pet id to delete
pet_id = 789 # Integer | Pet id to delete
opts = {
api_key: 'api_key_example' # String |
}
@@ -160,6 +162,7 @@ Multiple status values can be provided with comma separated strings
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -168,7 +171,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
status = ['status_example'] # Array<String> | Status values that need to be considered for filter
status = ['available'] # Array<String> | Status values that need to be considered for filter
begin
# Finds Pets by status
@@ -228,6 +231,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -236,7 +240,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
tags = ['tags_example'] # Array<String> | Tags to filter by
tags = ['inner_example'] # Array<String> | Tags to filter by
begin
# Finds Pets by tags
@@ -296,17 +300,18 @@ Returns a single pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
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. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key'] = 'Bearer'
# config.api_key_prefix['api_key'] = 'Bearer'
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to return
pet_id = 789 # Integer | ID of pet to return
begin
# Find pet by ID
@@ -364,6 +369,7 @@ Update an existing pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -372,7 +378,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
begin
# Update an existing pet
@@ -429,6 +435,7 @@ Updates a pet in the store with form data
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -437,7 +444,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet that needs to be updated
pet_id = 789 # Integer | ID of pet that needs to be updated
opts = {
name: 'name_example', # String | Updated name of the pet
status: 'status_example' # String | Updated status of the pet
@@ -500,6 +507,7 @@ uploads an image
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -508,10 +516,10 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to update
pet_id = 789 # Integer | ID of pet to update
opts = {
additional_metadata: 'additional_metadata_example', # String | Additional data to pass to server
file: File.new('/path/to/file') # File | file to upload
file: File.new('/path/to/some/file') # File | file to upload
}
begin
@@ -572,6 +580,7 @@ uploads an image (required)
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -580,8 +589,8 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to update
required_file = File.new('/path/to/file') # File | file to upload
pet_id = 789 # Integer | ID of pet to update
required_file = File.new('/path/to/some/file') # File | file to upload
opts = {
additional_metadata: 'additional_metadata_example' # String | Additional data to pass to server
}

View File

@@ -21,6 +21,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new
@@ -83,13 +84,14 @@ Returns a map of status codes to quantities
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
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. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key'] = 'Bearer'
# config.api_key_prefix['api_key'] = 'Bearer'
end
api_instance = Petstore::StoreApi.new
@@ -150,10 +152,11 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new
order_id = 56 # Integer | ID of pet that needs to be fetched
order_id = 789 # Integer | ID of pet that needs to be fetched
begin
# Find purchase order by ID
@@ -211,6 +214,7 @@ Place an order for a pet
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new

View File

@@ -25,6 +25,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -85,6 +86,7 @@ Creates list of users with given input array
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -145,6 +147,7 @@ Creates list of users with given input array
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -207,6 +210,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -267,6 +271,7 @@ Get user by user name
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -328,6 +333,7 @@ Logs user into the system
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -391,6 +397,7 @@ Logs out current logged in user session
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -450,6 +457,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new

View File

@@ -18,6 +18,7 @@ To test special tags and operation ID starting with number
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::AnotherFakeApi.new

View File

@@ -16,6 +16,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::DefaultApi.new

View File

@@ -30,6 +30,7 @@ Health check endpoint
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -88,13 +89,14 @@ test http signature authentication
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
end
api_instance = Petstore::FakeApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
opts = {
query_1: 'query_1_example', # String | query parameter
header_1: 'header_1_example' # String | header parameter
@@ -159,6 +161,7 @@ Test serialization of outer boolean types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -224,6 +227,7 @@ Test serialization of object with outer number type
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -289,11 +293,12 @@ Test serialization of outer number types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
body: 3.4 # Float | Input number as post body
body: 8.14 # Float | Input number as post body
}
begin
@@ -354,6 +359,7 @@ Test serialization of outer string types
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -419,6 +425,7 @@ For this test, the body for this request much reference a schema named `File`.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -479,6 +486,7 @@ No authorization required
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -543,6 +551,7 @@ To test \"client\" model
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -606,6 +615,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -615,17 +625,17 @@ Petstore.configure do |config|
end
api_instance = Petstore::FakeApi.new
number = 3.4 # Float | None
double = 3.4 # Float | None
number = 8.14 # Float | None
double = 1.2 # Float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # String | None
byte = 'byte_example' # String | None
byte = 'BYTE_ARRAY_DATA_HERE' # String | None
opts = {
integer: 56, # Integer | None
int32: 56, # Integer | None
int64: 56, # Integer | None
int64: 789, # Integer | None
float: 3.4, # Float | None
string: 'string_example', # String | None
binary: File.new('/path/to/file'), # File | None
binary: File.new('/path/to/some/file'), # File | None
date: Date.parse('2013-10-20'), # Date | None
date_time: Time.parse('2013-10-20T19:20:30+01:00'), # Time | None
password: 'password_example', # String | None
@@ -702,18 +712,19 @@ To test enum parameters
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
enum_header_string_array: ['enum_header_string_array_example'], # Array<String> | Header parameter enum test (string array)
enum_header_string: '-efg', # String | Header parameter enum test (string)
enum_query_string_array: ['enum_query_string_array_example'], # Array<String> | Query parameter enum test (string array)
enum_query_string: '-efg', # String | Query parameter enum test (string)
enum_query_integer: 56, # Integer | Query parameter enum test (double)
enum_query_double: 3.4, # Float | Query parameter enum test (double)
enum_form_string_array: '$', # Array<String> | Form parameter enum test (string array)
enum_form_string: '-efg' # String | Form parameter enum test (string)
enum_header_string_array: ['>'], # Array<String> | Header parameter enum test (string array)
enum_header_string: '_abc', # String | Header parameter enum test (string)
enum_query_string_array: ['>'], # Array<String> | Query parameter enum test (string array)
enum_query_string: '_abc', # String | Query parameter enum test (string)
enum_query_integer: 1, # Integer | Query parameter enum test (double)
enum_query_double: 1.1, # Float | Query parameter enum test (double)
enum_form_string_array: ['>'], # Array<String> | Form parameter enum test (string array)
enum_form_string: '_abc' # String | Form parameter enum test (string)
}
begin
@@ -780,6 +791,7 @@ Fake endpoint to test group parameters (optional)
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -790,11 +802,11 @@ end
api_instance = Petstore::FakeApi.new
required_string_group = 56 # Integer | Required String in group parameters
required_boolean_group = true # Boolean | Required Boolean in group parameters
required_int64_group = 56 # Integer | Required Integer in group parameters
required_int64_group = 789 # Integer | Required Integer in group parameters
opts = {
string_group: 56, # Integer | String in group parameters
boolean_group: true, # Boolean | Boolean in group parameters
int64_group: 56 # Integer | Integer in group parameters
int64_group: 789 # Integer | Integer in group parameters
}
begin
@@ -857,10 +869,11 @@ test inline additionalProperties
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
request_body = {'key' => 'request_body_example'} # Hash<String, String> | request body
request_body = { key: 'inner_example'} # Hash<String, String> | request body
begin
# test inline additionalProperties
@@ -917,6 +930,7 @@ test json serialization of form data
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
@@ -981,14 +995,15 @@ To test the collection format in query parameters
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::FakeApi.new
pipe = ['pipe_example'] # Array<String> |
ioutil = ['ioutil_example'] # Array<String> |
http = ['http_example'] # Array<String> |
url = ['url_example'] # Array<String> |
context = ['context_example'] # Array<String> |
pipe = ['inner_example'] # Array<String> |
ioutil = ['inner_example'] # Array<String> |
http = ['inner_example'] # Array<String> |
url = ['inner_example'] # Array<String> |
context = ['inner_example'] # Array<String> |
begin

View File

@@ -18,13 +18,14 @@ To test class name in snake case
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
# Configure API key authorization: api_key_query
config.api_key['api_key_query'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key_query'] = 'Bearer'
# config.api_key_prefix['api_key_query'] = 'Bearer'
end
api_instance = Petstore::FakeClassnameTags123Api.new

View File

@@ -24,6 +24,7 @@ Add a new pet to the store
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -32,7 +33,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
begin
# Add a new pet to the store
@@ -89,6 +90,7 @@ Deletes a pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -97,7 +99,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | Pet id to delete
pet_id = 789 # Integer | Pet id to delete
opts = {
api_key: 'api_key_example' # String |
}
@@ -160,6 +162,7 @@ Multiple status values can be provided with comma separated strings
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -168,7 +171,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
status = ['status_example'] # Array<String> | Status values that need to be considered for filter
status = ['available'] # Array<String> | Status values that need to be considered for filter
begin
# Finds Pets by status
@@ -228,6 +231,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -236,7 +240,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
tags = ['tags_example'] # Array<String> | Tags to filter by
tags = ['inner_example'] # Array<String> | Tags to filter by
begin
# Finds Pets by tags
@@ -296,17 +300,18 @@ Returns a single pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
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. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key'] = 'Bearer'
# config.api_key_prefix['api_key'] = 'Bearer'
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to return
pet_id = 789 # Integer | ID of pet to return
begin
# Find pet by ID
@@ -364,6 +369,7 @@ Update an existing pet
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -372,7 +378,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
pet = Petstore::Pet.new({name: 'doggie', photo_urls: ['photo_urls_example']}) # Pet | Pet object that needs to be added to the store
begin
# Update an existing pet
@@ -429,6 +435,7 @@ Updates a pet in the store with form data
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -437,7 +444,7 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet that needs to be updated
pet_id = 789 # Integer | ID of pet that needs to be updated
opts = {
name: 'name_example', # String | Updated name of the pet
status: 'status_example' # String | Updated status of the pet
@@ -500,6 +507,7 @@ uploads an image
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -508,10 +516,10 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to update
pet_id = 789 # Integer | ID of pet to update
opts = {
additional_metadata: 'additional_metadata_example', # String | Additional data to pass to server
file: File.new('/path/to/file') # File | file to upload
file: File.new('/path/to/some/file') # File | file to upload
}
begin
@@ -572,6 +580,7 @@ uploads an image (required)
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
Petstore.configure do |config|
@@ -580,8 +589,8 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet_id = 56 # Integer | ID of pet to update
required_file = File.new('/path/to/file') # File | file to upload
pet_id = 789 # Integer | ID of pet to update
required_file = File.new('/path/to/some/file') # File | file to upload
opts = {
additional_metadata: 'additional_metadata_example' # String | Additional data to pass to server
}

View File

@@ -21,6 +21,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new
@@ -83,13 +84,14 @@ Returns a map of status codes to quantities
### Examples
```ruby
require 'time'
require 'petstore'
# setup authorization
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. 'Bearer' (defaults to nil)
#config.api_key_prefix['api_key'] = 'Bearer'
# config.api_key_prefix['api_key'] = 'Bearer'
end
api_instance = Petstore::StoreApi.new
@@ -150,10 +152,11 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new
order_id = 56 # Integer | ID of pet that needs to be fetched
order_id = 789 # Integer | ID of pet that needs to be fetched
begin
# Find purchase order by ID
@@ -211,6 +214,7 @@ Place an order for a pet
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::StoreApi.new

View File

@@ -25,6 +25,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -85,6 +86,7 @@ Creates list of users with given input array
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -145,6 +147,7 @@ Creates list of users with given input array
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -207,6 +210,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -267,6 +271,7 @@ Get user by user name
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -328,6 +333,7 @@ Logs user into the system
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -391,6 +397,7 @@ Logs out current logged in user session
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new
@@ -450,6 +457,7 @@ This can only be done by the logged in user.
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UserApi.new

View File

@@ -19,6 +19,7 @@ Use custom server
### Examples
```ruby
require 'time'
require 'dynamic_servers'
api_instance = DynamicServers::UsageApi.new
@@ -79,6 +80,7 @@ Use default server
### Examples
```ruby
require 'time'
require 'dynamic_servers'
api_instance = DynamicServers::UsageApi.new

View File

@@ -19,6 +19,7 @@ Use alias to array
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UsageApi.new
@@ -84,6 +85,7 @@ Use alias to map
### Examples
```ruby
require 'time'
require 'petstore'
api_instance = Petstore::UsageApi.new