forked from loafle/openapi-generator-original
[Rust] Client library choice between hyper and reqwest (#1258)
* Port of PR https://github.com/swagger-api/swagger-codegen/pull/8804. * Correction of conflict with PR #528 (missing template file). * Add rust-reqwest samples to Circle CI tests. * Add integration test pom.xml file with launcher to trigger cargo execution. * Deduplicate Maven project name. * Fix "api_key" header for Petstore. * Better API key management. * Fix query param for lists of objects other than strings (numbers, etc.). * Update to reqwest 0.9, and refactor of header management (using reqwest transition feature). * Merge scripts generating rust-hyper and rust-reqwest samples. * Consistent full stops. * Use raw variables in all Rust mustache templates. * Replace production build in CI with a quick simple check. * Update samples. * Finish Reqwest 0.9 migration (removing "hyper 0.11" transition feature). * Configuration implements Default trait. * API template reorganized: HashMap is not required anymore. * Revert "Merge scripts generating rust-hyper and rust-reqwest samples." This reverts commit 970f996566a740045f2a986fd70fc70f11952925. * Remove deprecated "-XX:MaxPermSize" java arg.
This commit is contained in:
parent
eb4dfe0fc1
commit
f4eb96933a
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust -DpackageName=petstore_client $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust -DpackageName=petstore_client --library=hyper $@"
|
||||||
|
|
||||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||||
|
32
bin/rust-reqwest-petstore.sh
Executable file
32
bin/rust-reqwest-petstore.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=$(ls -ld "$SCRIPT")
|
||||||
|
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=$(dirname "$SCRIPT")/..
|
||||||
|
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust-reqwest -DpackageName=petstore_client --library=reqwest $@"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
@ -17,27 +17,17 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.CliOption;
|
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
|
||||||
import org.openapitools.codegen.CodegenType;
|
|
||||||
import org.openapitools.codegen.DefaultCodegen;
|
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
import org.openapitools.codegen.utils.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
@ -45,6 +35,9 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public static final String PACKAGE_NAME = "packageName";
|
public static final String PACKAGE_NAME = "packageName";
|
||||||
public static final String PACKAGE_VERSION = "packageVersion";
|
public static final String PACKAGE_VERSION = "packageVersion";
|
||||||
|
|
||||||
|
public static final String HYPER_LIBRARY = "hyper";
|
||||||
|
public static final String REQWEST_LIBRARY = "reqwest";
|
||||||
|
|
||||||
protected String packageName = "openapi";
|
protected String packageName = "openapi";
|
||||||
protected String packageVersion = "1.0.0";
|
protected String packageVersion = "1.0.0";
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
@ -68,7 +61,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
super();
|
super();
|
||||||
outputFolder = "generated-code/rust";
|
outputFolder = "generated-code/rust";
|
||||||
modelTemplateFiles.put("model.mustache", ".rs");
|
modelTemplateFiles.put("model.mustache", ".rs");
|
||||||
apiTemplateFiles.put("api.mustache", ".rs");
|
|
||||||
|
|
||||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
@ -141,6 +133,15 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
|
|
||||||
|
supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper.");
|
||||||
|
supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest.");
|
||||||
|
|
||||||
|
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use.");
|
||||||
|
libraryOption.setEnum(supportedLibraries);
|
||||||
|
// set hyper as the default
|
||||||
|
libraryOption.setDefault(HYPER_LIBRARY);
|
||||||
|
cliOptions.add(libraryOption);
|
||||||
|
setLibrary(HYPER_LIBRARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,21 +166,34 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
|
if ( HYPER_LIBRARY.equals(getLibrary())){
|
||||||
|
additionalProperties.put(HYPER_LIBRARY, "true");
|
||||||
|
} else if (REQWEST_LIBRARY.equals(getLibrary())) {
|
||||||
|
additionalProperties.put(REQWEST_LIBRARY, "true");
|
||||||
|
} else {
|
||||||
|
LOGGER.error("Unknown library option (-l/--library): {}", getLibrary());
|
||||||
|
}
|
||||||
|
|
||||||
|
apiTemplateFiles.put(getLibrary() + "/api.mustache", ".rs");
|
||||||
|
|
||||||
modelPackage = packageName;
|
modelPackage = packageName;
|
||||||
apiPackage = packageName;
|
apiPackage = packageName;
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
supportingFiles.add(new SupportingFile("configuration.mustache", apiFolder, "configuration.rs"));
|
|
||||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("api_mod.mustache", apiFolder, "mod.rs"));
|
|
||||||
supportingFiles.add(new SupportingFile("client.mustache", apiFolder, "client.rs"));
|
|
||||||
supportingFiles.add(new SupportingFile("request.rs", apiFolder, "request.rs"));
|
|
||||||
supportingFiles.add(new SupportingFile("model_mod.mustache", modelFolder, "mod.rs"));
|
supportingFiles.add(new SupportingFile("model_mod.mustache", modelFolder, "mod.rs"));
|
||||||
supportingFiles.add(new SupportingFile("lib.rs", "src", "lib.rs"));
|
supportingFiles.add(new SupportingFile("lib.mustache", "src", "lib.rs"));
|
||||||
supportingFiles.add(new SupportingFile("Cargo.mustache", "", "Cargo.toml"));
|
supportingFiles.add(new SupportingFile("Cargo.mustache", "", "Cargo.toml"));
|
||||||
|
|
||||||
|
if (HYPER_LIBRARY.equals(getLibrary())) {
|
||||||
|
supportingFiles.add(new SupportingFile("request.rs", apiFolder, "request.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile(getLibrary() + "/configuration.mustache", apiFolder, "configuration.rs"));
|
||||||
|
supportingFiles.add(new SupportingFile(getLibrary() + "/client.mustache", apiFolder, "client.rs"));
|
||||||
|
supportingFiles.add(new SupportingFile(getLibrary() + "/api_mod.mustache", apiFolder, "mod.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -209,7 +223,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return name;
|
return name;
|
||||||
|
|
||||||
// snake_case, e.g. PetId => pet_id
|
// snake_case, e.g. PetId => pet_id
|
||||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
name = StringUtils.underscore(name);
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word or word starting with number, append _
|
||||||
if (isReservedWord(name))
|
if (isReservedWord(name))
|
||||||
@ -231,16 +245,17 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public String toModelName(String name) {
|
public String toModelName(String name) {
|
||||||
// camelize the model name
|
// camelize the model name
|
||||||
// phone_number => PhoneNumber
|
// phone_number => PhoneNumber
|
||||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelFilename(name));
|
return StringUtils.camelize(toModelFilename(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelFilename(String name) {
|
public String toModelFilename(String name) {
|
||||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
|
||||||
|
if (!Strings.isNullOrEmpty(modelNamePrefix)) {
|
||||||
name = modelNamePrefix + "_" + name;
|
name = modelNamePrefix + "_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
if (!Strings.isNullOrEmpty(modelNameSuffix)) {
|
||||||
name = name + "_" + modelNameSuffix;
|
name = name + "_" + modelNameSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +273,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||||
}
|
}
|
||||||
|
|
||||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
return StringUtils.underscore(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -267,7 +282,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
// e.g. PetApi.rs => pet_api.rs
|
// e.g. PetApi.rs => pet_api.rs
|
||||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
return StringUtils.underscore(name) + "_api";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -340,11 +355,11 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
// method name cannot use reserved keyword, e.g. return
|
||||||
if (isReservedWord(sanitizedOperationId)) {
|
if (isReservedWord(sanitizedOperationId)) {
|
||||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId));
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + StringUtils.underscore("call_" + operationId));
|
||||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizedOperationId);
|
return StringUtils.underscore(sanitizedOperationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -353,9 +368,15 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
Set<String> headerKeys = new HashSet<>();
|
||||||
for (CodegenOperation operation : operations) {
|
for (CodegenOperation operation : operations) {
|
||||||
// http method verb conversion (e.g. PUT => Put)
|
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
|
||||||
operation.httpMethod = org.openapitools.codegen.utils.StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
if (HYPER_LIBRARY.equals(getLibrary())) {
|
||||||
|
operation.httpMethod = StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||||
|
} else if (REQWEST_LIBRARY.equals(getLibrary())) {
|
||||||
|
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
// update return type to conform to rust standard
|
// update return type to conform to rust standard
|
||||||
/*
|
/*
|
||||||
if (operation.returnType != null) {
|
if (operation.returnType != null) {
|
||||||
@ -407,6 +428,9 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
additionalProperties.put("headerKeys", headerKeys);
|
||||||
|
additionalProperties.putIfAbsent("authHeaderKey", "api-key");
|
||||||
|
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,14 +4,21 @@ version = "{{{packageVersion}}}"
|
|||||||
authors = ["OpenAPI Generator team and contributors"]
|
authors = ["OpenAPI Generator team and contributors"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0"
|
serde = "^1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "^1.0"
|
||||||
serde_yaml = "0.7"
|
serde_json = "^1.0"
|
||||||
serde_json = "1.0"
|
|
||||||
base64 = "~0.7.0"
|
|
||||||
futures = "0.1.16"
|
|
||||||
hyper = "0.11.6"
|
|
||||||
url = "1.5"
|
url = "1.5"
|
||||||
|
{{#hyper}}
|
||||||
|
hyper = "~0.11"
|
||||||
|
serde_yaml = "0.7"
|
||||||
|
base64 = "~0.7.0"
|
||||||
|
futures = "0.1.23"
|
||||||
|
{{/hyper}}
|
||||||
|
{{#reqwest}}
|
||||||
|
reqwest = "~0.9"
|
||||||
|
{{/reqwest}}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
{{#hyper}}
|
||||||
tokio-core = "*"
|
tokio-core = "*"
|
||||||
|
{{/hyper}}
|
@ -1,4 +1,4 @@
|
|||||||
# Rust API client for {{packageName}}
|
# Rust API client for {{{packageName}}}
|
||||||
|
|
||||||
{{#appDescription}}
|
{{#appDescription}}
|
||||||
{{{appDescription}}}
|
{{{appDescription}}}
|
||||||
@ -7,12 +7,12 @@
|
|||||||
## Overview
|
## Overview
|
||||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
|
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
|
||||||
|
|
||||||
- API version: {{appVersion}}
|
- API version: {{{appVersion}}}
|
||||||
- Package version: {{packageVersion}}
|
- Package version: {{{packageVersion}}}
|
||||||
{{^hideGenerationTimestamp}}
|
{{^hideGenerationTimestamp}}
|
||||||
- Build date: {{generatedDate}}
|
- Build date: {{{generatedDate}}}
|
||||||
{{/hideGenerationTimestamp}}
|
{{/hideGenerationTimestamp}}
|
||||||
- Build package: {{generatorClass}}
|
- Build package: {{{generatorClass}}}
|
||||||
{{#infoUrl}}
|
{{#infoUrl}}
|
||||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||||
{{/infoUrl}}
|
{{/infoUrl}}
|
||||||
@ -20,21 +20,21 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|||||||
## Installation
|
## Installation
|
||||||
Put the package under your project folder and add the following in import:
|
Put the package under your project folder and add the following in import:
|
||||||
```
|
```
|
||||||
"./{{packageName}}"
|
"./{{{packageName}}}"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
All URIs are relative to *{{basePath}}*
|
All URIs are relative to *{{{basePath}}}*
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{{classname}}}* | [**{{{operationId}}}**]({{{apiDocPath}}}{{classname}}.md#{{{operationIdLowerCase}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||||
|
|
||||||
## Documentation For Models
|
## Documentation For Models
|
||||||
|
|
||||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
{{#models}}{{#model}} - [{{{classname}}}]({{{modelDocPath}}}{{{classname}}}.md)
|
||||||
{{/model}}{{/models}}
|
{{/model}}{{/models}}
|
||||||
|
|
||||||
## Documentation For Authorization
|
## Documentation For Authorization
|
||||||
@ -92,5 +92,5 @@ Or via OAuth2 module to automatically refresh tokens and perform user authentica
|
|||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
{{#apiInfo}}{{#apis}}{{^hasMore}}{{{infoEmail}}}
|
||||||
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
# {{invokerPackage}}\{{classname}}{{#description}}
|
# {{{invokerPackage}}}\{{{classname}}}{{#description}}
|
||||||
{{description}}{{/description}}
|
{{{description}}}{{/description}}
|
||||||
|
|
||||||
All URIs are relative to *{{basePath}}*
|
All URIs are relative to *{{{basePath}}}*
|
||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
{{#operations}}{{#operation}}[**{{{operationId}}}**]({{{classname}}}.md#{{{operationId}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
# **{{{operationId}}}**
|
# **{{{operationId}}}**
|
||||||
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#authMethods}}ctx, {{/authMethods}}{{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
|
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#authMethods}}ctx, {{/authMethods}}{{#allParams}}{{#required}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
|
||||||
{{{summary}}}{{#notes}}
|
{{{summary}}}{{#notes}}
|
||||||
|
|
||||||
{{{notes}}}{{/notes}}
|
{{{notes}}}{{/notes}}
|
||||||
@ -21,7 +21,7 @@ Method | HTTP request | Description
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------{{#authMethods}}
|
------------- | ------------- | ------------- | -------------{{#authMethods}}
|
||||||
**ctx** | **context.Context** | context containing the authentication | nil if no authentication{{/authMethods}}{{/-last}}{{/allParams}}{{#allParams}}{{#required}}
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication{{/authMethods}}{{/-last}}{{/allParams}}{{#allParams}}{{#required}}
|
||||||
**{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
|
**{{{paramName}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}| {{{description}}} | {{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
|
||||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||||
|
|
||||||
### Optional Parameters
|
### Optional Parameters
|
||||||
@ -29,11 +29,11 @@ Optional parameters are passed through a map[string]interface{}.
|
|||||||
{{#allParams}}{{#-last}}
|
{{#allParams}}{{#-last}}
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
|
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
|
||||||
**{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}}
|
**{{{paramName}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}| {{{description}}} | {{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}}
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
|
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{{returnBaseType}}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
|
||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
|
@ -21,20 +21,20 @@ impl<C: hyper::client::Connect> {{{classname}}}Client<C> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait {{classname}} {
|
pub trait {{{classname}}} {
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error<serde_json::Value>>>;
|
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error<serde_json::Value>>>;
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<C: hyper::client::Connect>{{classname}} for {{classname}}Client<C> {
|
impl<C: hyper::client::Connect>{{{classname}}} for {{{classname}}}Client<C> {
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
|
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
|
||||||
__internal_request::Request::new(hyper::Method::{{httpMethod}}, "{{{path}}}".to_string())
|
__internal_request::Request::new(hyper::Method::{{{httpMethod}}}, "{{{path}}}".to_string())
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
@ -53,29 +53,29 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Client<C> {
|
|||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
.with_query_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
.with_path_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{#hasHeaderParams}}
|
{{#hasHeaderParams}}
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
.with_header_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
{{#hasFormParams}}
|
{{#hasFormParams}}
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#isFile}}
|
{{#isFile}}
|
||||||
.with_form_param("{{baseName}}".to_string(), unimplemented!())
|
.with_form_param("{{{baseName}}}".to_string(), unimplemented!())
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
{{^isFile}}
|
{{^isFile}}
|
||||||
.with_form_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{/hasFormParams}}
|
{{/hasFormParams}}
|
||||||
{{#hasBodyParam}}
|
{{#hasBodyParam}}
|
||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
.with_body_param({{paramName}})
|
.with_body_param({{{paramName}}})
|
||||||
{{/bodyParams}}
|
{{/bodyParams}}
|
||||||
{{/hasBodyParam}}
|
{{/hasBodyParam}}
|
||||||
{{^returnType}}
|
{{^returnType}}
|
@ -55,11 +55,11 @@ mod request;
|
|||||||
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
mod {{classFilename}};
|
mod {{{classFilename}}};
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
pub use self::{{classFilename}}::{ {{classname}}, {{classname}}Client };
|
pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client };
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
@ -10,7 +10,7 @@ pub struct APIClient<C: hyper::client::Connect> {
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
{{classFilename}}: Box<::apis::{{classname}}>,
|
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
@ -29,7 +29,7 @@ impl<C: hyper::client::Connect> APIClient<C> {
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
{{classFilename}}: Box::new(::apis::{{classname}}Client::new(rc.clone())),
|
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
@ -43,8 +43,8 @@ impl<C: hyper::client::Connect> APIClient<C> {
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#-last}}
|
{{#-last}}
|
||||||
pub fn {{classFilename}}(&self) -> &::apis::{{classname}}{
|
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||||
self.{{classFilename}}.as_ref()
|
self.{{{classFilename}}}.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/-last}}
|
{{/-last}}
|
@ -23,7 +23,7 @@ impl<C: hyper::client::Connect> Configuration<C> {
|
|||||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||||
Configuration {
|
Configuration {
|
||||||
base_path: "{{{basePath}}}".to_owned(),
|
base_path: "{{{basePath}}}".to_owned(),
|
||||||
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{version}}/rust".to_owned()){{/httpUserAgent}},
|
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
|
||||||
client: client,
|
client: client,
|
||||||
basic_auth: None,
|
basic_auth: None,
|
||||||
oauth_access_token: None,
|
oauth_access_token: None,
|
@ -0,0 +1,16 @@
|
|||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
|
||||||
|
extern crate serde;
|
||||||
|
extern crate serde_json;
|
||||||
|
extern crate url;
|
||||||
|
{{#hyper}}
|
||||||
|
extern crate hyper;
|
||||||
|
extern crate futures;
|
||||||
|
{{/hyper}}
|
||||||
|
{{#reqwest}}
|
||||||
|
extern crate reqwest;
|
||||||
|
{{/reqwest}}
|
||||||
|
|
||||||
|
pub mod apis;
|
||||||
|
pub mod models;
|
@ -9,45 +9,45 @@
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct {{classname}} {
|
pub struct {{{classname}}} {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#description}}
|
{{#description}}
|
||||||
/// {{{description}}}
|
/// {{{description}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
#[serde(rename = "{{baseName}}")]
|
#[serde(rename = "{{{baseName}}}")]
|
||||||
{{name}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
|
{{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl {{classname}} {
|
impl {{{classname}}} {
|
||||||
{{#description}}
|
{{#description}}
|
||||||
/// {{{description}}}
|
/// {{{description}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
pub fn new({{#requiredVars}}{{name}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{classname}} {
|
pub fn new({{#requiredVars}}{{{name}}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||||
{{classname}} {
|
{{{classname}}} {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{name}}: {{#required}}{{name}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
|
{{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
pub fn set_{{name}}(&mut self, {{name}}: {{{dataType}}}) {
|
pub fn set_{{{name}}}(&mut self, {{{name}}}: {{{dataType}}}) {
|
||||||
self.{{name}} = {{^required}}Some({{name}}){{/required}}{{#required}}{{name}}{{/required}};
|
self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_{{name}}(mut self, {{name}}: {{{dataType}}}) -> {{classname}} {
|
pub fn with_{{{name}}}(mut self, {{{name}}}: {{{dataType}}}) -> {{{classname}}} {
|
||||||
self.{{name}} = {{^required}}Some({{name}}){{/required}}{{#required}}{{name}}{{/required}};
|
self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn {{name}}(&self) -> {{^required}}Option<{{/required}}&{{{dataType}}}{{^required}}>{{/required}} {
|
pub fn {{{name}}}(&self) -> {{^required}}Option<{{/required}}&{{{dataType}}}{{^required}}>{{/required}} {
|
||||||
{{#required}}&{{/required}}self.{{name}}{{^required}}.as_ref(){{/required}}
|
{{#required}}&{{/required}}self.{{{name}}}{{^required}}.as_ref(){{/required}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{^required}}
|
{{^required}}
|
||||||
pub fn reset_{{name}}(&mut self) {
|
pub fn reset_{{{name}}}(&mut self) {
|
||||||
self.{{name}} = None;
|
self.{{{name}}} = None;
|
||||||
}
|
}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ impl {{classname}} {
|
|||||||
//const (
|
//const (
|
||||||
// {{#allowableValues}}
|
// {{#allowableValues}}
|
||||||
// {{#enumVars}}
|
// {{#enumVars}}
|
||||||
// {{name}} {{{classname}}} = "{{{value}}}"
|
// {{{name}}} {{{classname}}} = "{{{value}}}"
|
||||||
// {{/enumVars}}
|
// {{/enumVars}}
|
||||||
// {{/allowableValues}}
|
// {{/allowableValues}}
|
||||||
//)
|
//)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{{#models}}{{#model}}# {{classname}}
|
{{#models}}{{#model}}# {{{classname}}}
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
{{#vars}}**{{{name}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}} | {{{description}}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
@ -0,0 +1,113 @@
|
|||||||
|
{{>partial_header}}
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
pub struct {{{classname}}}Client {
|
||||||
|
configuration: Rc<configuration::Configuration>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl {{{classname}}}Client {
|
||||||
|
pub fn new(configuration: Rc<configuration::Configuration>) -> {{{classname}}}Client {
|
||||||
|
{{{classname}}}Client {
|
||||||
|
configuration: configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait {{{classname}}} {
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl {{{classname}}} for {{{classname}}}Client {
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
{{#queryParams}}
|
||||||
|
query.append_pair("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string());
|
||||||
|
{{/queryParams}}
|
||||||
|
{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
query.append_pair("{{{keyParamName}}}".to_owned(), val);
|
||||||
|
}
|
||||||
|
{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}{{{path}}}?{}", configuration.base_path, query_string{{#pathParams}}, {{{baseName}}}={{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}});
|
||||||
|
|
||||||
|
let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#hasHeaderParams}}
|
||||||
|
{{#headerParams}}
|
||||||
|
req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
|
||||||
|
{{/headerParams}}
|
||||||
|
{{/hasHeaderParams}}
|
||||||
|
|
||||||
|
{{#hasAuthMethods}}
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
req_builder = req_builder.header("{{{keyParamName}}}", val);
|
||||||
|
};
|
||||||
|
{{/isKeyInHeader}}{{/isApiKey}}
|
||||||
|
{{#isBasic}}
|
||||||
|
if let Some(ref auth_conf) = configuration.basic_auth {
|
||||||
|
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
|
||||||
|
};
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
{{#hasBodyParam}}
|
||||||
|
{{#bodyParams}}
|
||||||
|
req_builder = req_builder.json(&{{{paramName}}});
|
||||||
|
{{/bodyParams}}
|
||||||
|
{{/hasBodyParam}}
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
{{^returnType}}
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
{{/returnType}}
|
||||||
|
{{#returnType}}
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
{{/returnType}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
use reqwest;
|
||||||
|
use serde_json;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
Reqwest(reqwest::Error),
|
||||||
|
Serde(serde_json::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<reqwest::Error> for Error {
|
||||||
|
fn from(e: reqwest::Error) -> Self {
|
||||||
|
return Error::Reqwest(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<serde_json::Error> for Error {
|
||||||
|
fn from(e: serde_json::Error) -> Self {
|
||||||
|
return Error::Serde(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use super::models::*;
|
||||||
|
|
||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
mod {{{classFilename}}};
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
{{#-last}}
|
||||||
|
pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client };
|
||||||
|
{{/-last}}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
|
||||||
|
pub mod configuration;
|
||||||
|
pub mod client;
|
@ -0,0 +1,55 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
|
pub struct APIClient {
|
||||||
|
configuration: Rc<Configuration>,
|
||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
{{#-last}}
|
||||||
|
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||||
|
{{/-last}}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl APIClient {
|
||||||
|
pub fn new(configuration: Configuration) -> APIClient {
|
||||||
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
|
APIClient {
|
||||||
|
configuration: rc.clone(),
|
||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
{{#-last}}
|
||||||
|
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||||
|
{{/-last}}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
{{#-last}}
|
||||||
|
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||||
|
self.{{{classFilename}}}.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/-last}}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
{{>partial_header}}
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
pub struct Configuration {
|
||||||
|
pub base_path: String,
|
||||||
|
pub user_agent: Option<String>,
|
||||||
|
pub client: reqwest::Client,
|
||||||
|
pub basic_auth: Option<BasicAuth>,
|
||||||
|
pub oauth_access_token: Option<String>,
|
||||||
|
pub api_key: Option<ApiKey>,
|
||||||
|
// TODO: take an oauth2 token source, similar to the go one
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type BasicAuth = (String, Option<String>);
|
||||||
|
|
||||||
|
pub struct ApiKey {
|
||||||
|
pub prefix: Option<String>,
|
||||||
|
pub key: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Configuration {
|
||||||
|
pub fn new() -> Configuration {
|
||||||
|
Configuration::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Configuration {
|
||||||
|
fn default() -> Self {
|
||||||
|
Configuration {
|
||||||
|
base_path: "{{{basePath}}}".to_owned(),
|
||||||
|
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("Swagger-Codegen/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
|
||||||
|
client: reqwest::Client::new(),
|
||||||
|
basic_auth: None,
|
||||||
|
oauth_access_token: None,
|
||||||
|
api_key: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
pom.xml
1
pom.xml
@ -1025,6 +1025,7 @@
|
|||||||
<module>samples/client/petstore/elm-0.18</module>
|
<module>samples/client/petstore/elm-0.18</module>
|
||||||
<module>samples/client/petstore/groovy</module>
|
<module>samples/client/petstore/groovy</module>
|
||||||
<module>samples/client/petstore/rust</module>
|
<module>samples/client/petstore/rust</module>
|
||||||
|
<module>samples/client/petstore/rust-reqwest</module>
|
||||||
<!--<module>samples/client/petstore/perl</module>-->
|
<!--<module>samples/client/petstore/perl</module>-->
|
||||||
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
||||||
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>
|
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>
|
||||||
|
3
samples/client/petstore/rust-reqwest/.gitignore
vendored
Normal file
3
samples/client/petstore/rust-reqwest/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/target/
|
||||||
|
**/*.rs.bk
|
||||||
|
Cargo.lock
|
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1 @@
|
|||||||
|
3.3.2-SNAPSHOT
|
1
samples/client/petstore/rust-reqwest/.travis.yml
Normal file
1
samples/client/petstore/rust-reqwest/.travis.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
language: rust
|
13
samples/client/petstore/rust-reqwest/Cargo.toml
Normal file
13
samples/client/petstore/rust-reqwest/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "petstore_client"
|
||||||
|
version = "1.0.0"
|
||||||
|
authors = ["OpenAPI Generator team and contributors"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = "^1.0"
|
||||||
|
serde_derive = "^1.0"
|
||||||
|
serde_json = "^1.0"
|
||||||
|
url = "1.5"
|
||||||
|
reqwest = "~0.9"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
97
samples/client/petstore/rust-reqwest/README.md
Normal file
97
samples/client/petstore/rust-reqwest/README.md
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# Rust API client for petstore_client
|
||||||
|
|
||||||
|
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
|
||||||
|
|
||||||
|
- API version: 1.0.0
|
||||||
|
- Package version: 1.0.0
|
||||||
|
- Build package: org.openapitools.codegen.languages.RustClientCodegen
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Put the package under your project folder and add the following in import:
|
||||||
|
```
|
||||||
|
"./petstore_client"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **post** /pet | Add a new pet to the store
|
||||||
|
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **delete** /pet/{petId} | Deletes a pet
|
||||||
|
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **get** /pet/findByStatus | Finds Pets by status
|
||||||
|
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **get** /pet/findByTags | Finds Pets by tags
|
||||||
|
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **get** /pet/{petId} | Find pet by ID
|
||||||
|
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **put** /pet | Update an existing pet
|
||||||
|
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **post** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **post** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **delete** /store/order/{orderId} | Delete purchase order by ID
|
||||||
|
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **get** /store/inventory | Returns pet inventories by status
|
||||||
|
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **get** /store/order/{orderId} | Find purchase order by ID
|
||||||
|
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **post** /store/order | Place an order for a pet
|
||||||
|
*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **post** /user | Create user
|
||||||
|
*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
|
||||||
|
*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
|
||||||
|
*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **delete** /user/{username} | Delete user
|
||||||
|
*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **get** /user/{username} | Get user by user name
|
||||||
|
*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **get** /user/login | Logs user into the system
|
||||||
|
*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **get** /user/logout | Logs out current logged in user session
|
||||||
|
*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **put** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Models
|
||||||
|
|
||||||
|
- [ApiResponse](docs/ApiResponse.md)
|
||||||
|
- [Category](docs/Category.md)
|
||||||
|
- [Order](docs/Order.md)
|
||||||
|
- [Pet](docs/Pet.md)
|
||||||
|
- [Tag](docs/Tag.md)
|
||||||
|
- [User](docs/User.md)
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
## api_key
|
||||||
|
- **Type**: API key
|
||||||
|
|
||||||
|
Example
|
||||||
|
```
|
||||||
|
auth := context.WithValue(context.TODO(), sw.ContextAPIKey, sw.APIKey{
|
||||||
|
Key: "APIKEY",
|
||||||
|
Prefix: "Bearer", // Omit if not necessary.
|
||||||
|
})
|
||||||
|
r, err := client.Service.Operation(auth, args)
|
||||||
|
```
|
||||||
|
## petstore_auth
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- **write:pets**: modify pets in your account
|
||||||
|
- **read:pets**: read your pets
|
||||||
|
|
||||||
|
Example
|
||||||
|
```
|
||||||
|
auth := context.WithValue(context.TODO(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||||
|
r, err := client.Service.Operation(auth, args)
|
||||||
|
```
|
||||||
|
|
||||||
|
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||||
|
```
|
||||||
|
import "golang.org/x/oauth2"
|
||||||
|
|
||||||
|
/ .. Perform OAuth2 round trip request and obtain a token .. //
|
||||||
|
|
||||||
|
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
|
||||||
|
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
|
||||||
|
r, err := client.Service.Operation(auth, args)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
|
||||||
|
|
12
samples/client/petstore/rust-reqwest/docs/ApiResponse.md
Normal file
12
samples/client/petstore/rust-reqwest/docs/ApiResponse.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# ApiResponse
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**code** | **i32** | | [optional]
|
||||||
|
**_type** | **String** | | [optional]
|
||||||
|
**message** | **String** | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
11
samples/client/petstore/rust-reqwest/docs/Category.md
Normal file
11
samples/client/petstore/rust-reqwest/docs/Category.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Category
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **i64** | | [optional]
|
||||||
|
**name** | **String** | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
15
samples/client/petstore/rust-reqwest/docs/Order.md
Normal file
15
samples/client/petstore/rust-reqwest/docs/Order.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Order
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **i64** | | [optional]
|
||||||
|
**pet_id** | **i64** | | [optional]
|
||||||
|
**quantity** | **i32** | | [optional]
|
||||||
|
**ship_date** | **String** | | [optional]
|
||||||
|
**status** | **String** | Order Status | [optional]
|
||||||
|
**complete** | **bool** | | [optional] [default to false]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
15
samples/client/petstore/rust-reqwest/docs/Pet.md
Normal file
15
samples/client/petstore/rust-reqwest/docs/Pet.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Pet
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **i64** | | [optional]
|
||||||
|
**category** | [***::models::Category**](Category.md) | | [optional]
|
||||||
|
**name** | **String** | |
|
||||||
|
**photo_urls** | **Vec<String>** | |
|
||||||
|
**tags** | [**Vec<::models::Tag>**](Tag.md) | | [optional]
|
||||||
|
**status** | **String** | pet status in the store | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
259
samples/client/petstore/rust-reqwest/docs/PetApi.md
Normal file
259
samples/client/petstore/rust-reqwest/docs/PetApi.md
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
# \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
|
||||||
|
[**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
|
||||||
|
[**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(ctx, pet)
|
||||||
|
Add a new pet to the store
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **delete_pet**
|
||||||
|
> delete_pet(ctx, pet_id, optional)
|
||||||
|
Deletes a pet
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet_id** | **i64**| Pet id to delete |
|
||||||
|
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||||
|
|
||||||
|
### Optional Parameters
|
||||||
|
Optional parameters are passed through a map[string]interface{}.
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**pet_id** | **i64**| Pet id to delete |
|
||||||
|
**api_key** | **String**| |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **find_pets_by_status**
|
||||||
|
> Vec<::models::Pet> find_pets_by_status(ctx, status)
|
||||||
|
Finds Pets by status
|
||||||
|
|
||||||
|
Multiple status values can be provided with comma separated strings
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**status** | [**Vec<String>**](String.md)| Status values that need to be considered for filter |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Vec<::models::Pet>**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **find_pets_by_tags**
|
||||||
|
> Vec<::models::Pet> find_pets_by_tags(ctx, tags)
|
||||||
|
Finds Pets by tags
|
||||||
|
|
||||||
|
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**tags** | [**Vec<String>**](String.md)| Tags to filter by |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Vec<::models::Pet>**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **get_pet_by_id**
|
||||||
|
> ::models::Pet get_pet_by_id(ctx, pet_id)
|
||||||
|
Find pet by ID
|
||||||
|
|
||||||
|
Returns a single pet
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet_id** | **i64**| ID of pet to return |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**::models::Pet**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **update_pet**
|
||||||
|
> update_pet(ctx, pet)
|
||||||
|
Update an existing pet
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **update_pet_with_form**
|
||||||
|
> update_pet_with_form(ctx, pet_id, optional)
|
||||||
|
Updates a pet in the store with form data
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet_id** | **i64**| ID of pet that needs to be updated |
|
||||||
|
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||||
|
|
||||||
|
### Optional Parameters
|
||||||
|
Optional parameters are passed through a map[string]interface{}.
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**pet_id** | **i64**| ID of pet that needs to be updated |
|
||||||
|
**name** | **String**| Updated name of the pet |
|
||||||
|
**status** | **String**| Updated status of the pet |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/x-www-form-urlencoded
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **upload_file**
|
||||||
|
> ::models::ApiResponse upload_file(ctx, pet_id, optional)
|
||||||
|
uploads an image
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
|
**pet_id** | **i64**| ID of pet to update |
|
||||||
|
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||||
|
|
||||||
|
### Optional Parameters
|
||||||
|
Optional parameters are passed through a map[string]interface{}.
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**pet_id** | **i64**| ID of pet to update |
|
||||||
|
**additional_metadata** | **String**| Additional data to pass to server |
|
||||||
|
**file** | **::models::File**| file to upload |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**::models::ApiResponse**](ApiResponse.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: multipart/form-data
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
115
samples/client/petstore/rust-reqwest/docs/StoreApi.md
Normal file
115
samples/client/petstore/rust-reqwest/docs/StoreApi.md
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
# \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
|
||||||
|
[**get_inventory**](StoreApi.md#get_inventory) | **get** /store/inventory | Returns pet inventories by status
|
||||||
|
[**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)
|
||||||
|
Delete purchase order by ID
|
||||||
|
|
||||||
|
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**order_id** | **String**| ID of the order that needs to be deleted |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **get_inventory**
|
||||||
|
> ::std::collections::HashMap<String, i32> get_inventory(ctx, )
|
||||||
|
Returns pet inventories by status
|
||||||
|
|
||||||
|
Returns a map of status codes to quantities
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**::std::collections::HashMap<String, i32>**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **get_order_by_id**
|
||||||
|
> ::models::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
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**order_id** | **i64**| ID of pet that needs to be fetched |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**::models::Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **place_order**
|
||||||
|
> ::models::Order place_order(order)
|
||||||
|
Place an order for a pet
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**order** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**::models::Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
11
samples/client/petstore/rust-reqwest/docs/Tag.md
Normal file
11
samples/client/petstore/rust-reqwest/docs/Tag.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Tag
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **i64** | | [optional]
|
||||||
|
**name** | **String** | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
17
samples/client/petstore/rust-reqwest/docs/User.md
Normal file
17
samples/client/petstore/rust-reqwest/docs/User.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# User
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **i64** | | [optional]
|
||||||
|
**username** | **String** | | [optional]
|
||||||
|
**first_name** | **String** | | [optional]
|
||||||
|
**last_name** | **String** | | [optional]
|
||||||
|
**email** | **String** | | [optional]
|
||||||
|
**password** | **String** | | [optional]
|
||||||
|
**phone** | **String** | | [optional]
|
||||||
|
**user_status** | **i32** | User Status | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
221
samples/client/petstore/rust-reqwest/docs/UserApi.md
Normal file
221
samples/client/petstore/rust-reqwest/docs/UserApi.md
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
# \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(user)
|
||||||
|
Create user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | [**User**](User.md)| Created user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **create_users_with_array_input**
|
||||||
|
> create_users_with_array_input(user)
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **create_users_with_list_input**
|
||||||
|
> create_users_with_list_input(user)
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **delete_user**
|
||||||
|
> delete_user(username)
|
||||||
|
Delete user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **String**| The name that needs to be deleted |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **get_user_by_name**
|
||||||
|
> ::models::User get_user_by_name(username)
|
||||||
|
Get user by user name
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**::models::User**](User.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **login_user**
|
||||||
|
> String login_user(username, password)
|
||||||
|
Logs user into the system
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **String**| The user name for login |
|
||||||
|
**password** | **String**| The password for login in clear text |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**String**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **logout_user**
|
||||||
|
> logout_user()
|
||||||
|
Logs out current logged in user session
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
# **update_user**
|
||||||
|
> update_user(username, user)
|
||||||
|
Updated user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **String**| name that need to be deleted |
|
||||||
|
**user** | [**User**](User.md)| Updated user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
52
samples/client/petstore/rust-reqwest/git_push.sh
Normal file
52
samples/client/petstore/rust-reqwest/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
46
samples/client/petstore/rust-reqwest/pom.xml
Normal file
46
samples/client/petstore/rust-reqwest/pom.xml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>RustReqwestPetstoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Rust Reqwest Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>cargo</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>check</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
37
samples/client/petstore/rust-reqwest/src/apis/client.rs
Normal file
37
samples/client/petstore/rust-reqwest/src/apis/client.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
|
pub struct APIClient {
|
||||||
|
configuration: Rc<Configuration>,
|
||||||
|
pet_api: Box<::apis::PetApi>,
|
||||||
|
store_api: Box<::apis::StoreApi>,
|
||||||
|
user_api: Box<::apis::UserApi>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl APIClient {
|
||||||
|
pub fn new(configuration: Configuration) -> APIClient {
|
||||||
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
|
APIClient {
|
||||||
|
configuration: rc.clone(),
|
||||||
|
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
|
||||||
|
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
|
||||||
|
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pet_api(&self) -> &::apis::PetApi{
|
||||||
|
self.pet_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn store_api(&self) -> &::apis::StoreApi{
|
||||||
|
self.store_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn user_api(&self) -> &::apis::UserApi{
|
||||||
|
self.user_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
pub struct Configuration {
|
||||||
|
pub base_path: String,
|
||||||
|
pub user_agent: Option<String>,
|
||||||
|
pub client: reqwest::Client,
|
||||||
|
pub basic_auth: Option<BasicAuth>,
|
||||||
|
pub oauth_access_token: Option<String>,
|
||||||
|
pub api_key: Option<ApiKey>,
|
||||||
|
// TODO: take an oauth2 token source, similar to the go one
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type BasicAuth = (String, Option<String>);
|
||||||
|
|
||||||
|
pub struct ApiKey {
|
||||||
|
pub prefix: Option<String>,
|
||||||
|
pub key: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Configuration {
|
||||||
|
pub fn new() -> Configuration {
|
||||||
|
Configuration::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Configuration {
|
||||||
|
fn default() -> Self {
|
||||||
|
Configuration {
|
||||||
|
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
||||||
|
user_agent: Some("Swagger-Codegen/1.0.0/rust".to_owned()),
|
||||||
|
client: reqwest::Client::new(),
|
||||||
|
basic_auth: None,
|
||||||
|
oauth_access_token: None,
|
||||||
|
api_key: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
samples/client/petstore/rust-reqwest/src/apis/mod.rs
Normal file
32
samples/client/petstore/rust-reqwest/src/apis/mod.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
use reqwest;
|
||||||
|
use serde_json;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
Reqwest(reqwest::Error),
|
||||||
|
Serde(serde_json::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<reqwest::Error> for Error {
|
||||||
|
fn from(e: reqwest::Error) -> Self {
|
||||||
|
return Error::Reqwest(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<serde_json::Error> for Error {
|
||||||
|
fn from(e: serde_json::Error) -> Self {
|
||||||
|
return Error::Serde(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use super::models::*;
|
||||||
|
|
||||||
|
mod pet_api;
|
||||||
|
pub use self::pet_api::{ PetApi, PetApiClient };
|
||||||
|
mod store_api;
|
||||||
|
pub use self::store_api::{ StoreApi, StoreApiClient };
|
||||||
|
mod user_api;
|
||||||
|
pub use self::user_api::{ UserApi, UserApiClient };
|
||||||
|
|
||||||
|
pub mod configuration;
|
||||||
|
pub mod client;
|
298
samples/client/petstore/rust-reqwest/src/apis/pet_api.rs
Normal file
298
samples/client/petstore/rust-reqwest/src/apis/pet_api.rs
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
pub struct PetApiClient {
|
||||||
|
configuration: Rc<configuration::Configuration>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PetApiClient {
|
||||||
|
pub fn new(configuration: Rc<configuration::Configuration>) -> PetApiClient {
|
||||||
|
PetApiClient {
|
||||||
|
configuration: configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PetApi {
|
||||||
|
fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error>;
|
||||||
|
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error>;
|
||||||
|
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, Error>;
|
||||||
|
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, Error>;
|
||||||
|
fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error>;
|
||||||
|
fn update_pet(&self, pet: ::models::Pet) -> Result<(), Error>;
|
||||||
|
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error>;
|
||||||
|
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Result<::models::ApiResponse, Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl PetApi for PetApiClient {
|
||||||
|
fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&pet);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.delete(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
req_builder = req_builder.header("api_key", api_key.to_string());
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.append_pair("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/findByStatus?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.append_pair("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/findByTags?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
req_builder = req_builder.header("api_key", val);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_pet(&self, pet: ::models::Pet) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.put(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&pet);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Result<::models::ApiResponse, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}/uploadImage?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
155
samples/client/petstore/rust-reqwest/src/apis/store_api.rs
Normal file
155
samples/client/petstore/rust-reqwest/src/apis/store_api.rs
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
pub struct StoreApiClient {
|
||||||
|
configuration: Rc<configuration::Configuration>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StoreApiClient {
|
||||||
|
pub fn new(configuration: Rc<configuration::Configuration>) -> StoreApiClient {
|
||||||
|
StoreApiClient {
|
||||||
|
configuration: configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait StoreApi {
|
||||||
|
fn delete_order(&self, order_id: &str) -> Result<(), Error>;
|
||||||
|
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error>;
|
||||||
|
fn get_order_by_id(&self, order_id: i64) -> Result<::models::Order, Error>;
|
||||||
|
fn place_order(&self, order: ::models::Order) -> Result<::models::Order, Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl StoreApi for StoreApiClient {
|
||||||
|
fn delete_order(&self, order_id: &str) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.delete(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/inventory?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
req_builder = req_builder.header("api_key", val);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_order_by_id(&self, order_id: i64) -> Result<::models::Order, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn place_order(&self, order: ::models::Order) -> Result<::models::Order, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&order);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
263
samples/client/petstore/rust-reqwest/src/apis/user_api.rs
Normal file
263
samples/client/petstore/rust-reqwest/src/apis/user_api.rs
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
pub struct UserApiClient {
|
||||||
|
configuration: Rc<configuration::Configuration>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UserApiClient {
|
||||||
|
pub fn new(configuration: Rc<configuration::Configuration>) -> UserApiClient {
|
||||||
|
UserApiClient {
|
||||||
|
configuration: configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait UserApi {
|
||||||
|
fn create_user(&self, user: ::models::User) -> Result<(), Error>;
|
||||||
|
fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error>;
|
||||||
|
fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error>;
|
||||||
|
fn delete_user(&self, username: &str) -> Result<(), Error>;
|
||||||
|
fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error>;
|
||||||
|
fn login_user(&self, username: &str, password: &str) -> Result<String, Error>;
|
||||||
|
fn logout_user(&self, ) -> Result<(), Error>;
|
||||||
|
fn update_user(&self, username: &str, user: ::models::User) -> Result<(), Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl UserApi for UserApiClient {
|
||||||
|
fn create_user(&self, user: ::models::User) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&user);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/createWithArray?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&user);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/createWithList?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.post(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&user);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn delete_user(&self, username: &str) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
|
let mut req_builder = client.delete(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn login_user(&self, username: &str, password: &str) -> Result<String, Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.append_pair("username", &username.to_string());
|
||||||
|
query.append_pair("password", &password.to_string());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/login?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn logout_user(&self, ) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/logout?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_user(&self, username: &str, user: ::models::User) -> Result<(), Error> {
|
||||||
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
|
let client = &configuration.client;
|
||||||
|
|
||||||
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
|
let mut req_builder = client.put(uri_str.as_str());
|
||||||
|
|
||||||
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
req_builder = req_builder.json(&user);
|
||||||
|
|
||||||
|
// send request
|
||||||
|
let req = req_builder.build()?;
|
||||||
|
|
||||||
|
client.execute(req)?.error_for_status()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,10 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
extern crate hyper;
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate futures;
|
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
extern crate reqwest;
|
||||||
|
|
||||||
pub mod apis;
|
pub mod apis;
|
||||||
pub mod models;
|
pub mod models;
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// ApiResponse : Describes the result of uploading an image resource
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct ApiResponse {
|
||||||
|
#[serde(rename = "code")]
|
||||||
|
code: Option<i32>,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
_type: Option<String>,
|
||||||
|
#[serde(rename = "message")]
|
||||||
|
message: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ApiResponse {
|
||||||
|
/// Describes the result of uploading an image resource
|
||||||
|
pub fn new() -> ApiResponse {
|
||||||
|
ApiResponse {
|
||||||
|
code: None,
|
||||||
|
_type: None,
|
||||||
|
message: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_code(&mut self, code: i32) {
|
||||||
|
self.code = Some(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_code(mut self, code: i32) -> ApiResponse {
|
||||||
|
self.code = Some(code);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn code(&self) -> Option<&i32> {
|
||||||
|
self.code.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_code(&mut self) {
|
||||||
|
self.code = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set__type(&mut self, _type: String) {
|
||||||
|
self._type = Some(_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with__type(mut self, _type: String) -> ApiResponse {
|
||||||
|
self._type = Some(_type);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn _type(&self) -> Option<&String> {
|
||||||
|
self._type.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset__type(&mut self) {
|
||||||
|
self._type = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_message(&mut self, message: String) {
|
||||||
|
self.message = Some(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_message(mut self, message: String) -> ApiResponse {
|
||||||
|
self.message = Some(message);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn message(&self) -> Option<&String> {
|
||||||
|
self.message.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_message(&mut self) {
|
||||||
|
self.message = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
70
samples/client/petstore/rust-reqwest/src/models/category.rs
Normal file
70
samples/client/petstore/rust-reqwest/src/models/category.rs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// Category : A category for a pet
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Category {
|
||||||
|
#[serde(rename = "id")]
|
||||||
|
id: Option<i64>,
|
||||||
|
#[serde(rename = "name")]
|
||||||
|
name: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Category {
|
||||||
|
/// A category for a pet
|
||||||
|
pub fn new() -> Category {
|
||||||
|
Category {
|
||||||
|
id: None,
|
||||||
|
name: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_id(&mut self, id: i64) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_id(mut self, id: i64) -> Category {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Option<&i64> {
|
||||||
|
self.id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_id(&mut self) {
|
||||||
|
self.id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_name(&mut self, name: String) {
|
||||||
|
self.name = Some(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_name(mut self, name: String) -> Category {
|
||||||
|
self.name = Some(name);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> Option<&String> {
|
||||||
|
self.name.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_name(&mut self) {
|
||||||
|
self.name = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
15
samples/client/petstore/rust-reqwest/src/models/mod.rs
Normal file
15
samples/client/petstore/rust-reqwest/src/models/mod.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
mod api_response;
|
||||||
|
pub use self::api_response::ApiResponse;
|
||||||
|
mod category;
|
||||||
|
pub use self::category::Category;
|
||||||
|
mod order;
|
||||||
|
pub use self::order::Order;
|
||||||
|
mod pet;
|
||||||
|
pub use self::pet::Pet;
|
||||||
|
mod tag;
|
||||||
|
pub use self::tag::Tag;
|
||||||
|
mod user;
|
||||||
|
pub use self::user::User;
|
||||||
|
|
||||||
|
// TODO(farcaller): sort out files
|
||||||
|
pub struct File;
|
151
samples/client/petstore/rust-reqwest/src/models/order.rs
Normal file
151
samples/client/petstore/rust-reqwest/src/models/order.rs
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// Order : An order for a pets from the pet store
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Order {
|
||||||
|
#[serde(rename = "id")]
|
||||||
|
id: Option<i64>,
|
||||||
|
#[serde(rename = "petId")]
|
||||||
|
pet_id: Option<i64>,
|
||||||
|
#[serde(rename = "quantity")]
|
||||||
|
quantity: Option<i32>,
|
||||||
|
#[serde(rename = "shipDate")]
|
||||||
|
ship_date: Option<String>,
|
||||||
|
/// Order Status
|
||||||
|
#[serde(rename = "status")]
|
||||||
|
status: Option<String>,
|
||||||
|
#[serde(rename = "complete")]
|
||||||
|
complete: Option<bool>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Order {
|
||||||
|
/// An order for a pets from the pet store
|
||||||
|
pub fn new() -> Order {
|
||||||
|
Order {
|
||||||
|
id: None,
|
||||||
|
pet_id: None,
|
||||||
|
quantity: None,
|
||||||
|
ship_date: None,
|
||||||
|
status: None,
|
||||||
|
complete: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_id(&mut self, id: i64) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_id(mut self, id: i64) -> Order {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Option<&i64> {
|
||||||
|
self.id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_id(&mut self) {
|
||||||
|
self.id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_pet_id(&mut self, pet_id: i64) {
|
||||||
|
self.pet_id = Some(pet_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_pet_id(mut self, pet_id: i64) -> Order {
|
||||||
|
self.pet_id = Some(pet_id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pet_id(&self) -> Option<&i64> {
|
||||||
|
self.pet_id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_pet_id(&mut self) {
|
||||||
|
self.pet_id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_quantity(&mut self, quantity: i32) {
|
||||||
|
self.quantity = Some(quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_quantity(mut self, quantity: i32) -> Order {
|
||||||
|
self.quantity = Some(quantity);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn quantity(&self) -> Option<&i32> {
|
||||||
|
self.quantity.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_quantity(&mut self) {
|
||||||
|
self.quantity = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_ship_date(&mut self, ship_date: String) {
|
||||||
|
self.ship_date = Some(ship_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_ship_date(mut self, ship_date: String) -> Order {
|
||||||
|
self.ship_date = Some(ship_date);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ship_date(&self) -> Option<&String> {
|
||||||
|
self.ship_date.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_ship_date(&mut self) {
|
||||||
|
self.ship_date = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_status(&mut self, status: String) {
|
||||||
|
self.status = Some(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_status(mut self, status: String) -> Order {
|
||||||
|
self.status = Some(status);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn status(&self) -> Option<&String> {
|
||||||
|
self.status.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_status(&mut self) {
|
||||||
|
self.status = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_complete(&mut self, complete: bool) {
|
||||||
|
self.complete = Some(complete);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_complete(mut self, complete: bool) -> Order {
|
||||||
|
self.complete = Some(complete);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn complete(&self) -> Option<&bool> {
|
||||||
|
self.complete.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_complete(&mut self) {
|
||||||
|
self.complete = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
145
samples/client/petstore/rust-reqwest/src/models/pet.rs
Normal file
145
samples/client/petstore/rust-reqwest/src/models/pet.rs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// Pet : A pet for sale in the pet store
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Pet {
|
||||||
|
#[serde(rename = "id")]
|
||||||
|
id: Option<i64>,
|
||||||
|
#[serde(rename = "category")]
|
||||||
|
category: Option<::models::Category>,
|
||||||
|
#[serde(rename = "name")]
|
||||||
|
name: String,
|
||||||
|
#[serde(rename = "photoUrls")]
|
||||||
|
photo_urls: Vec<String>,
|
||||||
|
#[serde(rename = "tags")]
|
||||||
|
tags: Option<Vec<::models::Tag>>,
|
||||||
|
/// pet status in the store
|
||||||
|
#[serde(rename = "status")]
|
||||||
|
status: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pet {
|
||||||
|
/// A pet for sale in the pet store
|
||||||
|
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||||
|
Pet {
|
||||||
|
id: None,
|
||||||
|
category: None,
|
||||||
|
name: name,
|
||||||
|
photo_urls: photo_urls,
|
||||||
|
tags: None,
|
||||||
|
status: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_id(&mut self, id: i64) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_id(mut self, id: i64) -> Pet {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Option<&i64> {
|
||||||
|
self.id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_id(&mut self) {
|
||||||
|
self.id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_category(&mut self, category: ::models::Category) {
|
||||||
|
self.category = Some(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_category(mut self, category: ::models::Category) -> Pet {
|
||||||
|
self.category = Some(category);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn category(&self) -> Option<&::models::Category> {
|
||||||
|
self.category.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_category(&mut self) {
|
||||||
|
self.category = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_name(&mut self, name: String) {
|
||||||
|
self.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_name(mut self, name: String) -> Pet {
|
||||||
|
self.name = name;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &String {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn set_photo_urls(&mut self, photo_urls: Vec<String>) {
|
||||||
|
self.photo_urls = photo_urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_photo_urls(mut self, photo_urls: Vec<String>) -> Pet {
|
||||||
|
self.photo_urls = photo_urls;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photo_urls(&self) -> &Vec<String> {
|
||||||
|
&self.photo_urls
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn set_tags(&mut self, tags: Vec<::models::Tag>) {
|
||||||
|
self.tags = Some(tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_tags(mut self, tags: Vec<::models::Tag>) -> Pet {
|
||||||
|
self.tags = Some(tags);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tags(&self) -> Option<&Vec<::models::Tag>> {
|
||||||
|
self.tags.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_tags(&mut self) {
|
||||||
|
self.tags = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_status(&mut self, status: String) {
|
||||||
|
self.status = Some(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_status(mut self, status: String) -> Pet {
|
||||||
|
self.status = Some(status);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn status(&self) -> Option<&String> {
|
||||||
|
self.status.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_status(&mut self) {
|
||||||
|
self.status = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
70
samples/client/petstore/rust-reqwest/src/models/tag.rs
Normal file
70
samples/client/petstore/rust-reqwest/src/models/tag.rs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// Tag : A tag for a pet
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Tag {
|
||||||
|
#[serde(rename = "id")]
|
||||||
|
id: Option<i64>,
|
||||||
|
#[serde(rename = "name")]
|
||||||
|
name: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Tag {
|
||||||
|
/// A tag for a pet
|
||||||
|
pub fn new() -> Tag {
|
||||||
|
Tag {
|
||||||
|
id: None,
|
||||||
|
name: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_id(&mut self, id: i64) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_id(mut self, id: i64) -> Tag {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Option<&i64> {
|
||||||
|
self.id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_id(&mut self) {
|
||||||
|
self.id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_name(&mut self, name: String) {
|
||||||
|
self.name = Some(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_name(mut self, name: String) -> Tag {
|
||||||
|
self.name = Some(name);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> Option<&String> {
|
||||||
|
self.name.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_name(&mut self) {
|
||||||
|
self.name = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
191
samples/client/petstore/rust-reqwest/src/models/user.rs
Normal file
191
samples/client/petstore/rust-reqwest/src/models/user.rs
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// User : A User who is purchasing from the pet store
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct User {
|
||||||
|
#[serde(rename = "id")]
|
||||||
|
id: Option<i64>,
|
||||||
|
#[serde(rename = "username")]
|
||||||
|
username: Option<String>,
|
||||||
|
#[serde(rename = "firstName")]
|
||||||
|
first_name: Option<String>,
|
||||||
|
#[serde(rename = "lastName")]
|
||||||
|
last_name: Option<String>,
|
||||||
|
#[serde(rename = "email")]
|
||||||
|
email: Option<String>,
|
||||||
|
#[serde(rename = "password")]
|
||||||
|
password: Option<String>,
|
||||||
|
#[serde(rename = "phone")]
|
||||||
|
phone: Option<String>,
|
||||||
|
/// User Status
|
||||||
|
#[serde(rename = "userStatus")]
|
||||||
|
user_status: Option<i32>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl User {
|
||||||
|
/// A User who is purchasing from the pet store
|
||||||
|
pub fn new() -> User {
|
||||||
|
User {
|
||||||
|
id: None,
|
||||||
|
username: None,
|
||||||
|
first_name: None,
|
||||||
|
last_name: None,
|
||||||
|
email: None,
|
||||||
|
password: None,
|
||||||
|
phone: None,
|
||||||
|
user_status: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_id(&mut self, id: i64) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_id(mut self, id: i64) -> User {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Option<&i64> {
|
||||||
|
self.id.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_id(&mut self) {
|
||||||
|
self.id = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_username(&mut self, username: String) {
|
||||||
|
self.username = Some(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_username(mut self, username: String) -> User {
|
||||||
|
self.username = Some(username);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn username(&self) -> Option<&String> {
|
||||||
|
self.username.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_username(&mut self) {
|
||||||
|
self.username = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_first_name(&mut self, first_name: String) {
|
||||||
|
self.first_name = Some(first_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_first_name(mut self, first_name: String) -> User {
|
||||||
|
self.first_name = Some(first_name);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn first_name(&self) -> Option<&String> {
|
||||||
|
self.first_name.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_first_name(&mut self) {
|
||||||
|
self.first_name = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_last_name(&mut self, last_name: String) {
|
||||||
|
self.last_name = Some(last_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_last_name(mut self, last_name: String) -> User {
|
||||||
|
self.last_name = Some(last_name);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn last_name(&self) -> Option<&String> {
|
||||||
|
self.last_name.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_last_name(&mut self) {
|
||||||
|
self.last_name = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_email(&mut self, email: String) {
|
||||||
|
self.email = Some(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_email(mut self, email: String) -> User {
|
||||||
|
self.email = Some(email);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn email(&self) -> Option<&String> {
|
||||||
|
self.email.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_email(&mut self) {
|
||||||
|
self.email = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_password(&mut self, password: String) {
|
||||||
|
self.password = Some(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_password(mut self, password: String) -> User {
|
||||||
|
self.password = Some(password);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn password(&self) -> Option<&String> {
|
||||||
|
self.password.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_password(&mut self) {
|
||||||
|
self.password = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_phone(&mut self, phone: String) {
|
||||||
|
self.phone = Some(phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_phone(mut self, phone: String) -> User {
|
||||||
|
self.phone = Some(phone);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn phone(&self) -> Option<&String> {
|
||||||
|
self.phone.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_phone(&mut self) {
|
||||||
|
self.phone = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_user_status(&mut self, user_status: i32) {
|
||||||
|
self.user_status = Some(user_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_user_status(mut self, user_status: i32) -> User {
|
||||||
|
self.user_status = Some(user_status);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn user_status(&self) -> Option<&i32> {
|
||||||
|
self.user_status.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset_user_status(&mut self) {
|
||||||
|
self.user_status = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
3.1.0
|
3.3.2-SNAPSHOT
|
@ -4,14 +4,14 @@ version = "1.0.0"
|
|||||||
authors = ["OpenAPI Generator team and contributors"]
|
authors = ["OpenAPI Generator team and contributors"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0"
|
serde = "^1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "^1.0"
|
||||||
serde_yaml = "0.7"
|
serde_json = "^1.0"
|
||||||
serde_json = "1.0"
|
|
||||||
base64 = "~0.7.0"
|
|
||||||
futures = "0.1.16"
|
|
||||||
hyper = "0.11.6"
|
|
||||||
url = "1.5"
|
url = "1.5"
|
||||||
|
hyper = "~0.11"
|
||||||
|
serde_yaml = "0.7"
|
||||||
|
base64 = "~0.7.0"
|
||||||
|
futures = "0.1.23"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio-core = "*"
|
tokio-core = "*"
|
||||||
|
@ -86,7 +86,7 @@ Multiple status values can be provided with comma separated strings
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
**status** | [**Vec<String>**](String.md)| Status values that need to be considered for filter |
|
**status** | [**Vec<String>**](String.md)| Status values that need to be considered for filter |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
**ctx** | **context.Context** | context containing the authentication | nil if no authentication
|
||||||
**tags** | [**Vec<String>**](String.md)| Tags to filter by |
|
**tags** | [**Vec<String>**](String.md)| Tags to filter by |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ Creates list of users with given input array
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ Creates list of users with given input array
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
**user** | [**Vec<::models::User>**](array.md)| List of user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<executable>cargo</executable>
|
<executable>cargo</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>build</argument>
|
<argument>check</argument>
|
||||||
<argument>--release</argument>
|
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
extern crate hyper;
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate futures;
|
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
extern crate hyper;
|
||||||
|
extern crate futures;
|
||||||
|
|
||||||
pub mod apis;
|
pub mod apis;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user