From 983317b3694f052d274eeb19cbaa467279f63287 Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Thu, 1 Aug 2019 18:04:29 +0100 Subject: [PATCH 1/8] Amalgamate rust generator scripts --- bin/rust-petstore.sh | 15 +++++++++++++-- bin/rust-reqwest-petstore.sh | 32 -------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) delete mode 100755 bin/rust-reqwest-petstore.sh diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh index f80029512085..97b57472b73f 100755 --- a/bin/rust-petstore.sh +++ b/bin/rust-petstore.sh @@ -27,6 +27,17 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust --additional-properties packageName=petstore_client --library=hyper $@" -java ${JAVA_OPTS} -jar ${executable} ${ags} +for spec_path in modules/openapi-generator/src/test/resources/2_0/petstore.yaml ; do + spec=$(basename "$spec_path" | sed 's/.yaml//') + + for library in hyper reqwest; do + ags="generate --template-dir modules/openapi-generator/src/main/resources/rust + --input-spec $spec_path + --generator-name rust + --output samples/client/petstore/rust/$library/$spec + --additional-properties packageName=$spec + --library=$library $@" + java ${JAVA_OPTS} -jar ${executable} ${ags} + done +done diff --git a/bin/rust-reqwest-petstore.sh b/bin/rust-reqwest-petstore.sh deleted file mode 100755 index 7a5fc8d8cdd7..000000000000 --- a/bin/rust-reqwest-petstore.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -SCRIPT="$0" -echo "# START SCRIPT: $SCRIPT" - -while [ -h "$SCRIPT" ] ; do - ls=$(ls -ld "$SCRIPT") - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' > /dev/null; then - SCRIPT="$link" - else - SCRIPT=$(dirname "$SCRIPT")/"$link" - fi -done - -if [ ! -d "${APP_DIR}" ]; then - APP_DIR=$(dirname "$SCRIPT")/.. - APP_DIR=$(cd "${APP_DIR}"; pwd) -fi - -executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" - -if [ ! -f "$executable" ] -then - mvn -B clean package -fi - -# if you've executed sbt assembly previously it will use that instead. -export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust-reqwest --additional-properties packageName=petstore_client --library=reqwest $@" - -java ${JAVA_OPTS} -jar ${executable} ${ags} From d22bee26397199d2abaf0df93250f37cdfe2acb5 Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 16:32:51 +0100 Subject: [PATCH 2/8] Regenerate samples in new location --- .../.openapi-generator/VERSION.orig | 1 - samples/client/petstore/rust-reqwest/pom.xml | 46 ------------------- .../rust-reqwest/src/apis/client.rs.orig | 34 -------------- .../rust/.openapi-generator/VERSION.orig | 1 - .../hyper/petstore}/.gitignore | 0 .../hyper/petstore}/.openapi-generator-ignore | 0 .../petstore}/.openapi-generator/VERSION | 0 .../hyper/petstore}/.travis.yml | 0 .../rust/{ => hyper/petstore}/Cargo.toml | 2 +- .../rust/{ => hyper/petstore}/README.md | 2 +- .../hyper/petstore}/docs/ApiResponse.md | 0 .../hyper/petstore}/docs/Category.md | 0 .../hyper/petstore}/docs/Order.md | 0 .../hyper/petstore}/docs/Pet.md | 0 .../rust/{ => hyper/petstore}/docs/PetApi.md | 0 .../{ => hyper/petstore}/docs/StoreApi.md | 0 .../hyper/petstore}/docs/Tag.md | 0 .../hyper/petstore}/docs/User.md | 0 .../rust/{ => hyper/petstore}/docs/UserApi.md | 0 .../hyper/petstore}/git_push.sh | 0 .../{ => hyper/petstore}/src/apis/client.rs | 0 .../petstore}/src/apis/configuration.rs | 0 .../rust/{ => hyper/petstore}/src/apis/mod.rs | 0 .../{ => hyper/petstore}/src/apis/pet_api.rs | 0 .../{ => hyper/petstore}/src/apis/request.rs | 0 .../petstore}/src/apis/store_api.rs | 0 .../{ => hyper/petstore}/src/apis/user_api.rs | 0 .../rust/{ => hyper/petstore}/src/lib.rs | 0 .../petstore}/src/models/api_response.rs | 0 .../hyper/petstore}/src/models/category.rs | 0 .../hyper/petstore}/src/models/mod.rs | 0 .../hyper/petstore}/src/models/order.rs | 0 .../hyper/petstore}/src/models/pet.rs | 0 .../hyper/petstore}/src/models/tag.rs | 0 .../hyper/petstore}/src/models/user.rs | 0 .../petstore}/.openapi-generator-ignore | 0 .../petstore}/.openapi-generator/VERSION | 0 .../rust/{ => reqwest/petstore}/.travis.yml | 0 .../reqwest/petstore}/Cargo.toml | 2 +- .../reqwest/petstore}/README.md | 2 +- .../petstore}/docs/ApiResponse.md | 0 .../{ => reqwest/petstore}/docs/Category.md | 0 .../rust/{ => reqwest/petstore}/docs/Order.md | 0 .../rust/{ => reqwest/petstore}/docs/Pet.md | 0 .../reqwest/petstore}/docs/PetApi.md | 0 .../reqwest/petstore}/docs/StoreApi.md | 0 .../rust/{ => reqwest/petstore}/docs/Tag.md | 0 .../rust/{ => reqwest/petstore}/docs/User.md | 0 .../reqwest/petstore}/docs/UserApi.md | 0 .../rust/{ => reqwest/petstore}/git_push.sh | 0 .../reqwest/petstore}/src/apis/client.rs | 0 .../petstore}/src/apis/configuration.rs | 0 .../reqwest/petstore}/src/apis/mod.rs | 0 .../reqwest/petstore}/src/apis/pet_api.rs | 0 .../reqwest/petstore}/src/apis/store_api.rs | 0 .../reqwest/petstore}/src/apis/user_api.rs | 0 .../reqwest/petstore}/src/lib.rs | 0 .../petstore}/src/models/api_response.rs | 0 .../petstore}/src/models/category.rs | 0 .../{ => reqwest/petstore}/src/models/mod.rs | 0 .../petstore}/src/models/order.rs | 0 .../{ => reqwest/petstore}/src/models/pet.rs | 0 .../{ => reqwest/petstore}/src/models/tag.rs | 0 .../{ => reqwest/petstore}/src/models/user.rs | 0 .../petstore/rust/src/apis/client.rs.orig | 35 -------------- 65 files changed, 4 insertions(+), 121 deletions(-) delete mode 100644 samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig delete mode 100644 samples/client/petstore/rust-reqwest/pom.xml delete mode 100644 samples/client/petstore/rust-reqwest/src/apis/client.rs.orig delete mode 100644 samples/client/petstore/rust/.openapi-generator/VERSION.orig rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/.gitignore (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/.openapi-generator-ignore (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/.openapi-generator/VERSION (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/.travis.yml (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/Cargo.toml (91%) rename samples/client/petstore/rust/{ => hyper/petstore}/README.md (98%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/ApiResponse.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/Category.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/Order.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/Pet.md (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/docs/PetApi.md (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/docs/StoreApi.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/Tag.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/docs/User.md (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/docs/UserApi.md (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/git_push.sh (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/client.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/configuration.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/mod.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/pet_api.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/request.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/store_api.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/apis/user_api.rs (100%) rename samples/client/petstore/rust/{ => hyper/petstore}/src/lib.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/api_response.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/category.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/mod.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/order.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/pet.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/tag.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/hyper/petstore}/src/models/user.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/.openapi-generator-ignore (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/.openapi-generator/VERSION (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/.travis.yml (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/Cargo.toml (88%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/README.md (98%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/ApiResponse.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/Category.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/Order.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/Pet.md (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/docs/PetApi.md (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/docs/StoreApi.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/Tag.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/docs/User.md (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/docs/UserApi.md (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/git_push.sh (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/client.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/configuration.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/mod.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/pet_api.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/store_api.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/apis/user_api.rs (100%) rename samples/client/petstore/{rust-reqwest => rust/reqwest/petstore}/src/lib.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/api_response.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/category.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/mod.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/order.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/pet.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/tag.rs (100%) rename samples/client/petstore/rust/{ => reqwest/petstore}/src/models/user.rs (100%) delete mode 100644 samples/client/petstore/rust/src/apis/client.rs.orig diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig deleted file mode 100644 index 479c313e87b9..000000000000 --- a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig +++ /dev/null @@ -1 +0,0 @@ -4.0.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust-reqwest/pom.xml b/samples/client/petstore/rust-reqwest/pom.xml deleted file mode 100644 index 8ef695226a9f..000000000000 --- a/samples/client/petstore/rust-reqwest/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - 4.0.0 - org.openapitools - RustReqwestPetstoreClientTests - pom - 1.0-SNAPSHOT - Rust (reqwest) Petstore Client - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory} - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - bundle-test - integration-test - - exec - - - cargo - - check - - - - - - - - diff --git a/samples/client/petstore/rust-reqwest/src/apis/client.rs.orig b/samples/client/petstore/rust-reqwest/src/apis/client.rs.orig deleted file mode 100644 index f2319088324c..000000000000 --- a/samples/client/petstore/rust-reqwest/src/apis/client.rs.orig +++ /dev/null @@ -1,34 +0,0 @@ -use std::rc::Rc; - -use super::configuration::Configuration; - -pub struct APIClient { - pet_api: Box, - store_api: Box, - user_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())), - store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())), - user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())), - } - } - - pub fn pet_api(&self) -> &crate::apis::PetApi{ - self.pet_api.as_ref() - } - - pub fn store_api(&self) -> &crate::apis::StoreApi{ - self.store_api.as_ref() - } - - pub fn user_api(&self) -> &crate::apis::UserApi{ - self.user_api.as_ref() - } - -} diff --git a/samples/client/petstore/rust/.openapi-generator/VERSION.orig b/samples/client/petstore/rust/.openapi-generator/VERSION.orig deleted file mode 100644 index 479c313e87b9..000000000000 --- a/samples/client/petstore/rust/.openapi-generator/VERSION.orig +++ /dev/null @@ -1 +0,0 @@ -4.0.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust-reqwest/.gitignore b/samples/client/petstore/rust/hyper/petstore/.gitignore similarity index 100% rename from samples/client/petstore/rust-reqwest/.gitignore rename to samples/client/petstore/rust/hyper/petstore/.gitignore diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator-ignore b/samples/client/petstore/rust/hyper/petstore/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/rust-reqwest/.openapi-generator-ignore rename to samples/client/petstore/rust/hyper/petstore/.openapi-generator-ignore diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/rust-reqwest/.openapi-generator/VERSION rename to samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION diff --git a/samples/client/petstore/rust-reqwest/.travis.yml b/samples/client/petstore/rust/hyper/petstore/.travis.yml similarity index 100% rename from samples/client/petstore/rust-reqwest/.travis.yml rename to samples/client/petstore/rust/hyper/petstore/.travis.yml diff --git a/samples/client/petstore/rust/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml similarity index 91% rename from samples/client/petstore/rust/Cargo.toml rename to samples/client/petstore/rust/hyper/petstore/Cargo.toml index 2ccdd989058e..67fc43707a92 100644 --- a/samples/client/petstore/rust/Cargo.toml +++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "petstore_client" +name = "petstore-hyper" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] diff --git a/samples/client/petstore/rust/README.md b/samples/client/petstore/rust/hyper/petstore/README.md similarity index 98% rename from samples/client/petstore/rust/README.md rename to samples/client/petstore/rust/hyper/petstore/README.md index a1149b09036b..83a8b77584eb 100644 --- a/samples/client/petstore/rust/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -1,4 +1,4 @@ -# Rust API client for petstore_client +# Rust API client for petstore-hyper This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. diff --git a/samples/client/petstore/rust-reqwest/docs/ApiResponse.md b/samples/client/petstore/rust/hyper/petstore/docs/ApiResponse.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/ApiResponse.md rename to samples/client/petstore/rust/hyper/petstore/docs/ApiResponse.md diff --git a/samples/client/petstore/rust-reqwest/docs/Category.md b/samples/client/petstore/rust/hyper/petstore/docs/Category.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/Category.md rename to samples/client/petstore/rust/hyper/petstore/docs/Category.md diff --git a/samples/client/petstore/rust-reqwest/docs/Order.md b/samples/client/petstore/rust/hyper/petstore/docs/Order.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/Order.md rename to samples/client/petstore/rust/hyper/petstore/docs/Order.md diff --git a/samples/client/petstore/rust-reqwest/docs/Pet.md b/samples/client/petstore/rust/hyper/petstore/docs/Pet.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/Pet.md rename to samples/client/petstore/rust/hyper/petstore/docs/Pet.md diff --git a/samples/client/petstore/rust/docs/PetApi.md b/samples/client/petstore/rust/hyper/petstore/docs/PetApi.md similarity index 100% rename from samples/client/petstore/rust/docs/PetApi.md rename to samples/client/petstore/rust/hyper/petstore/docs/PetApi.md diff --git a/samples/client/petstore/rust/docs/StoreApi.md b/samples/client/petstore/rust/hyper/petstore/docs/StoreApi.md similarity index 100% rename from samples/client/petstore/rust/docs/StoreApi.md rename to samples/client/petstore/rust/hyper/petstore/docs/StoreApi.md diff --git a/samples/client/petstore/rust-reqwest/docs/Tag.md b/samples/client/petstore/rust/hyper/petstore/docs/Tag.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/Tag.md rename to samples/client/petstore/rust/hyper/petstore/docs/Tag.md diff --git a/samples/client/petstore/rust-reqwest/docs/User.md b/samples/client/petstore/rust/hyper/petstore/docs/User.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/User.md rename to samples/client/petstore/rust/hyper/petstore/docs/User.md diff --git a/samples/client/petstore/rust/docs/UserApi.md b/samples/client/petstore/rust/hyper/petstore/docs/UserApi.md similarity index 100% rename from samples/client/petstore/rust/docs/UserApi.md rename to samples/client/petstore/rust/hyper/petstore/docs/UserApi.md diff --git a/samples/client/petstore/rust-reqwest/git_push.sh b/samples/client/petstore/rust/hyper/petstore/git_push.sh similarity index 100% rename from samples/client/petstore/rust-reqwest/git_push.sh rename to samples/client/petstore/rust/hyper/petstore/git_push.sh diff --git a/samples/client/petstore/rust/src/apis/client.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/client.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/client.rs diff --git a/samples/client/petstore/rust/src/apis/configuration.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/configuration.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs diff --git a/samples/client/petstore/rust/src/apis/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/mod.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs diff --git a/samples/client/petstore/rust/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/pet_api.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs diff --git a/samples/client/petstore/rust/src/apis/request.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/request.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/request.rs diff --git a/samples/client/petstore/rust/src/apis/store_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/store_api.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs diff --git a/samples/client/petstore/rust/src/apis/user_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs similarity index 100% rename from samples/client/petstore/rust/src/apis/user_api.rs rename to samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs diff --git a/samples/client/petstore/rust/src/lib.rs b/samples/client/petstore/rust/hyper/petstore/src/lib.rs similarity index 100% rename from samples/client/petstore/rust/src/lib.rs rename to samples/client/petstore/rust/hyper/petstore/src/lib.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/api_response.rs b/samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/api_response.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/category.rs b/samples/client/petstore/rust/hyper/petstore/src/models/category.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/category.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/category.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/mod.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/mod.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/order.rs b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/order.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/order.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/pet.rs b/samples/client/petstore/rust/hyper/petstore/src/models/pet.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/pet.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/pet.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/tag.rs b/samples/client/petstore/rust/hyper/petstore/src/models/tag.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/tag.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/tag.rs diff --git a/samples/client/petstore/rust-reqwest/src/models/user.rs b/samples/client/petstore/rust/hyper/petstore/src/models/user.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/models/user.rs rename to samples/client/petstore/rust/hyper/petstore/src/models/user.rs diff --git a/samples/client/petstore/rust/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/rust/.openapi-generator-ignore rename to samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore diff --git a/samples/client/petstore/rust/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/rust/.openapi-generator/VERSION rename to samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION diff --git a/samples/client/petstore/rust/.travis.yml b/samples/client/petstore/rust/reqwest/petstore/.travis.yml similarity index 100% rename from samples/client/petstore/rust/.travis.yml rename to samples/client/petstore/rust/reqwest/petstore/.travis.yml diff --git a/samples/client/petstore/rust-reqwest/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml similarity index 88% rename from samples/client/petstore/rust-reqwest/Cargo.toml rename to samples/client/petstore/rust/reqwest/petstore/Cargo.toml index 6d66b8f7c7cf..7a2aed735ea5 100644 --- a/samples/client/petstore/rust-reqwest/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "petstore_client" +name = "petstore-reqwest" version = "1.0.0" authors = ["OpenAPI Generator team and contributors"] diff --git a/samples/client/petstore/rust-reqwest/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md similarity index 98% rename from samples/client/petstore/rust-reqwest/README.md rename to samples/client/petstore/rust/reqwest/petstore/README.md index d8591a2cb9f4..b83be74204c5 100644 --- a/samples/client/petstore/rust-reqwest/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -1,4 +1,4 @@ -# Rust API client for petstore_client +# Rust API client for petstore-reqwest This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. diff --git a/samples/client/petstore/rust/docs/ApiResponse.md b/samples/client/petstore/rust/reqwest/petstore/docs/ApiResponse.md similarity index 100% rename from samples/client/petstore/rust/docs/ApiResponse.md rename to samples/client/petstore/rust/reqwest/petstore/docs/ApiResponse.md diff --git a/samples/client/petstore/rust/docs/Category.md b/samples/client/petstore/rust/reqwest/petstore/docs/Category.md similarity index 100% rename from samples/client/petstore/rust/docs/Category.md rename to samples/client/petstore/rust/reqwest/petstore/docs/Category.md diff --git a/samples/client/petstore/rust/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md similarity index 100% rename from samples/client/petstore/rust/docs/Order.md rename to samples/client/petstore/rust/reqwest/petstore/docs/Order.md diff --git a/samples/client/petstore/rust/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore/docs/Pet.md similarity index 100% rename from samples/client/petstore/rust/docs/Pet.md rename to samples/client/petstore/rust/reqwest/petstore/docs/Pet.md diff --git a/samples/client/petstore/rust-reqwest/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/PetApi.md rename to samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md diff --git a/samples/client/petstore/rust-reqwest/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/StoreApi.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/StoreApi.md rename to samples/client/petstore/rust/reqwest/petstore/docs/StoreApi.md diff --git a/samples/client/petstore/rust/docs/Tag.md b/samples/client/petstore/rust/reqwest/petstore/docs/Tag.md similarity index 100% rename from samples/client/petstore/rust/docs/Tag.md rename to samples/client/petstore/rust/reqwest/petstore/docs/Tag.md diff --git a/samples/client/petstore/rust/docs/User.md b/samples/client/petstore/rust/reqwest/petstore/docs/User.md similarity index 100% rename from samples/client/petstore/rust/docs/User.md rename to samples/client/petstore/rust/reqwest/petstore/docs/User.md diff --git a/samples/client/petstore/rust-reqwest/docs/UserApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/UserApi.md similarity index 100% rename from samples/client/petstore/rust-reqwest/docs/UserApi.md rename to samples/client/petstore/rust/reqwest/petstore/docs/UserApi.md diff --git a/samples/client/petstore/rust/git_push.sh b/samples/client/petstore/rust/reqwest/petstore/git_push.sh similarity index 100% rename from samples/client/petstore/rust/git_push.sh rename to samples/client/petstore/rust/reqwest/petstore/git_push.sh diff --git a/samples/client/petstore/rust-reqwest/src/apis/client.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/client.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs diff --git a/samples/client/petstore/rust-reqwest/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/configuration.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs diff --git a/samples/client/petstore/rust-reqwest/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/mod.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs diff --git a/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/pet_api.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs diff --git a/samples/client/petstore/rust-reqwest/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/store_api.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs diff --git a/samples/client/petstore/rust-reqwest/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/apis/user_api.rs rename to samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs diff --git a/samples/client/petstore/rust-reqwest/src/lib.rs b/samples/client/petstore/rust/reqwest/petstore/src/lib.rs similarity index 100% rename from samples/client/petstore/rust-reqwest/src/lib.rs rename to samples/client/petstore/rust/reqwest/petstore/src/lib.rs diff --git a/samples/client/petstore/rust/src/models/api_response.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs similarity index 100% rename from samples/client/petstore/rust/src/models/api_response.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs diff --git a/samples/client/petstore/rust/src/models/category.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/category.rs similarity index 100% rename from samples/client/petstore/rust/src/models/category.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/category.rs diff --git a/samples/client/petstore/rust/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs similarity index 100% rename from samples/client/petstore/rust/src/models/mod.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs diff --git a/samples/client/petstore/rust/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs similarity index 100% rename from samples/client/petstore/rust/src/models/order.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/order.rs diff --git a/samples/client/petstore/rust/src/models/pet.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs similarity index 100% rename from samples/client/petstore/rust/src/models/pet.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs diff --git a/samples/client/petstore/rust/src/models/tag.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs similarity index 100% rename from samples/client/petstore/rust/src/models/tag.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs diff --git a/samples/client/petstore/rust/src/models/user.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/user.rs similarity index 100% rename from samples/client/petstore/rust/src/models/user.rs rename to samples/client/petstore/rust/reqwest/petstore/src/models/user.rs diff --git a/samples/client/petstore/rust/src/apis/client.rs.orig b/samples/client/petstore/rust/src/apis/client.rs.orig deleted file mode 100644 index 39175e119e0d..000000000000 --- a/samples/client/petstore/rust/src/apis/client.rs.orig +++ /dev/null @@ -1,35 +0,0 @@ -use std::rc::Rc; - -use hyper; -use super::configuration::Configuration; - -pub struct APIClient { - pet_api: Box, - store_api: Box, - user_api: Box, -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { - pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())), - store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())), - user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())), - } - } - - pub fn pet_api(&self) -> &crate::apis::PetApi{ - self.pet_api.as_ref() - } - - pub fn store_api(&self) -> &crate::apis::StoreApi{ - self.store_api.as_ref() - } - - pub fn user_api(&self) -> &crate::apis::UserApi{ - self.user_api.as_ref() - } - -} From 9ea9f0f37763b7f84a0ee1c9ff922466e6b5687a Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 16:33:42 +0100 Subject: [PATCH 3/8] Enable testing for new rust samples They are now in one cargo workspace, so a single `cargo check` will now check all rust samples --- bin/rust-petstore.sh | 2 +- samples/client/petstore/rust/.gitignore | 3 +-- samples/client/petstore/rust/Cargo.toml | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 samples/client/petstore/rust/Cargo.toml diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh index 97b57472b73f..6fdfb5e3bcc1 100755 --- a/bin/rust-petstore.sh +++ b/bin/rust-petstore.sh @@ -36,7 +36,7 @@ for spec_path in modules/openapi-generator/src/test/resources/2_0/petstore.yaml --input-spec $spec_path --generator-name rust --output samples/client/petstore/rust/$library/$spec - --additional-properties packageName=$spec + --additional-properties packageName=${spec}-${library} --library=$library $@" java ${JAVA_OPTS} -jar ${executable} ${ags} done diff --git a/samples/client/petstore/rust/.gitignore b/samples/client/petstore/rust/.gitignore index 6aa106405a4b..a9d37c560c6a 100644 --- a/samples/client/petstore/rust/.gitignore +++ b/samples/client/petstore/rust/.gitignore @@ -1,3 +1,2 @@ -/target/ -**/*.rs.bk +target Cargo.lock diff --git a/samples/client/petstore/rust/Cargo.toml b/samples/client/petstore/rust/Cargo.toml new file mode 100644 index 000000000000..46b06cf9bbe3 --- /dev/null +++ b/samples/client/petstore/rust/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["hyper/*", "reqwest/*"] From 1c71c17aaa3e4a1a105b403988446ae86ecbd674 Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 17:05:51 +0100 Subject: [PATCH 4/8] Add test for rust client types To catch the problem found in #3463 if it is ever encountered again --- bin/rust-petstore.sh | 5 ++- .../test/resources/3_0/rust/rust-test.yaml | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh index 6fdfb5e3bcc1..ff7c0c3e83bb 100755 --- a/bin/rust-petstore.sh +++ b/bin/rust-petstore.sh @@ -28,7 +28,10 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -for spec_path in modules/openapi-generator/src/test/resources/2_0/petstore.yaml ; do +for spec_path in \ + modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ + modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \ + ; do spec=$(basename "$spec_path" | sed 's/.yaml//') for library in hyper reqwest; do 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 new file mode 100644 index 000000000000..861e84ca8d4e --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml @@ -0,0 +1,31 @@ +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 From ede21806653892068baa1808d5bd5960ddd14ceb Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 17:06:52 +0100 Subject: [PATCH 5/8] Generate samples for rust types test --- .../petstore/rust/hyper/rust-test/.gitignore | 3 + .../hyper/rust-test/.openapi-generator-ignore | 23 ++ .../rust-test/.openapi-generator/VERSION | 1 + .../petstore/rust/hyper/rust-test/.travis.yml | 1 + .../petstore/rust/hyper/rust-test/Cargo.toml | 17 ++ .../petstore/rust/hyper/rust-test/README.md | 44 ++++ .../rust/hyper/rust-test/docs/DefaultApi.md | 34 +++ .../rust/hyper/rust-test/docs/TypeTesting.md | 16 ++ .../petstore/rust/hyper/rust-test/git_push.sh | 52 ++++ .../rust/hyper/rust-test/src/apis/client.rs | 23 ++ .../hyper/rust-test/src/apis/configuration.rs | 41 +++ .../hyper/rust-test/src/apis/default_api.rs | 45 ++++ .../rust/hyper/rust-test/src/apis/mod.rs | 58 +++++ .../rust/hyper/rust-test/src/apis/request.rs | 239 ++++++++++++++++++ .../petstore/rust/hyper/rust-test/src/lib.rs | 11 + .../rust/hyper/rust-test/src/models/mod.rs | 2 + .../rust-test/src/models/type_testing.rs | 44 ++++ .../petstore/rust/reqwest/petstore/.gitignore | 3 + .../rust/reqwest/rust-test/.gitignore | 3 + .../rust-test/.openapi-generator-ignore | 23 ++ .../rust-test/.openapi-generator/VERSION | 1 + .../rust/reqwest/rust-test/.travis.yml | 1 + .../rust/reqwest/rust-test/Cargo.toml | 13 + .../petstore/rust/reqwest/rust-test/README.md | 44 ++++ .../rust/reqwest/rust-test/docs/DefaultApi.md | 34 +++ .../reqwest/rust-test/docs/TypeTesting.md | 16 ++ .../rust/reqwest/rust-test/git_push.sh | 52 ++++ .../rust/reqwest/rust-test/src/apis/client.rs | 22 ++ .../rust-test/src/apis/configuration.rs | 50 ++++ .../reqwest/rust-test/src/apis/default_api.rs | 53 ++++ .../rust/reqwest/rust-test/src/apis/mod.rs | 37 +++ .../rust/reqwest/rust-test/src/lib.rs | 10 + .../rust/reqwest/rust-test/src/models/mod.rs | 2 + .../rust-test/src/models/type_testing.rs | 44 ++++ 34 files changed, 1062 insertions(+) create mode 100644 samples/client/petstore/rust/hyper/rust-test/.gitignore create mode 100644 samples/client/petstore/rust/hyper/rust-test/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/hyper/rust-test/.travis.yml create mode 100644 samples/client/petstore/rust/hyper/rust-test/Cargo.toml create mode 100644 samples/client/petstore/rust/hyper/rust-test/README.md create mode 100644 samples/client/petstore/rust/hyper/rust-test/docs/DefaultApi.md create mode 100644 samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md create mode 100644 samples/client/petstore/rust/hyper/rust-test/git_push.sh create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/lib.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs create mode 100644 samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore/.gitignore create mode 100644 samples/client/petstore/rust/reqwest/rust-test/.gitignore create mode 100644 samples/client/petstore/rust/reqwest/rust-test/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/reqwest/rust-test/.travis.yml create mode 100644 samples/client/petstore/rust/reqwest/rust-test/Cargo.toml create mode 100644 samples/client/petstore/rust/reqwest/rust-test/README.md create mode 100644 samples/client/petstore/rust/reqwest/rust-test/docs/DefaultApi.md create mode 100644 samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md create mode 100644 samples/client/petstore/rust/reqwest/rust-test/git_push.sh create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/lib.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs diff --git a/samples/client/petstore/rust/hyper/rust-test/.gitignore b/samples/client/petstore/rust/hyper/rust-test/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/.gitignore @@ -0,0 +1,3 @@ +/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 new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION new file mode 100644 index 000000000000..83a328a9227e --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.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 new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/hyper/rust-test/Cargo.toml b/samples/client/petstore/rust/hyper/rust-test/Cargo.toml new file mode 100644 index 000000000000..0e17417c3d2d --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "rust-test-hyper" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "1.5" +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 new file mode 100644 index 000000000000..1383eecfd30d --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/README.md @@ -0,0 +1,44 @@ +# 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 new file mode 100644 index 000000000000..caf46321830a --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/docs/DefaultApi.md @@ -0,0 +1,34 @@ +# \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/docs/TypeTesting.md b/samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md new file mode 100644 index 000000000000..e84136389e9b --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/docs/TypeTesting.md @@ -0,0 +1,16 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **i32** | | [optional] +**long** | **i64** | | [optional] +**number** | **f32** | | [optional] +**float** | **f32** | | [optional] +**double** | **f64** | | [optional] +**uuid** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper/rust-test/git_push.sh b/samples/client/petstore/rust/hyper/rust-test/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + 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 new file mode 100644 index 000000000000..6105ed87f9db --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs @@ -0,0 +1,23 @@ +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) -> &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 new file mode 100644 index 000000000000..79762a1437cb --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/configuration.rs @@ -0,0 +1,41 @@ +/* + * 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 new file mode 100644 index 000000000000..b1894d69ef23 --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs @@ -0,0 +1,45 @@ +/* + * 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; + +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: configuration, + } + } +} + +pub trait DefaultApi { + fn dummy_get(&self, ) -> Box>>; +} + + +implDefaultApi for DefaultApiClient { + fn dummy_get(&self, ) -> Box>> { + __internal_request::Request::new(hyper::Method::Get, "/dummy".to_string()) + .returns_nothing() + .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 new file mode 100644 index 000000000000..cb13d23efc24 --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/mod.rs @@ -0,0 +1,58 @@ +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 new file mode 100644 index 000000000000..2d5c7eb5a64d --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs @@ -0,0 +1,239 @@ +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 new file mode 100644 index 000000000000..a76d822525da --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/lib.rs @@ -0,0 +1,11 @@ +#[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 new file mode 100644 index 000000000000..8762207b5b3f --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000000..abd6582cc66f --- /dev/null +++ b/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs @@ -0,0 +1,44 @@ +/* + * 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(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/petstore/.gitignore b/samples/client/petstore/rust/reqwest/petstore/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/rust-test/.gitignore b/samples/client/petstore/rust/reqwest/rust-test/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/.gitignore @@ -0,0 +1,3 @@ +/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 new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION new file mode 100644 index 000000000000..83a328a9227e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.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 new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml b/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml new file mode 100644 index 000000000000..60c968a7cf2f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "rust-test-reqwest" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "1.5" +reqwest = "~0.9" + +[dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/rust-test/README.md b/samples/client/petstore/rust/reqwest/rust-test/README.md new file mode 100644 index 000000000000..097d18b77d0a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/README.md @@ -0,0 +1,44 @@ +# 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 new file mode 100644 index 000000000000..ea01d010f01f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/docs/DefaultApi.md @@ -0,0 +1,34 @@ +# \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/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md new file mode 100644 index 000000000000..e84136389e9b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/docs/TypeTesting.md @@ -0,0 +1,16 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **i32** | | [optional] +**long** | **i64** | | [optional] +**number** | **f32** | | [optional] +**float** | **f32** | | [optional] +**double** | **f64** | | [optional] +**uuid** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/rust-test/git_push.sh b/samples/client/petstore/rust/reqwest/rust-test/git_push.sh new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + 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 new file mode 100644 index 000000000000..2f76997d319f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs @@ -0,0 +1,22 @@ +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::DefaultApiClient::new(rc.clone())), + } + } + + pub fn default_api(&self) -> &crate::apis::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 new file mode 100644 index 000000000000..6aa6915560fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/configuration.rs @@ -0,0 +1,50 @@ +/* + * 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 new file mode 100644 index 000000000000..9404fefb7dd9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs @@ -0,0 +1,53 @@ +/* + * 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; + +use reqwest; + +use super::{Error, configuration}; + +pub struct DefaultApiClient { + configuration: Rc, +} + +impl DefaultApiClient { + pub fn new(configuration: Rc) -> DefaultApiClient { + DefaultApiClient { + configuration: configuration, + } + } +} + +pub trait DefaultApi { + fn dummy_get(&self, ) -> Result<(), Error>; +} + +impl DefaultApi for DefaultApiClient { + fn dummy_get(&self, ) -> Result<(), Error> { + let configuration: &configuration::Configuration = self.configuration.borrow(); + 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()); + } + + // send request + let req = req_builder.build()?; + + client.execute(req)?.error_for_status()?; + Ok(()) + } + +} diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs new file mode 100644 index 000000000000..3b70668f6fd9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs @@ -0,0 +1,37 @@ +use reqwest; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +mod default_api; +pub use self::default_api::{ DefaultApi, DefaultApiClient }; + +pub mod configuration; +pub mod client; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs b/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs new file mode 100644 index 000000000000..c1dd666f7957 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate serde_derive; + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs b/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs new file mode 100644 index 000000000000..8762207b5b3f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000000..abd6582cc66f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs @@ -0,0 +1,44 @@ +/* + * 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(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, + } + } +} + + From c3a85996b9d52694535b636616726f38c79bd8ff Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 17:08:31 +0100 Subject: [PATCH 6/8] Add test of rust's file handling --- bin/rust-petstore.sh | 3 +- .../rust/hyper/fileResponseTest/.gitignore | 3 + .../.openapi-generator-ignore | 23 ++ .../.openapi-generator/VERSION | 1 + .../rust/hyper/fileResponseTest/.travis.yml | 1 + .../rust/hyper/fileResponseTest/Cargo.toml | 17 ++ .../rust/hyper/fileResponseTest/README.md | 43 ++++ .../hyper/fileResponseTest/docs/DefaultApi.md | 34 +++ .../rust/hyper/fileResponseTest/git_push.sh | 52 ++++ .../hyper/fileResponseTest/src/apis/client.rs | 23 ++ .../src/apis/configuration.rs | 41 +++ .../fileResponseTest/src/apis/default_api.rs | 44 ++++ .../hyper/fileResponseTest/src/apis/mod.rs | 58 +++++ .../fileResponseTest/src/apis/request.rs | 239 ++++++++++++++++++ .../rust/hyper/fileResponseTest/src/lib.rs | 11 + .../hyper/fileResponseTest/src/models/mod.rs | 0 .../rust/reqwest/fileResponseTest/.gitignore | 3 + .../.openapi-generator-ignore | 23 ++ .../.openapi-generator/VERSION | 1 + .../rust/reqwest/fileResponseTest/.travis.yml | 1 + .../rust/reqwest/fileResponseTest/Cargo.toml | 13 + .../rust/reqwest/fileResponseTest/README.md | 43 ++++ .../fileResponseTest/docs/DefaultApi.md | 34 +++ .../rust/reqwest/fileResponseTest/git_push.sh | 52 ++++ .../fileResponseTest/src/apis/client.rs | 22 ++ .../src/apis/configuration.rs | 50 ++++ .../fileResponseTest/src/apis/default_api.rs | 52 ++++ .../reqwest/fileResponseTest/src/apis/mod.rs | 37 +++ .../rust/reqwest/fileResponseTest/src/lib.rs | 10 + .../fileResponseTest/src/models/mod.rs | 0 30 files changed, 933 insertions(+), 1 deletion(-) create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/.gitignore create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/.travis.yml create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/README.md create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/lib.rs create mode 100644 samples/client/petstore/rust/hyper/fileResponseTest/src/models/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/.travis.yml create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/README.md create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/docs/DefaultApi.md create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs create mode 100644 samples/client/petstore/rust/reqwest/fileResponseTest/src/models/mod.rs diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh index ff7c0c3e83bb..7deb7aa91860 100755 --- a/bin/rust-petstore.sh +++ b/bin/rust-petstore.sh @@ -31,8 +31,9 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" for spec_path in \ modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \ + modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json\ ; do - spec=$(basename "$spec_path" | sed 's/.yaml//') + spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' ) for library in hyper reqwest; do ags="generate --template-dir modules/openapi-generator/src/main/resources/rust diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore b/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.gitignore @@ -0,0 +1,3 @@ +/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 new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION new file mode 100644 index 000000000000..83a328a9227e --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.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 new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml new file mode 100644 index 000000000000..f78404453cf9 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "fileResponseTest-hyper" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "1.5" +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 new file mode 100644 index 000000000000..1cb8e0b83f17 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/README.md @@ -0,0 +1,43 @@ +# 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 new file mode 100644 index 000000000000..6e8157cf0e54 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md @@ -0,0 +1,34 @@ +# \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 new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs new file mode 100644 index 000000000000..6105ed87f9db --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs @@ -0,0 +1,23 @@ +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) -> &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 new file mode 100644 index 000000000000..6a3d69dddd61 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs @@ -0,0 +1,41 @@ +/* + * 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 new file mode 100644 index 000000000000..d5440cb4df04 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs @@ -0,0 +1,44 @@ +/* + * 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; + +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: configuration, + } + } +} + +pub trait DefaultApi { + fn fileresponsetest(&self, ) -> Box>>; +} + + +implDefaultApi for DefaultApiClient { + fn fileresponsetest(&self, ) -> Box>> { + __internal_request::Request::new(hyper::Method::Get, "/tests/fileResponse".to_string()) + .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 new file mode 100644 index 000000000000..cb13d23efc24 --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/mod.rs @@ -0,0 +1,58 @@ +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 new file mode 100644 index 000000000000..2d5c7eb5a64d --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs @@ -0,0 +1,239 @@ +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 new file mode 100644 index 000000000000..a76d822525da --- /dev/null +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/lib.rs @@ -0,0 +1,11 @@ +#[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 new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore b/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.gitignore @@ -0,0 +1,3 @@ +/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 new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION new file mode 100644 index 000000000000..83a328a9227e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.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 new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml b/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml new file mode 100644 index 000000000000..97c0f07897b9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "fileResponseTest-reqwest" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "1.5" +reqwest = "~0.9" + +[dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/README.md b/samples/client/petstore/rust/reqwest/fileResponseTest/README.md new file mode 100644 index 000000000000..8bf849adb68d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/README.md @@ -0,0 +1,43 @@ +# 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 new file mode 100644 index 000000000000..0b0273e4346b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/docs/DefaultApi.md @@ -0,0 +1,34 @@ +# \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 new file mode 100644 index 000000000000..8442b80bb445 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs new file mode 100644 index 000000000000..2f76997d319f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs @@ -0,0 +1,22 @@ +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::DefaultApiClient::new(rc.clone())), + } + } + + pub fn default_api(&self) -> &crate::apis::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 new file mode 100644 index 000000000000..107d558aa4f9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/configuration.rs @@ -0,0 +1,50 @@ +/* + * 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 new file mode 100644 index 000000000000..487e5d3af60e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs @@ -0,0 +1,52 @@ +/* + * 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; + +use reqwest; + +use super::{Error, configuration}; + +pub struct DefaultApiClient { + configuration: Rc, +} + +impl DefaultApiClient { + pub fn new(configuration: Rc) -> DefaultApiClient { + DefaultApiClient { + configuration: configuration, + } + } +} + +pub trait DefaultApi { + fn fileresponsetest(&self, ) -> Result; +} + +impl DefaultApi for DefaultApiClient { + fn fileresponsetest(&self, ) -> Result { + let configuration: &configuration::Configuration = self.configuration.borrow(); + 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()); + } + + // send request + let req = req_builder.build()?; + + Ok(client.execute(req)?.error_for_status()?.json()?) + } + +} diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs new file mode 100644 index 000000000000..3b70668f6fd9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs @@ -0,0 +1,37 @@ +use reqwest; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +mod default_api; +pub use self::default_api::{ DefaultApi, DefaultApiClient }; + +pub mod configuration; +pub mod client; diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs new file mode 100644 index 000000000000..c1dd666f7957 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +extern crate serde_derive; + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/models/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/models/mod.rs new file mode 100644 index 000000000000..e69de29bb2d1 From 1262bda1f0a9f0f5f63435632f819f51d3894c19 Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 2 Aug 2019 17:10:15 +0100 Subject: [PATCH 7/8] Remove old samples from pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18f9b1dd04f2..08ce843360aa 100644 --- a/pom.xml +++ b/pom.xml @@ -1039,7 +1039,6 @@ samples/client/petstore/elm-0.18 samples/client/petstore/rust - samples/client/petstore/rust-reqwest samples/client/petstore/php/OpenAPIClient-php samples/openapi3/client/petstore/php/OpenAPIClient-php From db79b250090b833b0cac55c451aef0c66d91bf4a Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Fri, 16 Aug 2019 17:47:07 +0100 Subject: [PATCH 8/8] Fix typo and detect failures properly. Previously, we might not have noticed if an early generation failed, but the final one succeeded. --- bin/rust-petstore.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh index 7deb7aa91860..d5aceb82af66 100755 --- a/bin/rust-petstore.sh +++ b/bin/rust-petstore.sh @@ -36,12 +36,12 @@ for spec_path in \ spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' ) for library in hyper reqwest; do - ags="generate --template-dir modules/openapi-generator/src/main/resources/rust - --input-spec $spec_path - --generator-name rust - --output samples/client/petstore/rust/$library/$spec - --additional-properties packageName=${spec}-${library} - --library=$library $@" - java ${JAVA_OPTS} -jar ${executable} ${ags} + args="generate --template-dir modules/openapi-generator/src/main/resources/rust + --input-spec $spec_path + --generator-name rust + --output samples/client/petstore/rust/$library/$spec + --additional-properties packageName=${spec}-${library} + --library=$library $@" + java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1 done done