diff --git a/bin/configs/rust-reqwest-petstore-async.yaml b/bin/configs/rust-reqwest-petstore-async.yaml index e045f8485f2..ed156ec550e 100644 --- a/bin/configs/rust-reqwest-petstore-async.yaml +++ b/bin/configs/rust-reqwest-petstore-async.yaml @@ -1,7 +1,7 @@ generatorName: rust outputDir: samples/client/petstore/rust/reqwest/petstore-async library: reqwest -inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/rust additionalProperties: supportAsync: true diff --git a/bin/configs/rust-reqwest-petstore-awsv4signature.yaml b/bin/configs/rust-reqwest-petstore-awsv4signature.yaml index 82f44cae588..3ffd335719a 100644 --- a/bin/configs/rust-reqwest-petstore-awsv4signature.yaml +++ b/bin/configs/rust-reqwest-petstore-awsv4signature.yaml @@ -1,7 +1,7 @@ generatorName: rust outputDir: samples/client/petstore/rust/reqwest/petstore-awsv4signature library: reqwest -inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/rust additionalProperties: supportAsync: false diff --git a/bin/configs/unmaintained/rust-hyper-fileResponseTest.yaml b/bin/configs/unmaintained/rust-hyper-fileResponseTest.yaml deleted file mode 100644 index fc26c786be8..00000000000 --- a/bin/configs/unmaintained/rust-hyper-fileResponseTest.yaml +++ /dev/null @@ -1,9 +0,0 @@ -generatorName: rust -outputDir: samples/client/petstore/rust/hyper/fileResponseTest -library: hyper -inputSpec: modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json -templateDir: modules/openapi-generator/src/main/resources/rust -generateAliasAsModel: true -additionalProperties: - supportAsync: "false" - packageName: fileResponseTest-hyper diff --git a/bin/configs/unmaintained/rust-hyper-test.yaml b/bin/configs/unmaintained/rust-hyper-test.yaml deleted file mode 100644 index 371d69150dd..00000000000 --- a/bin/configs/unmaintained/rust-hyper-test.yaml +++ /dev/null @@ -1,8 +0,0 @@ -generatorName: rust -outputDir: samples/client/petstore/rust/hyper/rust-test -library: hyper -inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml -templateDir: modules/openapi-generator/src/main/resources/rust -additionalProperties: - supportAsync: "false" - packageName: rust-test-hyper diff --git a/bin/configs/unmaintained/rust-reqwest-fileResponseTest.yaml b/bin/configs/unmaintained/rust-reqwest-fileResponseTest.yaml deleted file mode 100644 index 15aadb72170..00000000000 --- a/bin/configs/unmaintained/rust-reqwest-fileResponseTest.yaml +++ /dev/null @@ -1,8 +0,0 @@ -generatorName: rust -outputDir: samples/client/petstore/rust/reqwest/fileResponseTest -library: reqwest -inputSpec: modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json -templateDir: modules/openapi-generator/src/main/resources/rust -additionalProperties: - supportAsync: "false" - packageName: fileResponseTest-reqwest diff --git a/bin/configs/unmaintained/rust-reqwest-test.yaml b/bin/configs/unmaintained/rust-reqwest-test.yaml deleted file mode 100644 index 74dbb40a812..00000000000 --- a/bin/configs/unmaintained/rust-reqwest-test.yaml +++ /dev/null @@ -1,8 +0,0 @@ -generatorName: rust -outputDir: samples/client/petstore/rust/reqwest/rust-test -library: reqwest -inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml -templateDir: modules/openapi-generator/src/main/resources/rust -additionalProperties: - supportAsync: "false" - packageName: rust-test-reqwest diff --git a/modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json b/modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json deleted file mode 100644 index 3fd70ed45e8..00000000000 --- a/modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "File Response Test", - "license": { - "name": "Apache-2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "basePath": "/v2", - "schemes": [ - "http" - ], - "paths": { - "/tests/fileResponse": { - "get": { - "operationId": "fileresponsetest", - "produces": [ - "application/octet-stream" - ], - "responses": { - "200": { - "description": "OutputFileData", - "schema": { - "type": "file" - } - } - } - } - } - } -} diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml index 8cbd1e18b15..28bafb3714b 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml @@ -599,6 +599,31 @@ paths: description: Invalid username supplied '404': description: User not found + '/tests/fileResponse': + get: + tags: + - testing + summary: Returns an image file + responses: + '200': + description: An image file + content: + image/jpeg: + schema: + type: string + format: binary + '/tests/typeTesting': + get: + tags: + - testing + summary: Route to test the TypeTesting schema + responses: + '200': + description: The TypeTesting response + content: + application/json: + schema: + $ref: '#/components/schemas/TypeTesting' externalDocs: description: Find out more about Swagger url: 'http://swagger.io' @@ -791,3 +816,34 @@ components: - A - B type: string + TypeTesting: + description: Test handling of different field data types + type: object + required: + - int32 + - int64 + - float + - double + - string + - boolean + - uuid + properties: + int32: + type: integer + format: int32 + int64: + type: integer + format: int64 + float: + type: number + format: float + double: + type: number + format: double + string: + type: string + boolean: + type: boolean + uuid: + type: string + format: uuid diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml deleted file mode 100644 index 861e84ca8d4..00000000000 --- a/modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml +++ /dev/null @@ -1,31 +0,0 @@ -openapi: 3.0.1 -info: - title: Rust client test spec - description: Special testing for the Rust client generator - version: 1.0.7 -paths: - /dummy: - get: - summary: A dummy endpoint to make the spec valid. - responses: - '200': - description: Success -components: - schemas: - TypeTesting: - description: Test handling of differing types (see \#3463) - type: object - properties: - integer: - type: integer - long: - type: long - number: - type: number - float: - type: float - double: - type: double - uuid: - type: string - format: uuid diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore b/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore deleted file mode 100644 index 6aa106405a4..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -**/*.rs.bk -Cargo.lock diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator-ignore b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/hyper/fileResponseTest/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/FILES deleted file mode 100644 index d85f759b592..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/FILES +++ /dev/null @@ -1,13 +0,0 @@ -.gitignore -.travis.yml -Cargo.toml -README.md -docs/DefaultApi.md -git_push.sh -src/apis/client.rs -src/apis/configuration.rs -src/apis/default_api.rs -src/apis/mod.rs -src/apis/request.rs -src/lib.rs -src/models/mod.rs diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.travis.yml b/samples/client/petstore/rust/hyper/fileResponseTest/.travis.yml deleted file mode 100644 index 22761ba7ee1..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: rust diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml deleted file mode 100644 index 808f425995b..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "fileResponseTest-hyper" -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" -hyper = "~0.11" -serde_yaml = "0.7" -base64 = "~0.7.0" -futures = "0.1.23" - -[dev-dependencies] -tokio-core = "*" diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/README.md b/samples/client/petstore/rust/hyper/fileResponseTest/README.md deleted file mode 100644 index 1cb8e0b83f1..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Rust API client for fileResponseTest-hyper - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -## 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://localhost/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultApi* | [**fileresponsetest**](docs/DefaultApi.md#fileresponsetest) | **Get** /tests/fileResponse | - - -## Documentation For Models - - - -To get access to the crate's generated documentation, use: - -``` -cargo doc --open -``` - -## Author - - - diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md b/samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md deleted file mode 100644 index 6e8157cf0e5..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md +++ /dev/null @@ -1,34 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://localhost/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**fileresponsetest**](DefaultApi.md#fileresponsetest) | **Get** /tests/fileResponse | - - - -## fileresponsetest - -> std::path::PathBuf fileresponsetest() - - -### Parameters - -This endpoint does not need any parameter. - -### Return type - -[**std::path::PathBuf**](std::path::PathBuf.md) - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/octet-stream - -[[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/hyper/fileResponseTest/git_push.sh b/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh deleted file mode 100644 index ced3be2b0c7..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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/hyper/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs deleted file mode 100644 index 4976ba81c65..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::rc::Rc; - -use hyper; -use super::configuration::Configuration; - -pub struct APIClient { - default_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), - } - } - - pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ - self.default_api.as_ref() - } - -} diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs deleted file mode 100644 index 6a3d69dddd6..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * File Response Test - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use hyper; - -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: hyper::client::Client, - pub basic_auth: Option, - pub oauth_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(client: hyper::client::Client) -> Configuration { - Configuration { - base_path: "http://localhost/v2".to_owned(), - user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), - client: client, - basic_auth: None, - oauth_access_token: None, - api_key: None, - } - } -} diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs deleted file mode 100644 index fb52b3cc52c..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs +++ /dev/null @@ -1,47 +0,0 @@ -/* - * File Response Test - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use std::rc::Rc; -use std::borrow::Borrow; -#[allow(unused_imports)] -use std::option::Option; - -use hyper; -use serde_json; -use futures::Future; - -use super::{Error, configuration}; -use super::request as __internal_request; - -pub struct DefaultApiClient { - configuration: Rc>, -} - -impl DefaultApiClient { - pub fn new(configuration: Rc>) -> DefaultApiClient { - DefaultApiClient { - configuration, - } - } -} - -pub trait DefaultApi { - fn fileresponsetest(&self, ) -> Box>>; -} - -implDefaultApi for DefaultApiClient { - fn fileresponsetest(&self, ) -> Box>> { - let mut req = __internal_request::Request::new(hyper::Method::Get, "/tests/fileResponse".to_string()) - ; - - req.execute(self.configuration.borrow()) - } - -} diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/mod.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/mod.rs deleted file mode 100644 index cb13d23efc2..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/mod.rs +++ /dev/null @@ -1,58 +0,0 @@ -use hyper; -use serde; -use serde_json; - -#[derive(Debug)] -pub enum Error { - UriError(hyper::error::UriError), - Hyper(hyper::Error), - Serde(serde_json::Error), - ApiError(ApiError), -} - -#[derive(Debug)] -pub struct ApiError { - pub code: hyper::StatusCode, - pub content: Option, -} - -impl<'de, T> From<(hyper::StatusCode, &'de [u8])> for Error - where T: serde::Deserialize<'de> { - fn from(e: (hyper::StatusCode, &'de [u8])) -> Self { - if e.1.len() == 0 { - return Error::ApiError(ApiError{ - code: e.0, - content: None, - }); - } - match serde_json::from_slice::(e.1) { - Ok(t) => Error::ApiError(ApiError{ - code: e.0, - content: Some(t), - }), - Err(e) => { - Error::from(e) - } - } - } -} - -impl From for Error { - fn from(e: hyper::Error) -> Self { - return Error::Hyper(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - return Error::Serde(e) - } -} - -mod request; - -mod default_api; -pub use self::default_api::{ DefaultApi, DefaultApiClient }; - -pub mod configuration; -pub mod client; diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs deleted file mode 100644 index f97b5277196..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs +++ /dev/null @@ -1,239 +0,0 @@ -use std::borrow::Cow; -use std::collections::HashMap; - -use super::{configuration, Error}; -use futures; -use futures::{Future, Stream}; -use hyper; -use hyper::header::UserAgent; -use serde; -use serde_json; - -pub(crate) struct ApiKey { - pub in_header: bool, - pub in_query: bool, - pub param_name: String, -} - -impl ApiKey { - fn key(&self, prefix: &Option, key: &str) -> String { - match prefix { - None => key.to_owned(), - Some(ref prefix) => format!("{} {}", prefix, key), - } - } -} - -#[allow(dead_code)] -pub(crate) enum Auth { - None, - ApiKey(ApiKey), - Basic, - Oauth, -} - -pub(crate) struct Request { - auth: Auth, - method: hyper::Method, - path: String, - query_params: HashMap, - no_return_type: bool, - path_params: HashMap, - form_params: HashMap, - header_params: HashMap, - // TODO: multiple body params are possible technically, but not supported here. - serialized_body: Option, -} - -impl Request { - pub fn new(method: hyper::Method, path: String) -> Self { - Request { - auth: Auth::None, - method: method, - path: path, - query_params: HashMap::new(), - path_params: HashMap::new(), - form_params: HashMap::new(), - header_params: HashMap::new(), - serialized_body: None, - no_return_type: false, - } - } - - pub fn with_body_param(mut self, param: T) -> Self { - self.serialized_body = Some(serde_json::to_string(¶m).unwrap()); - self - } - - pub fn with_header_param(mut self, basename: String, param: String) -> Self { - self.header_params.insert(basename, param); - self - } - - pub fn with_query_param(mut self, basename: String, param: String) -> Self { - self.query_params.insert(basename, param); - self - } - - pub fn with_path_param(mut self, basename: String, param: String) -> Self { - self.path_params.insert(basename, param); - self - } - - pub fn with_form_param(mut self, basename: String, param: String) -> Self { - self.form_params.insert(basename, param); - self - } - - pub fn returns_nothing(mut self) -> Self { - self.no_return_type = true; - self - } - - pub fn with_auth(mut self, auth: Auth) -> Self { - self.auth = auth; - self - } - - pub fn execute<'a, C, U>( - self, - conf: &configuration::Configuration, - ) -> Box> + 'a> - where - C: hyper::client::Connect, - U: Sized + 'a, - for<'de> U: serde::Deserialize<'de>, - { - let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned()); - // raw_headers is for headers we don't know the proper type of (e.g. custom api key - // headers); headers is for ones we do know the type of. - let mut raw_headers = HashMap::new(); - let mut headers: hyper::header::Headers = hyper::header::Headers::new(); - - let mut path = self.path; - for (k, v) in self.path_params { - // replace {id} with the value of the id path param - path = path.replace(&format!("{{{}}}", k), &v); - } - - for (k, v) in self.header_params { - raw_headers.insert(k, v); - } - - for (key, val) in self.query_params { - query_string.append_pair(&key, &val); - } - - match self.auth { - Auth::ApiKey(apikey) => { - if let Some(ref key) = conf.api_key { - let val = apikey.key(&key.prefix, &key.key); - if apikey.in_query { - query_string.append_pair(&apikey.param_name, &val); - } - if apikey.in_header { - raw_headers.insert(apikey.param_name, val); - } - } - } - Auth::Basic => { - if let Some(ref auth_conf) = conf.basic_auth { - let auth = hyper::header::Authorization(hyper::header::Basic { - username: auth_conf.0.to_owned(), - password: auth_conf.1.to_owned(), - }); - headers.set(auth); - } - } - Auth::Oauth => { - if let Some(ref token) = conf.oauth_access_token { - let auth = hyper::header::Authorization(hyper::header::Bearer { - token: token.to_owned(), - }); - headers.set(auth); - } - } - Auth::None => {} - } - - let mut uri_str = format!("{}{}", conf.base_path, path); - - let query_string_str = query_string.finish(); - if query_string_str != "" { - uri_str += "?"; - uri_str += &query_string_str; - } - let uri: hyper::Uri = match uri_str.parse() { - Err(e) => { - return Box::new(futures::future::err(Error::UriError(e))); - } - Ok(u) => u, - }; - - let mut req = hyper::Request::new(self.method, uri); - { - let req_headers = req.headers_mut(); - if let Some(ref user_agent) = conf.user_agent { - req_headers.set(UserAgent::new(Cow::Owned(user_agent.clone()))); - } - - req_headers.extend(headers.iter()); - - for (key, val) in raw_headers { - req_headers.set_raw(key, val); - } - } - - if self.form_params.len() > 0 { - req.headers_mut().set(hyper::header::ContentType::form_url_encoded()); - let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned()); - for (k, v) in self.form_params { - enc.append_pair(&k, &v); - } - req.set_body(enc.finish()); - } - - if let Some(body) = self.serialized_body { - req.headers_mut().set(hyper::header::ContentType::json()); - req.headers_mut() - .set(hyper::header::ContentLength(body.len() as u64)); - req.set_body(body); - } - - let no_ret_type = self.no_return_type; - let res = conf.client - .request(req) - .map_err(|e| Error::from(e)) - .and_then(|resp| { - let status = resp.status(); - resp.body() - .concat2() - .and_then(move |body| Ok((status, body))) - .map_err(|e| Error::from(e)) - }) - .and_then(|(status, body)| { - if status.is_success() { - Ok(body) - } else { - Err(Error::from((status, &*body))) - } - }); - Box::new( - res - .and_then(move |body| { - let parsed: Result = if no_ret_type { - // This is a hack; if there's no_ret_type, U is (), but serde_json gives an - // error when deserializing "" into (), so deserialize 'null' into it - // instead. - // An alternate option would be to require U: Default, and then return - // U::default() here instead since () implements that, but then we'd - // need to impl default for all models. - serde_json::from_str("null") - } else { - serde_json::from_slice(&body) - }; - parsed.map_err(|e| Error::from(e)) - }) - ) - } -} diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/lib.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/lib.rs deleted file mode 100644 index a76d822525d..00000000000 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[macro_use] -extern crate serde_derive; - -extern crate serde; -extern crate serde_json; -extern crate url; -extern crate hyper; -extern crate futures; - -pub mod apis; -pub mod models; diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/models/mod.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/models/mod.rs deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES index 639c6877625..26ff149a1a8 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES @@ -13,6 +13,8 @@ docs/PetApi.md docs/PropertyTest.md docs/StoreApi.md docs/Tag.md +docs/TestingApi.md +docs/TypeTesting.md docs/User.md docs/UserApi.md git_push.sh @@ -23,6 +25,7 @@ src/apis/mod.rs src/apis/pet_api.rs src/apis/request.rs src/apis/store_api.rs +src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs src/models/action_container.rs @@ -34,4 +37,5 @@ src/models/order.rs src/models/pet.rs src/models/property_test.rs src/models/tag.rs +src/models/type_testing.rs src/models/user.rs diff --git a/samples/client/petstore/rust/hyper/petstore/README.md b/samples/client/petstore/rust/hyper/petstore/README.md index b068ac70fa7..29da32b054d 100644 --- a/samples/client/petstore/rust/hyper/petstore/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -38,6 +38,8 @@ Class | Method | HTTP request | Description *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 +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema *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 @@ -58,6 +60,7 @@ Class | Method | HTTP request | Description - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Tag](docs/Tag.md) + - [TypeTesting](docs/TypeTesting.md) - [User](docs/User.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/DefaultApi.md b/samples/client/petstore/rust/hyper/petstore/docs/DefaultApi.md new file mode 100644 index 00000000000..54af2295257 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/DefaultApi.md @@ -0,0 +1,60 @@ +# \DefaultApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](DefaultApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](DefaultApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md new file mode 100644 index 00000000000..9f72e78530b --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md @@ -0,0 +1,60 @@ +# \TestingApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md similarity index 51% rename from samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md rename to samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md index 7b05cee280a..6beca6dbac1 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md @@ -4,12 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**integer** | Option<**i32**> | | [optional] -**long** | Option<**i64**> | | [optional] -**number** | Option<**f32**> | | [optional] -**float** | Option<**f32**> | | [optional] -**double** | Option<**f64**> | | [optional] -**uuid** | Option<**String**> | | [optional] +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | [**uuid::Uuid**](uuid::Uuid.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) diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs index e209050c597..c38f01cdc55 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs @@ -7,6 +7,7 @@ pub struct APIClient { fake_api: Box, pet_api: Box, store_api: Box, + testing_api: Box, user_api: Box, } @@ -19,6 +20,7 @@ impl APIClient { fake_api: Box::new(crate::apis::FakeApiClient::new(rc.clone())), pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())), store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())), + testing_api: Box::new(crate::apis::TestingApiClient::new(rc.clone())), user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())), } } @@ -35,6 +37,10 @@ impl APIClient { self.store_api.as_ref() } + pub fn testing_api(&self) -> &dyn crate::apis::TestingApi{ + self.testing_api.as_ref() + } + pub fn user_api(&self) -> &dyn crate::apis::UserApi{ self.user_api.as_ref() } diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs index e2ccc5d6a38..2abfb5a4e60 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs @@ -53,6 +53,8 @@ mod pet_api; pub use self::pet_api::{ PetApi, PetApiClient }; mod store_api; pub use self::store_api::{ StoreApi, StoreApiClient }; +mod testing_api; +pub use self::testing_api::{ TestingApi, TestingApiClient }; mod user_api; pub use self::user_api::{ UserApi, UserApiClient }; diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs new file mode 100644 index 00000000000..fd521555b76 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs @@ -0,0 +1,60 @@ +/* + * 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 std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct TestingApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl TestingApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> TestingApiClient { + TestingApiClient { + configuration, + } + } +} + +pub trait TestingApi { + fn tests_file_response_get(&self, ) -> Pin>>>; + fn tests_type_testing_get(&self, ) -> Pin>>>; +} + +implTestingApi for TestingApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn tests_file_response_get(&self, ) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn tests_type_testing_get(&self, ) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/typeTesting".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs index 10b2293873f..fb875c47a06 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -14,5 +14,7 @@ pub mod property_test; pub use self::property_test::PropertyTest; pub mod tag; pub use self::tag::Tag; +pub mod type_testing; +pub use self::type_testing::TypeTesting; pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs b/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs new file mode 100644 index 00000000000..dda67915dfe --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs @@ -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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// TypeTesting : Test handling of different field data types + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, +} + +impl TypeTesting { + /// Test handling of different field data types + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + } + } +} + + diff --git a/samples/client/petstore/rust/hyper/rust-test/.gitignore b/samples/client/petstore/rust/hyper/rust-test/.gitignore deleted file mode 100644 index 6aa106405a4..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -**/*.rs.bk -Cargo.lock diff --git a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator-ignore b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/hyper/rust-test/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/FILES deleted file mode 100644 index 22f11c2df5b..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/FILES +++ /dev/null @@ -1,15 +0,0 @@ -.gitignore -.travis.yml -Cargo.toml -README.md -docs/DefaultApi.md -docs/TypeTesting.md -git_push.sh -src/apis/client.rs -src/apis/configuration.rs -src/apis/default_api.rs -src/apis/mod.rs -src/apis/request.rs -src/lib.rs -src/models/mod.rs -src/models/type_testing.rs diff --git a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/rust-test/.travis.yml b/samples/client/petstore/rust/hyper/rust-test/.travis.yml deleted file mode 100644 index 22761ba7ee1..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: rust diff --git a/samples/client/petstore/rust/hyper/rust-test/Cargo.toml b/samples/client/petstore/rust/hyper/rust-test/Cargo.toml deleted file mode 100644 index 4a39ba0c5fb..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "rust-test-hyper" -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" -hyper = "~0.11" -serde_yaml = "0.7" -base64 = "~0.7.0" -futures = "0.1.23" - -[dev-dependencies] -tokio-core = "*" diff --git a/samples/client/petstore/rust/hyper/rust-test/README.md b/samples/client/petstore/rust/hyper/rust-test/README.md deleted file mode 100644 index 1383eecfd30..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Rust API client for rust-test-hyper - -Special testing for the Rust client generator - -## 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.7 -- 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://localhost* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultApi* | [**dummy_get**](docs/DefaultApi.md#dummy_get) | **Get** /dummy | A dummy endpoint to make the spec valid. - - -## Documentation For Models - - - [TypeTesting](docs/TypeTesting.md) - - -To get access to the crate's generated documentation, use: - -``` -cargo doc --open -``` - -## Author - - - diff --git a/samples/client/petstore/rust/hyper/rust-test/docs/DefaultApi.md b/samples/client/petstore/rust/hyper/rust-test/docs/DefaultApi.md deleted file mode 100644 index caf46321830..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/docs/DefaultApi.md +++ /dev/null @@ -1,34 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**dummy_get**](DefaultApi.md#dummy_get) | **Get** /dummy | A dummy endpoint to make the spec valid. - - - -## dummy_get - -> dummy_get() -A dummy endpoint to make the spec valid. - -### 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) - diff --git a/samples/client/petstore/rust/hyper/rust-test/git_push.sh b/samples/client/petstore/rust/hyper/rust-test/git_push.sh deleted file mode 100644 index ced3be2b0c7..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/git_push.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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/hyper/rust-test/src/apis/client.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs deleted file mode 100644 index 4976ba81c65..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::rc::Rc; - -use hyper; -use super::configuration::Configuration; - -pub struct APIClient { - default_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), - } - } - - pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ - self.default_api.as_ref() - } - -} diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/configuration.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/configuration.rs deleted file mode 100644 index 79762a1437c..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/configuration.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * Generated by: https://openapi-generator.tech - */ - -use hyper; - -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: hyper::client::Client, - pub basic_auth: Option, - pub oauth_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(client: hyper::client::Client) -> Configuration { - Configuration { - base_path: "http://localhost".to_owned(), - user_agent: Some("OpenAPI-Generator/1.0.7/rust".to_owned()), - client: client, - basic_auth: None, - oauth_access_token: None, - api_key: None, - } - } -} diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs deleted file mode 100644 index 5ebb6a09dd3..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * Generated by: https://openapi-generator.tech - */ - -use std::rc::Rc; -use std::borrow::Borrow; -#[allow(unused_imports)] -use std::option::Option; - -use hyper; -use serde_json; -use futures::Future; - -use super::{Error, configuration}; -use super::request as __internal_request; - -pub struct DefaultApiClient { - configuration: Rc>, -} - -impl DefaultApiClient { - pub fn new(configuration: Rc>) -> DefaultApiClient { - DefaultApiClient { - configuration, - } - } -} - -pub trait DefaultApi { - fn dummy_get(&self, ) -> Box>>; -} - -implDefaultApi for DefaultApiClient { - fn dummy_get(&self, ) -> Box>> { - let mut req = __internal_request::Request::new(hyper::Method::Get, "/dummy".to_string()) - ; - req = req.returns_nothing(); - - req.execute(self.configuration.borrow()) - } - -} diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/mod.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/mod.rs deleted file mode 100644 index cb13d23efc2..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/mod.rs +++ /dev/null @@ -1,58 +0,0 @@ -use hyper; -use serde; -use serde_json; - -#[derive(Debug)] -pub enum Error { - UriError(hyper::error::UriError), - Hyper(hyper::Error), - Serde(serde_json::Error), - ApiError(ApiError), -} - -#[derive(Debug)] -pub struct ApiError { - pub code: hyper::StatusCode, - pub content: Option, -} - -impl<'de, T> From<(hyper::StatusCode, &'de [u8])> for Error - where T: serde::Deserialize<'de> { - fn from(e: (hyper::StatusCode, &'de [u8])) -> Self { - if e.1.len() == 0 { - return Error::ApiError(ApiError{ - code: e.0, - content: None, - }); - } - match serde_json::from_slice::(e.1) { - Ok(t) => Error::ApiError(ApiError{ - code: e.0, - content: Some(t), - }), - Err(e) => { - Error::from(e) - } - } - } -} - -impl From for Error { - fn from(e: hyper::Error) -> Self { - return Error::Hyper(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - return Error::Serde(e) - } -} - -mod request; - -mod default_api; -pub use self::default_api::{ DefaultApi, DefaultApiClient }; - -pub mod configuration; -pub mod client; diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs deleted file mode 100644 index f97b5277196..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs +++ /dev/null @@ -1,239 +0,0 @@ -use std::borrow::Cow; -use std::collections::HashMap; - -use super::{configuration, Error}; -use futures; -use futures::{Future, Stream}; -use hyper; -use hyper::header::UserAgent; -use serde; -use serde_json; - -pub(crate) struct ApiKey { - pub in_header: bool, - pub in_query: bool, - pub param_name: String, -} - -impl ApiKey { - fn key(&self, prefix: &Option, key: &str) -> String { - match prefix { - None => key.to_owned(), - Some(ref prefix) => format!("{} {}", prefix, key), - } - } -} - -#[allow(dead_code)] -pub(crate) enum Auth { - None, - ApiKey(ApiKey), - Basic, - Oauth, -} - -pub(crate) struct Request { - auth: Auth, - method: hyper::Method, - path: String, - query_params: HashMap, - no_return_type: bool, - path_params: HashMap, - form_params: HashMap, - header_params: HashMap, - // TODO: multiple body params are possible technically, but not supported here. - serialized_body: Option, -} - -impl Request { - pub fn new(method: hyper::Method, path: String) -> Self { - Request { - auth: Auth::None, - method: method, - path: path, - query_params: HashMap::new(), - path_params: HashMap::new(), - form_params: HashMap::new(), - header_params: HashMap::new(), - serialized_body: None, - no_return_type: false, - } - } - - pub fn with_body_param(mut self, param: T) -> Self { - self.serialized_body = Some(serde_json::to_string(¶m).unwrap()); - self - } - - pub fn with_header_param(mut self, basename: String, param: String) -> Self { - self.header_params.insert(basename, param); - self - } - - pub fn with_query_param(mut self, basename: String, param: String) -> Self { - self.query_params.insert(basename, param); - self - } - - pub fn with_path_param(mut self, basename: String, param: String) -> Self { - self.path_params.insert(basename, param); - self - } - - pub fn with_form_param(mut self, basename: String, param: String) -> Self { - self.form_params.insert(basename, param); - self - } - - pub fn returns_nothing(mut self) -> Self { - self.no_return_type = true; - self - } - - pub fn with_auth(mut self, auth: Auth) -> Self { - self.auth = auth; - self - } - - pub fn execute<'a, C, U>( - self, - conf: &configuration::Configuration, - ) -> Box> + 'a> - where - C: hyper::client::Connect, - U: Sized + 'a, - for<'de> U: serde::Deserialize<'de>, - { - let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned()); - // raw_headers is for headers we don't know the proper type of (e.g. custom api key - // headers); headers is for ones we do know the type of. - let mut raw_headers = HashMap::new(); - let mut headers: hyper::header::Headers = hyper::header::Headers::new(); - - let mut path = self.path; - for (k, v) in self.path_params { - // replace {id} with the value of the id path param - path = path.replace(&format!("{{{}}}", k), &v); - } - - for (k, v) in self.header_params { - raw_headers.insert(k, v); - } - - for (key, val) in self.query_params { - query_string.append_pair(&key, &val); - } - - match self.auth { - Auth::ApiKey(apikey) => { - if let Some(ref key) = conf.api_key { - let val = apikey.key(&key.prefix, &key.key); - if apikey.in_query { - query_string.append_pair(&apikey.param_name, &val); - } - if apikey.in_header { - raw_headers.insert(apikey.param_name, val); - } - } - } - Auth::Basic => { - if let Some(ref auth_conf) = conf.basic_auth { - let auth = hyper::header::Authorization(hyper::header::Basic { - username: auth_conf.0.to_owned(), - password: auth_conf.1.to_owned(), - }); - headers.set(auth); - } - } - Auth::Oauth => { - if let Some(ref token) = conf.oauth_access_token { - let auth = hyper::header::Authorization(hyper::header::Bearer { - token: token.to_owned(), - }); - headers.set(auth); - } - } - Auth::None => {} - } - - let mut uri_str = format!("{}{}", conf.base_path, path); - - let query_string_str = query_string.finish(); - if query_string_str != "" { - uri_str += "?"; - uri_str += &query_string_str; - } - let uri: hyper::Uri = match uri_str.parse() { - Err(e) => { - return Box::new(futures::future::err(Error::UriError(e))); - } - Ok(u) => u, - }; - - let mut req = hyper::Request::new(self.method, uri); - { - let req_headers = req.headers_mut(); - if let Some(ref user_agent) = conf.user_agent { - req_headers.set(UserAgent::new(Cow::Owned(user_agent.clone()))); - } - - req_headers.extend(headers.iter()); - - for (key, val) in raw_headers { - req_headers.set_raw(key, val); - } - } - - if self.form_params.len() > 0 { - req.headers_mut().set(hyper::header::ContentType::form_url_encoded()); - let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned()); - for (k, v) in self.form_params { - enc.append_pair(&k, &v); - } - req.set_body(enc.finish()); - } - - if let Some(body) = self.serialized_body { - req.headers_mut().set(hyper::header::ContentType::json()); - req.headers_mut() - .set(hyper::header::ContentLength(body.len() as u64)); - req.set_body(body); - } - - let no_ret_type = self.no_return_type; - let res = conf.client - .request(req) - .map_err(|e| Error::from(e)) - .and_then(|resp| { - let status = resp.status(); - resp.body() - .concat2() - .and_then(move |body| Ok((status, body))) - .map_err(|e| Error::from(e)) - }) - .and_then(|(status, body)| { - if status.is_success() { - Ok(body) - } else { - Err(Error::from((status, &*body))) - } - }); - Box::new( - res - .and_then(move |body| { - let parsed: Result = if no_ret_type { - // This is a hack; if there's no_ret_type, U is (), but serde_json gives an - // error when deserializing "" into (), so deserialize 'null' into it - // instead. - // An alternate option would be to require U: Default, and then return - // U::default() here instead since () implements that, but then we'd - // need to impl default for all models. - serde_json::from_str("null") - } else { - serde_json::from_slice(&body) - }; - parsed.map_err(|e| Error::from(e)) - }) - ) - } -} diff --git a/samples/client/petstore/rust/hyper/rust-test/src/lib.rs b/samples/client/petstore/rust/hyper/rust-test/src/lib.rs deleted file mode 100644 index a76d822525d..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[macro_use] -extern crate serde_derive; - -extern crate serde; -extern crate serde_json; -extern crate url; -extern crate hyper; -extern crate futures; - -pub mod apis; -pub mod models; diff --git a/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs b/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs deleted file mode 100644 index 97887b5798e..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod type_testing; -pub use self::type_testing::TypeTesting; diff --git a/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs b/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs deleted file mode 100644 index 530d1d1365d..00000000000 --- a/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * Generated by: https://openapi-generator.tech - */ - -/// TypeTesting : Test handling of differing types (see \\#3463) - - - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct TypeTesting { - #[serde(rename = "integer", skip_serializing_if = "Option::is_none")] - pub integer: Option, - #[serde(rename = "long", skip_serializing_if = "Option::is_none")] - pub long: Option, - #[serde(rename = "number", skip_serializing_if = "Option::is_none")] - pub number: Option, - #[serde(rename = "float", skip_serializing_if = "Option::is_none")] - pub float: Option, - #[serde(rename = "double", skip_serializing_if = "Option::is_none")] - pub double: Option, - #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] - pub uuid: Option, -} - -impl TypeTesting { - /// Test handling of differing types (see \\#3463) - pub fn new() -> TypeTesting { - TypeTesting { - integer: None, - long: None, - number: None, - float: None, - double: None, - uuid: None, - } - } -} - - diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore b/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore deleted file mode 100644 index 6aa106405a4..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -**/*.rs.bk -Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/fileResponseTest/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/FILES deleted file mode 100644 index 20457f1a6d0..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/FILES +++ /dev/null @@ -1,11 +0,0 @@ -.gitignore -.travis.yml -Cargo.toml -README.md -docs/DefaultApi.md -git_push.sh -src/apis/configuration.rs -src/apis/default_api.rs -src/apis/mod.rs -src/lib.rs -src/models/mod.rs diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.travis.yml b/samples/client/petstore/rust/reqwest/fileResponseTest/.travis.yml deleted file mode 100644 index 22761ba7ee1..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: rust diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml deleted file mode 100644 index 67a75586797..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "fileResponseTest-reqwest" -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" -reqwest = "~0.9" - -[dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/README.md b/samples/client/petstore/rust/reqwest/fileResponseTest/README.md deleted file mode 100644 index 8bf849adb68..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Rust API client for fileResponseTest-reqwest - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -## 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://localhost/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultApi* | [**fileresponsetest**](docs/DefaultApi.md#fileresponsetest) | **get** /tests/fileResponse | - - -## Documentation For Models - - - -To get access to the crate's generated documentation, use: - -``` -cargo doc --open -``` - -## Author - - - diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/docs/DefaultApi.md b/samples/client/petstore/rust/reqwest/fileResponseTest/docs/DefaultApi.md deleted file mode 100644 index 0b0273e4346..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/docs/DefaultApi.md +++ /dev/null @@ -1,34 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://localhost/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**fileresponsetest**](DefaultApi.md#fileresponsetest) | **get** /tests/fileResponse | - - - -## fileresponsetest - -> std::path::PathBuf fileresponsetest() - - -### Parameters - -This endpoint does not need any parameter. - -### Return type - -[**std::path::PathBuf**](std::path::PathBuf.md) - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/octet-stream - -[[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/fileResponseTest/git_push.sh b/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh deleted file mode 100644 index ced3be2b0c7..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs deleted file mode 100644 index b10fef0b554..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::rc::Rc; - -use super::configuration::Configuration; - -pub struct APIClient { - default_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - default_api: Box::new(crate::apis::default_api::DefaultApiClient::new(rc.clone())), - } - } - - pub fn default_api(&self) -> &dyn crate::apis::default_api::DefaultApi{ - self.default_api.as_ref() - } - -} diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/configuration.rs deleted file mode 100644 index 107d558aa4f..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/configuration.rs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * File Response Test - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * 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://localhost/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/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs deleted file mode 100644 index 1dad859d20d..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * File Response Test - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - - -use reqwest; - -use crate::apis::ResponseContent; -use super::{Error, configuration}; - - -/// struct for typed errors of method `fileresponsetest` -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum FileresponsetestError { - UnknownValue(serde_json::Value), -} - - -pub fn fileresponsetest(configuration: &configuration::Configuration, ) -> Result> { - - let client = &configuration.client; - - let uri_str = format!("{}/tests/fileResponse", 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()?; - let mut resp = client.execute(req)?; - - let status = resp.status(); - let content = resp.text()?; - - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) - } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) - } -} - diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs deleted file mode 100644 index aeab00a7bc0..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use reqwest; -use serde_json; - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), -} - -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() -} - -pub mod default_api; - -pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs deleted file mode 100644 index c1dd666f795..00000000000 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[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/fileResponseTest/src/models/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/models/mod.rs deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES index 611ac7b6dd7..b2e3ba3cf43 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -2,26 +2,38 @@ .travis.yml Cargo.toml README.md +docs/ActionContainer.md docs/ApiResponse.md +docs/Baz.md docs/Category.md +docs/FakeApi.md docs/Order.md docs/Pet.md docs/PetApi.md +docs/PropertyTest.md docs/StoreApi.md docs/Tag.md +docs/TestingApi.md +docs/TypeTesting.md docs/User.md docs/UserApi.md git_push.sh src/apis/configuration.rs +src/apis/fake_api.rs src/apis/mod.rs src/apis/pet_api.rs src/apis/store_api.rs +src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/action_container.rs src/models/api_response.rs +src/models/baz.rs src/models/category.rs src/models/mod.rs src/models/order.rs src/models/pet.rs +src/models/property_test.rs src/models/tag.rs +src/models/type_testing.rs src/models/user.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/README.md b/samples/client/petstore/rust/reqwest/petstore-async/README.md index a26b68bd333..6ec9b9c17e0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -25,6 +25,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters *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 @@ -37,6 +38,8 @@ Class | Method | HTTP request | Description *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 +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *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 @@ -49,11 +52,15 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) + - [PropertyTest](docs/PropertyTest.md) - [Tag](docs/Tag.md) + - [TypeTesting](docs/TypeTesting.md) - [User](docs/User.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ActionContainer.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ActionContainer.md new file mode 100644 index 00000000000..8490ec5d821 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ActionContainer.md @@ -0,0 +1,11 @@ +# ActionContainer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**action** | [**crate::models::Baz**](Baz.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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Baz.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Baz.md new file mode 100644 index 00000000000..68c84b1b1b0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Baz.md @@ -0,0 +1,10 @@ +# Baz + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/FakeApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/FakeApi.md new file mode 100644 index 00000000000..55bf612aa21 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/FakeApi.md @@ -0,0 +1,41 @@ +# \FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters + + + +## test_nullable_required_param + +> test_nullable_required_param(username, dummy_required_nullable_param, uppercase) +To test nullable required parameters + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | +**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] | +**uppercase** | Option<**String**> | To test parameter names in upper case | | + +### 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/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md new file mode 100644 index 00000000000..3f36c163de0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md @@ -0,0 +1,11 @@ +# PropertyTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [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/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md new file mode 100644 index 00000000000..ca0c06e06a0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md @@ -0,0 +1,60 @@ +# \TestingApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md similarity index 51% rename from samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md rename to samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md index 7b05cee280a..6beca6dbac1 100644 --- a/samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md @@ -4,12 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**integer** | Option<**i32**> | | [optional] -**long** | Option<**i64**> | | [optional] -**number** | Option<**f32**> | | [optional] -**float** | Option<**f32**> | | [optional] -**double** | Option<**f64**> | | [optional] -**uuid** | Option<**String**> | | [optional] +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | [**uuid::Uuid**](uuid::Uuid.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) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs new file mode 100644 index 00000000000..d457ee3888e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs @@ -0,0 +1,89 @@ +/* + * 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; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`test_nullable_required_param`] +#[derive(Clone, Debug, Default)] +pub struct TestNullableRequiredParamParams { + /// The name that needs to be fetched. Use user1 for testing. + pub username: String, + /// To test nullable required parameters + pub dummy_required_nullable_param: Option, + /// To test parameter names in upper case + pub uppercase: Option +} + + +/// struct for typed successes of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamSuccess { + Status200(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// +pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + let dummy_required_nullable_param = params.dummy_required_nullable_param; + let uppercase = params.uppercase; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + match dummy_required_nullable_param { + Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, + None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + } + if let Some(local_var_param_value) = uppercase { + local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + 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 index c24f345edf3..34085cdedff 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs @@ -61,8 +61,10 @@ pub fn urlencode>(s: T) -> String { ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() } +pub mod fake_api; pub mod pet_api; pub mod store_api; +pub mod testing_api; pub mod user_api; pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs new file mode 100644 index 00000000000..98f2fa15625 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs @@ -0,0 +1,112 @@ +/* + * 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; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed successes of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetSuccess { + Status200(std::path::PathBuf), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetSuccess { + Status200(crate::models::TypeTesting), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetError { + UnknownValue(serde_json::Value), +} + + +pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/action_container.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/action_container.rs new file mode 100644 index 00000000000..32d925eed3d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/action_container.rs @@ -0,0 +1,28 @@ +/* + * 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 + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActionContainer { + #[serde(rename = "action")] + pub action: Box, +} + +impl ActionContainer { + pub fn new(action: crate::models::Baz) -> ActionContainer { + ActionContainer { + action: Box::new(action), + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/baz.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/baz.rs new file mode 100644 index 00000000000..8a07bf66198 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/baz.rs @@ -0,0 +1,39 @@ +/* + * 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 + */ + + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Baz { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + +} + +impl ToString for Baz { + fn to_string(&self) -> String { + match self { + Self::A => String::from("A"), + Self::B => String::from("B"), + } + } +} + +impl Default for Baz { + fn default() -> Baz { + Self::A + } +} + + + + 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 index 1baf2f7528e..fb875c47a06 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs @@ -1,12 +1,20 @@ +pub mod action_container; +pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod baz; +pub use self::baz::Baz; 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 property_test; +pub use self::property_test::PropertyTest; pub mod tag; pub use self::tag::Tag; +pub mod type_testing; +pub use self::type_testing::TypeTesting; pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/property_test.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/property_test.rs new file mode 100644 index 00000000000..1c3c4f3f3fc --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/property_test.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +/// PropertyTest : A model to test various formats, e.g. UUID + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct PropertyTest { + #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] + pub uuid: Option, +} + +impl PropertyTest { + /// A model to test various formats, e.g. UUID + pub fn new() -> PropertyTest { + PropertyTest { + uuid: None, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs new file mode 100644 index 00000000000..dda67915dfe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs @@ -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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// TypeTesting : Test handling of different field data types + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, +} + +impl TypeTesting { + /// Test handling of different field data types + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + } + } +} + + 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 index bf4cb42e867..8d9d2576f92 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/tests/pet_tests.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/tests/pet_tests.rs @@ -17,7 +17,7 @@ fn test_pet() { new_pet.id = Option::Some(8787); let new_pet_params = petstore_reqwest_async::apis::pet_api::AddPetParams { - body: new_pet, + pet: new_pet, }; // add pet @@ -28,7 +28,7 @@ fn test_pet() { }; // get pet - let pet_result = petstore_reqwest_async::apis::pet_api::get_pet_by_id(&config, get_pet_params); + let _pet_result = petstore_reqwest_async::apis::pet_api::get_pet_by_id(&config, get_pet_params); // TODO Testing async functions requires some additionnal testing crates. } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES index 611ac7b6dd7..b2e3ba3cf43 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES @@ -2,26 +2,38 @@ .travis.yml Cargo.toml README.md +docs/ActionContainer.md docs/ApiResponse.md +docs/Baz.md docs/Category.md +docs/FakeApi.md docs/Order.md docs/Pet.md docs/PetApi.md +docs/PropertyTest.md docs/StoreApi.md docs/Tag.md +docs/TestingApi.md +docs/TypeTesting.md docs/User.md docs/UserApi.md git_push.sh src/apis/configuration.rs +src/apis/fake_api.rs src/apis/mod.rs src/apis/pet_api.rs src/apis/store_api.rs +src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/action_container.rs src/models/api_response.rs +src/models/baz.rs src/models/category.rs src/models/mod.rs src/models/order.rs src/models/pet.rs +src/models/property_test.rs src/models/tag.rs +src/models/type_testing.rs src/models/user.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md index c3f36db3538..a25174eb87e 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md @@ -25,6 +25,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters *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 @@ -37,6 +38,8 @@ Class | Method | HTTP request | Description *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 +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *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 @@ -49,11 +52,15 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) + - [PropertyTest](docs/PropertyTest.md) - [Tag](docs/Tag.md) + - [TypeTesting](docs/TypeTesting.md) - [User](docs/User.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ActionContainer.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ActionContainer.md new file mode 100644 index 00000000000..8490ec5d821 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ActionContainer.md @@ -0,0 +1,11 @@ +# ActionContainer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**action** | [**crate::models::Baz**](Baz.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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Baz.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Baz.md new file mode 100644 index 00000000000..68c84b1b1b0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Baz.md @@ -0,0 +1,10 @@ +# Baz + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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-awsv4signature/docs/FakeApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/FakeApi.md new file mode 100644 index 00000000000..55bf612aa21 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/FakeApi.md @@ -0,0 +1,41 @@ +# \FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters + + + +## test_nullable_required_param + +> test_nullable_required_param(username, dummy_required_nullable_param, uppercase) +To test nullable required parameters + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | +**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] | +**uppercase** | Option<**String**> | To test parameter names in upper case | | + +### 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-awsv4signature/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md new file mode 100644 index 00000000000..3f36c163de0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md @@ -0,0 +1,11 @@ +# PropertyTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [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-awsv4signature/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md new file mode 100644 index 00000000000..ca0c06e06a0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md @@ -0,0 +1,60 @@ +# \TestingApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md new file mode 100644 index 00000000000..6beca6dbac1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md @@ -0,0 +1,17 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | [**uuid::Uuid**](uuid::Uuid.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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs new file mode 100644 index 00000000000..13d9b7f851a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs @@ -0,0 +1,62 @@ +/* + * 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; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// +pub fn test_nullable_required_param(configuration: &configuration::Configuration, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + match dummy_required_nullable_param { + Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, + None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + } + if let Some(local_var_param_value) = uppercase { + local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/mod.rs index caa4d7eb628..32344f36b0c 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/mod.rs @@ -65,8 +65,10 @@ pub fn urlencode>(s: T) -> String { ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() } +pub mod fake_api; pub mod pet_api; pub mod store_api; +pub mod testing_api; pub mod user_api; pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs new file mode 100644 index 00000000000..fb84a57345e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_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 + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetError { + UnknownValue(serde_json::Value), +} + + +pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/action_container.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/action_container.rs new file mode 100644 index 00000000000..32d925eed3d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/action_container.rs @@ -0,0 +1,28 @@ +/* + * 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 + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActionContainer { + #[serde(rename = "action")] + pub action: Box, +} + +impl ActionContainer { + pub fn new(action: crate::models::Baz) -> ActionContainer { + ActionContainer { + action: Box::new(action), + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/baz.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/baz.rs new file mode 100644 index 00000000000..8a07bf66198 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/baz.rs @@ -0,0 +1,39 @@ +/* + * 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 + */ + + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Baz { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + +} + +impl ToString for Baz { + fn to_string(&self) -> String { + match self { + Self::A => String::from("A"), + Self::B => String::from("B"), + } + } +} + +impl Default for Baz { + fn default() -> Baz { + Self::A + } +} + + + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs index 1baf2f7528e..fb875c47a06 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs @@ -1,12 +1,20 @@ +pub mod action_container; +pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod baz; +pub use self::baz::Baz; 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 property_test; +pub use self::property_test::PropertyTest; pub mod tag; pub use self::tag::Tag; +pub mod type_testing; +pub use self::type_testing::TypeTesting; pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/property_test.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/property_test.rs new file mode 100644 index 00000000000..1c3c4f3f3fc --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/property_test.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +/// PropertyTest : A model to test various formats, e.g. UUID + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct PropertyTest { + #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] + pub uuid: Option, +} + +impl PropertyTest { + /// A model to test various formats, e.g. UUID + pub fn new() -> PropertyTest { + PropertyTest { + uuid: None, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs new file mode 100644 index 00000000000..dda67915dfe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs @@ -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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// TypeTesting : Test handling of different field data types + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, +} + +impl TypeTesting { + /// Test handling of different field data types + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES index dc1444953f7..b2e3ba3cf43 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES @@ -13,6 +13,8 @@ docs/PetApi.md docs/PropertyTest.md docs/StoreApi.md docs/Tag.md +docs/TestingApi.md +docs/TypeTesting.md docs/User.md docs/UserApi.md git_push.sh @@ -21,6 +23,7 @@ src/apis/fake_api.rs src/apis/mod.rs src/apis/pet_api.rs src/apis/store_api.rs +src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs src/models/action_container.rs @@ -32,4 +35,5 @@ src/models/order.rs src/models/pet.rs src/models/property_test.rs src/models/tag.rs +src/models/type_testing.rs src/models/user.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md index cd952b20964..a7841e9b400 100644 --- a/samples/client/petstore/rust/reqwest/petstore/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -38,6 +38,8 @@ Class | Method | HTTP request | Description *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 +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *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 @@ -58,6 +60,7 @@ Class | Method | HTTP request | Description - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Tag](docs/Tag.md) + - [TypeTesting](docs/TypeTesting.md) - [User](docs/User.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/DefaultApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/DefaultApi.md new file mode 100644 index 00000000000..86b9c86e7c9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/DefaultApi.md @@ -0,0 +1,60 @@ +# \DefaultApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](DefaultApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](DefaultApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md new file mode 100644 index 00000000000..ca0c06e06a0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md @@ -0,0 +1,60 @@ +# \TestingApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[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) + + +## tests_type_testing_get + +> crate::models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**crate::models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md new file mode 100644 index 00000000000..6beca6dbac1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md @@ -0,0 +1,17 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | [**uuid::Uuid**](uuid::Uuid.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) + + 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 353447f6257..34085cdedff 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs @@ -64,6 +64,7 @@ pub fn urlencode>(s: T) -> String { pub mod fake_api; pub mod pet_api; pub mod store_api; +pub mod testing_api; pub mod user_api; pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs new file mode 100644 index 00000000000..fb84a57345e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_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 + */ + + +use reqwest; + +use crate::apis::ResponseContent; +use super::{Error, configuration}; + + +/// struct for typed errors of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetError { + UnknownValue(serde_json::Value), +} + + +pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs index 10b2293873f..fb875c47a06 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -14,5 +14,7 @@ pub mod property_test; pub use self::property_test::PropertyTest; pub mod tag; pub use self::tag::Tag; +pub mod type_testing; +pub use self::type_testing::TypeTesting; pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs new file mode 100644 index 00000000000..dda67915dfe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs @@ -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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// TypeTesting : Test handling of different field data types + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, +} + +impl TypeTesting { + /// Test handling of different field data types + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + } + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs new file mode 100644 index 00000000000..e89187b170c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs @@ -0,0 +1,19 @@ +extern crate petstore_reqwest; + +use petstore_reqwest::models::TypeTesting; + +#[test] +fn test_types() { + let tt = TypeTesting::default(); + assert_eq!(type_of(tt.int32), "i32"); + assert_eq!(type_of(tt.int64), "i64"); + assert_eq!(type_of(tt.float), "f32"); + assert_eq!(type_of(tt.double), "f64"); + assert_eq!(type_of(tt.string), "alloc::string::String"); + assert_eq!(type_of(tt.boolean), "bool"); + assert_eq!(type_of(tt.uuid), "uuid::Uuid"); +} + +fn type_of(_: T) -> &'static str { + std::any::type_name::() +} diff --git a/samples/client/petstore/rust/reqwest/rust-test/.gitignore b/samples/client/petstore/rust/reqwest/rust-test/.gitignore deleted file mode 100644 index 6aa106405a4..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -**/*.rs.bk -Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/rust-test/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/FILES deleted file mode 100644 index 419360c647b..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/FILES +++ /dev/null @@ -1,13 +0,0 @@ -.gitignore -.travis.yml -Cargo.toml -README.md -docs/DefaultApi.md -docs/TypeTesting.md -git_push.sh -src/apis/configuration.rs -src/apis/default_api.rs -src/apis/mod.rs -src/lib.rs -src/models/mod.rs -src/models/type_testing.rs diff --git a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/rust-test/.travis.yml b/samples/client/petstore/rust/reqwest/rust-test/.travis.yml deleted file mode 100644 index 22761ba7ee1..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: rust diff --git a/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml b/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml deleted file mode 100644 index 1c36153fd79..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "rust-test-reqwest" -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" -reqwest = "~0.9" - -[dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/rust-test/README.md b/samples/client/petstore/rust/reqwest/rust-test/README.md deleted file mode 100644 index 097d18b77d0..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Rust API client for rust-test-reqwest - -Special testing for the Rust client generator - -## 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.7 -- 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://localhost* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultApi* | [**dummy_get**](docs/DefaultApi.md#dummy_get) | **get** /dummy | A dummy endpoint to make the spec valid. - - -## Documentation For Models - - - [TypeTesting](docs/TypeTesting.md) - - -To get access to the crate's generated documentation, use: - -``` -cargo doc --open -``` - -## Author - - - diff --git a/samples/client/petstore/rust/reqwest/rust-test/docs/DefaultApi.md b/samples/client/petstore/rust/reqwest/rust-test/docs/DefaultApi.md deleted file mode 100644 index ea01d010f01..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/docs/DefaultApi.md +++ /dev/null @@ -1,34 +0,0 @@ -# \DefaultApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**dummy_get**](DefaultApi.md#dummy_get) | **get** /dummy | A dummy endpoint to make the spec valid. - - - -## dummy_get - -> dummy_get() -A dummy endpoint to make the spec valid. - -### 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) - diff --git a/samples/client/petstore/rust/reqwest/rust-test/git_push.sh b/samples/client/petstore/rust/reqwest/rust-test/git_push.sh deleted file mode 100644 index ced3be2b0c7..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/git_push.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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/rust-test/src/apis/client.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs deleted file mode 100644 index b10fef0b554..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::rc::Rc; - -use super::configuration::Configuration; - -pub struct APIClient { - default_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - default_api: Box::new(crate::apis::default_api::DefaultApiClient::new(rc.clone())), - } - } - - pub fn default_api(&self) -> &dyn crate::apis::default_api::DefaultApi{ - self.default_api.as_ref() - } - -} diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/configuration.rs deleted file mode 100644 index 6aa6915560f..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/configuration.rs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * 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://localhost".to_owned(), - user_agent: Some("OpenAPI-Generator/1.0.7/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/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs deleted file mode 100644 index 098078bea89..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * Generated by: https://openapi-generator.tech - */ - - -use reqwest; - -use crate::apis::ResponseContent; -use super::{Error, configuration}; - - -/// struct for typed errors of method `dummy_get` -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DummyGetError { - UnknownValue(serde_json::Value), -} - - -pub fn dummy_get(configuration: &configuration::Configuration, ) -> Result<(), Error> { - - let client = &configuration.client; - - let uri_str = format!("{}/dummy", 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()?; - let mut resp = client.execute(req)?; - - let status = resp.status(); - let content = resp.text()?; - - if status.is_success() { - Ok(()) - } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) - } -} - 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 deleted file mode 100644 index aeab00a7bc0..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use reqwest; -use serde_json; - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), -} - -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() -} - -pub mod default_api; - -pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs b/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs deleted file mode 100644 index c1dd666f795..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[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/rust-test/src/models/mod.rs b/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs deleted file mode 100644 index 97887b5798e..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod type_testing; -pub use self::type_testing::TypeTesting; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs deleted file mode 100644 index 530d1d1365d..00000000000 --- a/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Rust client test spec - * - * Special testing for the Rust client generator - * - * The version of the OpenAPI document: 1.0.7 - * - * Generated by: https://openapi-generator.tech - */ - -/// TypeTesting : Test handling of differing types (see \\#3463) - - - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct TypeTesting { - #[serde(rename = "integer", skip_serializing_if = "Option::is_none")] - pub integer: Option, - #[serde(rename = "long", skip_serializing_if = "Option::is_none")] - pub long: Option, - #[serde(rename = "number", skip_serializing_if = "Option::is_none")] - pub number: Option, - #[serde(rename = "float", skip_serializing_if = "Option::is_none")] - pub float: Option, - #[serde(rename = "double", skip_serializing_if = "Option::is_none")] - pub double: Option, - #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] - pub uuid: Option, -} - -impl TypeTesting { - /// Test handling of differing types (see \\#3463) - pub fn new() -> TypeTesting { - TypeTesting { - integer: None, - long: None, - number: None, - float: None, - double: None, - uuid: None, - } - } -} - -