diff --git a/bin/rust-petstore-reqwest-async.sh b/bin/rust-petstore-reqwest-async.sh new file mode 100755 index 000000000000..13a7c649bcb2 --- /dev/null +++ b/bin/rust-petstore-reqwest-async.sh @@ -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 --library reqwest -o samples/client/petstore/rust/reqwest/petstore-async --additional-properties supportAsync=true,packageName=petstore-reqwest-async $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/docs/generators/rust.md b/docs/generators/rust.md index b93f900f3b16..b59b31471f0c 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -9,6 +9,7 @@ sidebar_label: rust |library|library template (sub-template) to use.|
**hyper**
HTTP client: Hyper.
**reqwest**
HTTP client: Reqwest.
|hyper| |packageName|Rust package name (convention: lowercase).| |openapi| |packageVersion|Rust package version.| |1.0.0| +|supportAsync|If set, generate async function call instead| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false| ## IMPORT MAPPING diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 1307f27f6928..3ff2bfe8569c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -39,12 +39,13 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class); private boolean useSingleRequestParameter = false; + private boolean supportAsync = false; public static final String PACKAGE_NAME = "packageName"; public static final String PACKAGE_VERSION = "packageVersion"; - public static final String HYPER_LIBRARY = "hyper"; public static final String REQWEST_LIBRARY = "reqwest"; + public static final String SUPPORT_ASYNC = "supportAsync"; protected String packageName = "openapi"; protected String packageVersion = "1.0.0"; @@ -172,6 +173,8 @@ public RustClientCodegen() { .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); + cliOptions.add(new CliOption(SUPPORT_ASYNC, "If set, generate async function call instead", SchemaTypeUtil.BOOLEAN_TYPE) + .defaultValue(Boolean.FALSE.toString())); supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper."); supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest."); @@ -257,6 +260,11 @@ public void processOpts() { } writePropertyBack(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter()); + if (additionalProperties.containsKey(SUPPORT_ASYNC)) { + this.setSupportAsync(convertPropertyToBoolean(SUPPORT_ASYNC)); + } + writePropertyBack(SUPPORT_ASYNC, getSupportAsync()); + additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); @@ -284,13 +292,22 @@ public void processOpts() { supportingFiles.add(new SupportingFile("lib.mustache", "src", "lib.rs")); supportingFiles.add(new SupportingFile("Cargo.mustache", "", "Cargo.toml")); + supportingFiles.add(new SupportingFile(getLibrary() + "/api_mod.mustache", apiFolder, "mod.rs")); + supportingFiles.add(new SupportingFile(getLibrary() + "/configuration.mustache", apiFolder, "configuration.rs")); if (HYPER_LIBRARY.equals(getLibrary())) { supportingFiles.add(new SupportingFile("request.rs", apiFolder, "request.rs")); } + if (!getSupportAsync()) { // for sync only + supportingFiles.add(new SupportingFile(getLibrary() + "/client.mustache", apiFolder, "client.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")); + private boolean getSupportAsync() { + return supportAsync; + } + + private void setSupportAsync(boolean supportAsync) { + this.supportAsync = supportAsync; } private boolean getUseSingleRequestParameter() { diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index e448a38c51c9..264ae44d5947 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -2,6 +2,7 @@ name = "{{{packageName}}}" version = "{{{packageVersion}}}" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" @@ -15,7 +16,15 @@ base64 = "~0.7.0" futures = "0.1.23" {{/hyper}} {{#reqwest}} +{{^supportAsync}} reqwest = "~0.9" +{{/supportAsync}} +{{#supportAsync}} +[dependencies.reqwest] +version = "^0.10" +default-features = false +features = ["json"] +{{/supportAsync}} {{/reqwest}} [dev-dependencies] diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 48bd7cc1524d..9656c13c036d 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -1,13 +1,14 @@ {{>partial_header}} +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; use super::{Error, configuration}; +{{^supportAsync}} pub struct {{{classname}}}Client { configuration: Rc, } @@ -20,6 +21,7 @@ impl {{{classname}}}Client { } } +{{/supportAsync}} {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} @@ -42,6 +44,7 @@ pub struct {{{classname}}}{{{operationIdCamelCase}}}Params { {{/operation}} {{/operations}} +{{^supportAsync}} pub trait {{{classname}}} { {{#operations}} {{#operation}} @@ -56,10 +59,11 @@ pub trait {{{classname}}} { } impl {{{classname}}} for {{{classname}}}Client { +{{/supportAsync}} {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{classname}}}{{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{classname}}}{{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { // unbox the parameters {{#allParams}} let {{paramName}} = params.{{paramName}}; @@ -67,9 +71,11 @@ impl {{{classname}}} for {{{classname}}}Client { {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { {{/vendorExtensions.x-group-parameters}} + {{^supportAsync}} let configuration: &configuration::Configuration = self.configuration.borrow(); + {{/supportAsync}} let client = &configuration.client; let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}}); @@ -162,6 +168,7 @@ impl {{{classname}}} for {{{classname}}}Client { let mut form = reqwest::multipart::Form::new(); {{#formParams}} {{#isFile}} + {{^supportAsync}} {{#required}} {{^isNullable}} form = form.file("{{{baseName}}}", {{{paramName}}})?; @@ -178,6 +185,10 @@ impl {{{classname}}} for {{{classname}}}Client { form = form.file("{{{baseName}}}", param_value)?; } {{/required}} + {{/supportAsync}} + {{#supportAsync}} + // TODO: support file upload for '{{{baseName}}}' parameter + {{/supportAsync}} {{/isFile}} {{^isFile}} {{#required}} @@ -251,18 +262,23 @@ impl {{{classname}}} for {{{classname}}}Client { {{/bodyParams}} {{/hasBodyParam}} - // send request let req = req_builder.build()?; - {{^returnType}} - client.execute(req)?.error_for_status()?; + client.execute(req){{#supportAsync}}.await{{/supportAsync}}?.error_for_status()?; Ok(()) {{/returnType}} {{#returnType}} + {{#supportAsync}} + Ok(client.execute(req).await?.error_for_status()?.json::<{{{.}}}>().await?) + {{/supportAsync}} + {{^supportAsync}} Ok(client.execute(req)?.error_for_status()?.json()?) + {{/supportAsync}} {{/returnType}} } {{/operation}} {{/operations}} +{{^supportAsync}} } +{{/supportAsync}} diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache index 540d12bf2c8c..3593cf0a490a 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache @@ -35,9 +35,14 @@ pub fn urlencode>(s: T) -> String { mod {{{classFilename}}}; {{#operations}} {{#operation}} +{{^supportAsync}} {{#-first}} pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client }; {{/-first}} +{{/supportAsync}} +{{#supportAsync}} +pub use self::{{{classFilename}}}::{ {{{operationId}}} }; +{{/supportAsync}} {{#vendorExtensions.x-group-parameters}} {{#allParams}} {{#-first}} @@ -50,5 +55,7 @@ pub use self::{{{classFilename}}}::{ {{{classname}}}{{{operationIdCamelCase}}}Pa {{/apis}} {{/apiInfo}} -pub mod configuration; +{{^supportAsync}} pub mod client; +{{/supportAsync}} +pub mod configuration; diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml index f78404453cf9..808f425995b8 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml +++ b/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml @@ -2,6 +2,7 @@ name = "fileResponseTest-hyper" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/hyper/petstore/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml index 67fc43707a92..7c7314a7a364 100644 --- a/samples/client/petstore/rust/hyper/petstore/Cargo.toml +++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml @@ -2,6 +2,7 @@ name = "petstore-hyper" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/hyper/rust-test/Cargo.toml b/samples/client/petstore/rust/hyper/rust-test/Cargo.toml index 0e17417c3d2d..4a39ba0c5fbd 100644 --- a/samples/client/petstore/rust/hyper/rust-test/Cargo.toml +++ b/samples/client/petstore/rust/hyper/rust-test/Cargo.toml @@ -2,6 +2,7 @@ name = "rust-test-hyper" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml index 97c0f07897b9..67a755867977 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml @@ -2,6 +2,7 @@ name = "fileResponseTest-reqwest" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs index 407215f0c7b1..8c907ea7923f 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs @@ -8,9 +8,9 @@ * Generated by: https://openapi-generator.tech */ +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; @@ -46,9 +46,7 @@ impl DefaultApi for DefaultApiClient { 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()?) } diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs index 3b70668f6fd9..77bd60c058a5 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs @@ -33,5 +33,5 @@ pub fn urlencode>(s: T) -> String { mod default_api; pub use self::default_api::{ DefaultApi, DefaultApiClient }; -pub mod configuration; pub mod client; +pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.gitignore b/samples/client/petstore/rust/reqwest/petstore-async/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore @@ -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 diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES new file mode 100644 index 000000000000..611ac7b6dd7c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -0,0 +1,27 @@ +.gitignore +.travis.yml +Cargo.toml +README.md +docs/ApiResponse.md +docs/Category.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +git_push.sh +src/apis/configuration.rs +src/apis/mod.rs +src/apis/pet_api.rs +src/apis/store_api.rs +src/apis/user_api.rs +src/lib.rs +src/models/api_response.rs +src/models/category.rs +src/models/mod.rs +src/models/order.rs +src/models/pet.rs +src/models/tag.rs +src/models/user.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/VERSION new file mode 100644 index 000000000000..d99e7162d01f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.travis.yml b/samples/client/petstore/rust/reqwest/petstore-async/.travis.yml new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml new file mode 100644 index 000000000000..18eb264f99c7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "petstore-reqwest-async" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] +edition = "2018" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "1.5" +[dependencies.reqwest] +version = "^0.10" +default-features = false +features = ["json"] + +[dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/petstore-async/README.md b/samples/client/petstore/rust/reqwest/petstore-async/README.md new file mode 100644 index 000000000000..4a3e0251107a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -0,0 +1,68 @@ +# Rust API client for petstore-reqwest-async + +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 to `Cargo.toml` under `[dependencies]`: + +``` + openapi = { path = "./generated" } +``` + +## 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) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ApiResponse.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ApiResponse.md new file mode 100644 index 000000000000..97128a87d97b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ApiResponse.md @@ -0,0 +1,13 @@ +# ApiResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | Option<**i32**> | | [optional] +**_type** | Option<**String**> | | [optional] +**message** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Category.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Category.md new file mode 100644 index 000000000000..1cf67347c057 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Category.md @@ -0,0 +1,12 @@ +# Category + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md new file mode 100644 index 000000000000..d9a09c397432 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md @@ -0,0 +1,16 @@ +# Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**pet_id** | Option<**i64**> | | [optional] +**quantity** | Option<**i32**> | | [optional] +**ship_date** | Option<**String**> | | [optional] +**status** | Option<**String**> | Order Status | [optional] +**complete** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md new file mode 100644 index 000000000000..27886889d1d4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md @@ -0,0 +1,16 @@ +# Pet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**category** | Option<[**crate::models::Category**](Category.md)> | | [optional] +**name** | **String** | | +**photo_urls** | **Vec** | | +**tags** | Option<[**Vec**](Tag.md)> | | [optional] +**status** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md new file mode 100644 index 000000000000..4716e752b666 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md @@ -0,0 +1,251 @@ +# \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(body) +Add a new pet to the store + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### 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(pet_id, api_key) +Deletes a pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | Pet id to delete | [required] | +**api_key** | Option<**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 find_pets_by_status(status) +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | [**Vec**](String.md) | Status values that need to be considered for filter | [required] | + +### Return type + +[**Vec**](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 find_pets_by_tags(tags) +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**tags** | [**Vec**](String.md) | Tags to filter by | [required] | + +### Return type + +[**Vec**](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 + +> crate::models::Pet get_pet_by_id(pet_id) +Find pet by ID + +Returns a single pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to return | [required] | + +### Return type + +[**crate::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(body) +Update an existing pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### 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(pet_id, name, status) +Updates a pet in the store with form data + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet that needs to be updated | [required] | +**name** | Option<**String**> | Updated name of the pet | | +**status** | Option<**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 + +> crate::models::ApiResponse upload_file(pet_id, additional_metadata, file) +uploads an image + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to update | [required] | +**additional_metadata** | Option<**String**> | Additional data to pass to server | | +**file** | Option<**std::path::PathBuf**> | file to upload | | + +### Return type + +[**crate::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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/StoreApi.md new file mode 100644 index 000000000000..a310b5383154 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/StoreApi.md @@ -0,0 +1,127 @@ +# \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 + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **String** | ID of the order that needs to be deleted | [required] | + +### 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 get_inventory() +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**::std::collections::HashMap** + +### 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 + +> crate::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 + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **i64** | ID of pet that needs to be fetched | [required] | + +### Return type + +[**crate::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 + +> crate::models::Order place_order(body) +Place an order for a pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**Order**](Order.md) | order placed for purchasing the pet | [required] | + +### Return type + +[**crate::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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Tag.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Tag.md new file mode 100644 index 000000000000..7bf71ab0e9d8 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Tag.md @@ -0,0 +1,12 @@ +# Tag + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/User.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/User.md new file mode 100644 index 000000000000..2e6abda42b32 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/User.md @@ -0,0 +1,18 @@ +# User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**username** | Option<**String**> | | [optional] +**first_name** | Option<**String**> | | [optional] +**last_name** | Option<**String**> | | [optional] +**email** | Option<**String**> | | [optional] +**password** | Option<**String**> | | [optional] +**phone** | Option<**String**> | | [optional] +**user_status** | Option<**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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/UserApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/UserApi.md new file mode 100644 index 000000000000..a6268f251a64 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/UserApi.md @@ -0,0 +1,245 @@ +# \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(body) +Create user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**User**](User.md) | Created user object | [required] | + +### 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(body) +Creates list of users with given input array + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**Vec**](User.md) | List of user object | [required] | + +### 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(body) +Creates list of users with given input array + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | [**Vec**](User.md) | List of user object | [required] | + +### 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. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be deleted | [required] | + +### 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 + +> crate::models::User get_user_by_name(username) +Get user by user name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | + +### Return type + +[**crate::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 + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The user name for login | [required] | +**password** | **String** | The password for login in clear text | [required] | + +### 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 + +### 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, body) +Updated user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | name that need to be deleted | [required] | +**body** | [**User**](User.md) | Updated user object | [required] | + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/git_push.sh b/samples/client/petstore/rust/reqwest/petstore-async/git_push.sh new file mode 100644 index 000000000000..ced3be2b0c7b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/git_push.sh @@ -0,0 +1,58 @@ +#!/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" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +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://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${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://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs new file mode 100644 index 000000000000..4194f7a52d1d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs @@ -0,0 +1,50 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; + +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +pub struct ApiKey { + pub prefix: Option, + 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("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs new file mode 100644 index 000000000000..2bab29983bc3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs @@ -0,0 +1,57 @@ +use reqwest; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +mod pet_api; +pub use self::pet_api::{ add_pet }; +pub use self::pet_api::{ delete_pet }; +pub use self::pet_api::{ find_pets_by_status }; +pub use self::pet_api::{ find_pets_by_tags }; +pub use self::pet_api::{ get_pet_by_id }; +pub use self::pet_api::{ update_pet }; +pub use self::pet_api::{ update_pet_with_form }; +pub use self::pet_api::{ upload_file }; +mod store_api; +pub use self::store_api::{ delete_order }; +pub use self::store_api::{ get_inventory }; +pub use self::store_api::{ get_order_by_id }; +pub use self::store_api::{ place_order }; +mod user_api; +pub use self::user_api::{ create_user }; +pub use self::user_api::{ create_users_with_array_input }; +pub use self::user_api::{ create_users_with_list_input }; +pub use self::user_api::{ delete_user }; +pub use self::user_api::{ get_user_by_name }; +pub use self::user_api::{ login_user }; +pub use self::user_api::{ logout_user }; +pub use self::user_api::{ update_user }; + +pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs new file mode 100644 index 000000000000..8dfe56d1f1f4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs @@ -0,0 +1,186 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +#[allow(unused_imports)] +use std::rc::Rc; +use std::borrow::Borrow; +use std::option::Option; + +use reqwest; + +use super::{Error, configuration}; + + + pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, 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()); + } + if let Some(param_value) = api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = client.get(uri_str.as_str()); + + req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + 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()); + }; + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::>().await?) + } + + pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = client.get(uri_str.as_str()); + + req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + 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()); + }; + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::>().await?) + } + + pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, 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); + }; + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + + pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, 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()); + }; + let mut form_params = std::collections::HashMap::new(); + if let Some(param_value) = name { + form_params.insert("name", param_value.to_string()); + } + if let Some(param_value) = status { + form_params.insert("status", param_value.to_string()); + } + req_builder = req_builder.form(&form_params); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, 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()); + }; + let mut form = reqwest::multipart::Form::new(); + if let Some(param_value) = additional_metadata { + form = form.text("additionalMetadata", param_value.to_string()); + } + // TODO: support file upload for 'file' parameter + req_builder = req_builder.multipart(form); + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs new file mode 100644 index 000000000000..d9ab07295ec6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs @@ -0,0 +1,86 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +#[allow(unused_imports)] +use std::rc::Rc; +use std::borrow::Borrow; +use std::option::Option; + +use reqwest; + +use super::{Error, configuration}; + + + pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(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()); + } + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap, Error> { + let client = &configuration.client; + + let uri_str = format!("{}/store/inventory", configuration.base_path); + 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); + }; + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::<::std::collections::HashMap>().await?) + } + + pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, 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()); + } + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + + pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/store/order", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs new file mode 100644 index 000000000000..618cca717893 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs @@ -0,0 +1,144 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +#[allow(unused_imports)] +use std::rc::Rc; +use std::borrow::Borrow; +use std::option::Option; + +use reqwest; + +use super::{Error, configuration}; + + + pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user/createWithList", configuration.base_path); + 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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(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()); + } + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(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()); + } + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + + pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result { + let client = &configuration.client; + + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = client.get(uri_str.as_str()); + + req_builder = req_builder.query(&[("username", &username.to_string())]); + req_builder = req_builder.query(&[("password", &password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + Ok(client.execute(req).await?.error_for_status()?.json::().await?) + } + + pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user/logout", configuration.base_path); + 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()); + } + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + + pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error> { + let client = &configuration.client; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(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(&body); + + let req = req_builder.build()?; + client.execute(req).await?.error_for_status()?; + Ok(()) + } + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/lib.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/lib.rs new file mode 100644 index 000000000000..c1dd666f7957 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate serde_derive; + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/api_response.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/api_response.rs new file mode 100644 index 000000000000..16c49d8d61d6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/api_response.rs @@ -0,0 +1,36 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// ApiResponse : Describes the result of uploading an image resource + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct ApiResponse { + #[serde(rename = "code", skip_serializing_if = "Option::is_none")] + pub code: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub _type: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl ApiResponse { + /// Describes the result of uploading an image resource + pub fn new() -> ApiResponse { + ApiResponse { + code: None, + _type: None, + message: None, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/category.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/category.rs new file mode 100644 index 000000000000..ed937ac261de --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/category.rs @@ -0,0 +1,33 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// Category : A category for a pet + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Category { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Category { + /// A category for a pet + pub fn new() -> Category { + Category { + id: None, + name: None, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs new file mode 100644 index 000000000000..1baf2f7528e2 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs @@ -0,0 +1,12 @@ +pub mod api_response; +pub use self::api_response::ApiResponse; +pub mod category; +pub use self::category::Category; +pub mod order; +pub use self::order::Order; +pub mod pet; +pub use self::pet::Pet; +pub mod tag; +pub use self::tag::Tag; +pub mod user; +pub use self::user::User; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs new file mode 100644 index 000000000000..c64eae6d4ffe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs @@ -0,0 +1,56 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// Order : An order for a pets from the pet store + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Order { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "petId", skip_serializing_if = "Option::is_none")] + pub pet_id: Option, + #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] + pub quantity: Option, + #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] + pub ship_date: Option, + /// Order Status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "complete", skip_serializing_if = "Option::is_none")] + pub complete: Option, +} + +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, + } + } +} + +/// Order Status +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "placed")] + Placed, + #[serde(rename = "approved")] + Approved, + #[serde(rename = "delivered")] + Delivered, +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/pet.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/pet.rs new file mode 100644 index 000000000000..36c9d22c0694 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/pet.rs @@ -0,0 +1,56 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// Pet : A pet for sale in the pet store + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Pet { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "photoUrls")] + pub photo_urls: Vec, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + /// pet status in the store + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl Pet { + /// A pet for sale in the pet store + pub fn new(name: String, photo_urls: Vec) -> Pet { + Pet { + id: None, + category: None, + name, + photo_urls, + tags: None, + status: None, + } + } +} + +/// pet status in the store +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "available")] + Available, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "sold")] + Sold, +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/tag.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/tag.rs new file mode 100644 index 000000000000..e0ae6e9efcc0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/tag.rs @@ -0,0 +1,33 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// Tag : A tag for a pet + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Tag { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Tag { + /// A tag for a pet + pub fn new() -> Tag { + Tag { + id: None, + name: None, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/user.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/user.rs new file mode 100644 index 000000000000..360df3b9ec3a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/user.rs @@ -0,0 +1,52 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// User : A User who is purchasing from the pet store + + + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "username", skip_serializing_if = "Option::is_none")] + pub username: Option, + #[serde(rename = "firstName", skip_serializing_if = "Option::is_none")] + pub first_name: Option, + #[serde(rename = "lastName", skip_serializing_if = "Option::is_none")] + pub last_name: Option, + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "password", skip_serializing_if = "Option::is_none")] + pub password: Option, + #[serde(rename = "phone", skip_serializing_if = "Option::is_none")] + pub phone: Option, + /// User Status + #[serde(rename = "userStatus", skip_serializing_if = "Option::is_none")] + pub user_status: Option, +} + +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, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/tests/pet_tests.rs b/samples/client/petstore/rust/reqwest/petstore-async/tests/pet_tests.rs new file mode 100644 index 000000000000..50829ebaa3e8 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/tests/pet_tests.rs @@ -0,0 +1,34 @@ +extern crate petstore_reqwest_async; +//use petstore_reqwest_async::apis::PetApi; +//use petstore_reqwest_async::apis::PetApiClient; +use petstore_reqwest_async::apis::configuration; +//use petstore_reqwest::apis::PetApiUpdatePetWithFormParams; +use petstore_reqwest_async::models::{Pet}; +use std::option::Option; +use std::rc::Rc; + +#[test] +fn test_pet() { + let config = configuration::Configuration::new(); + //let pet_api_client = PetApiClient::new(Rc::new(config)); + + // create pet object + let photo_urls = vec!["https://11".to_string(), "https://22".to_string()]; + let mut new_pet = Pet::new("Rust Pet".to_string(), photo_urls); + new_pet.id = Option::Some(8787); + + // add pet + let _add_result = petstore_reqwest_async::apis::add_pet(&config, new_pet); + + // get pet + let pet_result = petstore_reqwest_async::apis::get_pet_by_id(&config, 8787); + + let _pet_result = match pet_result { + Ok(pet) => { + assert_eq!(pet.id, Option::Some(8787)); + assert_eq!(pet.name, "Rust Pet"); + assert_eq!(pet.photo_urls, vec!["https://11".to_string(), "https://22".to_string()]); + }, + Err(error) => println!("error: {:?}", error), + }; +} diff --git a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml index 7a2aed735ea5..bd9b1402d118 100644 --- a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml @@ -2,6 +2,7 @@ name = "petstore-reqwest" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs index c14d751153a1..2ce86d2804a5 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs @@ -37,5 +37,5 @@ pub use self::store_api::{ StoreApi, StoreApiClient }; mod user_api; pub use self::user_api::{ UserApi, UserApiClient }; -pub mod configuration; pub mod client; +pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs index be122c14b7ec..1d90f2f1219b 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs @@ -8,9 +8,9 @@ * Generated by: https://openapi-generator.tech */ +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; @@ -57,9 +57,7 @@ impl PetApi for PetApiClient { }; req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -81,9 +79,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.bearer_auth(token.to_owned()); }; - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -103,9 +99,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.bearer_auth(token.to_owned()); }; - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } @@ -124,9 +118,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.bearer_auth(token.to_owned()); }; - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } @@ -149,9 +141,7 @@ impl PetApi for PetApiClient { req_builder = req_builder.header("api_key", val); }; - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } @@ -170,9 +160,7 @@ impl PetApi for PetApiClient { }; req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -199,9 +187,7 @@ impl PetApi for PetApiClient { } req_builder = req_builder.form(&form_params); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -228,9 +214,7 @@ impl PetApi for PetApiClient { } req_builder = req_builder.multipart(form); - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs index 8856e2d9f05a..fee0b120f13f 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs @@ -8,9 +8,9 @@ * Generated by: https://openapi-generator.tech */ +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; @@ -49,9 +49,7 @@ impl StoreApi for StoreApiClient { 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(()) } @@ -75,9 +73,7 @@ impl StoreApi for StoreApiClient { req_builder = req_builder.header("api_key", val); }; - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } @@ -92,9 +88,7 @@ impl StoreApi for StoreApiClient { 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()?) } @@ -110,9 +104,7 @@ impl StoreApi for StoreApiClient { } req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - Ok(client.execute(req)?.error_for_status()?.json()?) } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs index 0ae109852975..a57be5aa6283 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs @@ -8,9 +8,9 @@ * Generated by: https://openapi-generator.tech */ +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; @@ -54,9 +54,7 @@ impl UserApi for UserApiClient { } req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -73,9 +71,7 @@ impl UserApi for UserApiClient { } req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -92,9 +88,7 @@ impl UserApi for UserApiClient { } req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } @@ -110,9 +104,7 @@ impl UserApi for UserApiClient { 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(()) } @@ -128,9 +120,7 @@ impl UserApi for UserApiClient { 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()?) } @@ -147,9 +137,7 @@ impl UserApi for UserApiClient { 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()?) } @@ -164,9 +152,7 @@ impl UserApi for UserApiClient { 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(()) } @@ -183,9 +169,7 @@ impl UserApi for UserApiClient { } req_builder = req_builder.json(&body); - // send request let req = req_builder.build()?; - client.execute(req)?.error_for_status()?; Ok(()) } diff --git a/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml b/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml index 60c968a7cf2f..1c36153fd797 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml @@ -2,6 +2,7 @@ name = "rust-test-reqwest" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] +edition = "2018" [dependencies] serde = "^1.0" diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs index 697d250b5401..1bb79873dae8 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs @@ -8,9 +8,9 @@ * Generated by: https://openapi-generator.tech */ +#[allow(unused_imports)] use std::rc::Rc; use std::borrow::Borrow; -#[allow(unused_imports)] use std::option::Option; use reqwest; @@ -46,9 +46,7 @@ impl DefaultApi for DefaultApiClient { 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(()) } diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs index 3b70668f6fd9..77bd60c058a5 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs @@ -33,5 +33,5 @@ pub fn urlencode>(s: T) -> String { mod default_api; pub use self::default_api::{ DefaultApi, DefaultApiClient }; -pub mod configuration; pub mod client; +pub mod configuration;