diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index ad2c260cac1..cdac07896c1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -156,6 +156,45 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { return postProcessModelsEnum(objs); } + @SuppressWarnings({"static-method", "unchecked"}) + public Map postProcessAllModels(Map objs) { + // Index all CodegenModels by model name. + Map allModels = new HashMap<>(); + for (Map.Entry entry : objs.entrySet()) { + String modelName = toModelName(entry.getKey()); + Map inner = (Map) entry.getValue(); + List> models = (List>) inner.get("models"); + for (Map mo : models) { + CodegenModel cm = (CodegenModel) mo.get("model"); + allModels.put(modelName, cm); + } + } + for (Map.Entry entry : objs.entrySet()) { + Map inner = (Map) entry.getValue(); + List> models = (List>) inner.get("models"); + for (Map mo : models) { + CodegenModel cm = (CodegenModel) mo.get("model"); + if (cm.discriminator != null) { + List discriminatorVars = new ArrayList<>(); + for(CodegenDiscriminator.MappedModel mappedModel: cm.discriminator.getMappedModels()) { + CodegenModel model = allModels.get(mappedModel.getModelName()); + Map mas = new HashMap<>(); + mas.put("modelName", camelize(mappedModel.getModelName())); + mas.put("mappingName", mappedModel.getMappingName()); + List vars = model.getVars(); + vars.removeIf(p -> p.name.equals(cm.discriminator.getPropertyName())); + mas.put("vars", vars); + discriminatorVars.add(mas); + } + // TODO: figure out how to properly have the original property type that didn't go through toVarName + cm.vendorExtensions.put("tagName", cm.discriminator.getPropertyName().replace("_", "")); + cm.vendorExtensions.put("mappedModels", discriminatorVars); + } + } + } + return objs; + } + @Override public void processOpts() { super.processOpts(); diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache index 872148bdddd..d6974271fa8 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache @@ -16,7 +16,7 @@ pub struct {{{classname}}}Client { impl {{{classname}}}Client { pub fn new(configuration: Rc>) -> {{{classname}}}Client { {{{classname}}}Client { - configuration: configuration, + configuration, } } } @@ -24,7 +24,7 @@ impl {{{classname}}}Client { pub trait {{{classname}}} { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>>; + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>>; {{/operation}} {{/operations}} } @@ -33,7 +33,7 @@ pub trait {{{classname}}} { impl{{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>> { + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>> { __internal_request::Request::new(hyper::Method::{{{httpMethod}}}, "{{{path}}}".to_string()) {{#hasAuthMethods}} {{#authMethods}} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache index 2aa7338b4b7..5b3bcf85c75 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache @@ -9,7 +9,7 @@ pub struct APIClient { {{#operations}} {{#operation}} {{#-last}} - {{{classFilename}}}: Box, + {{{classFilename}}}: Box, {{/-last}} {{/operation}} {{/operations}} @@ -41,7 +41,7 @@ impl APIClient { {{#operations}} {{#operation}} {{#-last}} - pub fn {{{classFilename}}}(&self) -> &crate::apis::{{{classname}}}{ + pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ self.{{{classFilename}}}.as_ref() } diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index 1572a1a8718..054cd2deb25 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -8,7 +8,7 @@ {{!-- for enum schemas --}} {{#isEnum}} /// {{{description}}} -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum {{classname}} { {{#allowableValues}} {{#enumVars}} @@ -18,8 +18,32 @@ pub enum {{classname}} { } {{/isEnum}} +{{!-- for schemas that have a discriminator --}} +{{#discriminator}} +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "{{{vendorExtensions.tagName}}}")] +pub enum {{classname}} { +{{#vendorExtensions}} + {{#mappedModels}} + #[serde(rename="{{mappingName}}")] + {{modelName}} { + {{#vars}} + {{#description}} + /// {{{description}}} + {{/description}} + #[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})] + {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, + {{/vars}} + }, + {{/mappedModels}} +{{/vendorExtensions}} +} + +{{/discriminator}} + {{!-- for non-enum schemas --}} {{^isEnum}} +{{^discriminator}} #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct {{{classname}}} { {{#vars}} @@ -38,11 +62,12 @@ impl {{{classname}}} { pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { {{{classname}}} { {{#vars}} - {{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}, + {{{name}}}{{^required}}{{#isListContainer}}: None{{/isListContainer}}{{#isMapContainer}}: None{{/isMapContainer}}{{^isContainer}}: None{{/isContainer}}{{/required}}, {{/vars}} } } } +{{/discriminator}} {{/isEnum}} {{!-- for properties that are of enum type --}} diff --git a/modules/openapi-generator/src/main/resources/rust/model_mod.mustache b/modules/openapi-generator/src/main/resources/rust/model_mod.mustache index daddc889b81..06bf92f019a 100644 --- a/modules/openapi-generator/src/main/resources/rust/model_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model_mod.mustache @@ -1,6 +1,6 @@ {{#models}} {{#model}} -mod {{{classFilename}}}; +pub mod {{{classFilename}}}; pub use self::{{{classFilename}}}::{{{classname}}}; {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/rust/request.rs b/modules/openapi-generator/src/main/resources/rust/request.rs index 2d5c7eb5a64..f97b5277196 100644 --- a/modules/openapi-generator/src/main/resources/rust/request.rs +++ b/modules/openapi-generator/src/main/resources/rust/request.rs @@ -98,7 +98,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Box> + 'a> + ) -> Box> + 'a> where C: hyper::client::Connect, U: Sized + 'a, diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 35d25dfde7b..ee8359f6bc2 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -13,7 +13,7 @@ pub struct {{{classname}}}Client { impl {{{classname}}}Client { pub fn new(configuration: Rc) -> {{{classname}}}Client { {{{classname}}}Client { - configuration: configuration, + configuration, } } } diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache index 9eab1328656..60be0f295fb 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache @@ -8,7 +8,7 @@ pub struct APIClient { {{#operations}} {{#operation}} {{#-last}} - {{{classFilename}}}: Box, + {{{classFilename}}}: Box, {{/-last}} {{/operation}} {{/operations}} @@ -40,7 +40,7 @@ impl APIClient { {{#operations}} {{#operation}} {{#-last}} - pub fn {{{classFilename}}}(&self) -> &crate::apis::{{{classname}}}{ + pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ self.{{{classFilename}}}.as_ref() } diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION index 83a328a9227..0e97bd19efb 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.0-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh b/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh +++ b/samples/client/petstore/rust/hyper/fileResponseTest/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs index 6105ed87f9d..4976ba81c65 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs @@ -4,7 +4,7 @@ use hyper; use super::configuration::Configuration; pub struct APIClient { - default_api: Box, + default_api: Box, } impl APIClient { @@ -16,7 +16,7 @@ impl APIClient { } } - pub fn default_api(&self) -> &crate::apis::DefaultApi{ + pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ self.default_api.as_ref() } diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs index d5440cb4df0..7f807e2f81b 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/default_api.rs @@ -25,18 +25,18 @@ pub struct DefaultApiClient { impl DefaultApiClient { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { - configuration: configuration, + configuration, } } } pub trait DefaultApi { - fn fileresponsetest(&self, ) -> Box>>; + fn fileresponsetest(&self, ) -> Box>>; } implDefaultApi for DefaultApiClient { - fn fileresponsetest(&self, ) -> Box>> { + 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/request.rs b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs index 2d5c7eb5a64..f97b5277196 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/fileResponseTest/src/apis/request.rs @@ -98,7 +98,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Box> + 'a> + ) -> Box> + 'a> where C: hyper::client::Connect, U: Sized + 'a, diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION index 83a328a9227..0e97bd19efb 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.0-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/petstore/git_push.sh b/samples/client/petstore/rust/hyper/petstore/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/hyper/petstore/git_push.sh +++ b/samples/client/petstore/rust/hyper/petstore/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs index 39175e119e0..34953d4a063 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs @@ -4,9 +4,9 @@ use hyper; use super::configuration::Configuration; pub struct APIClient { - pet_api: Box, - store_api: Box, - user_api: Box, + pet_api: Box, + store_api: Box, + user_api: Box, } impl APIClient { @@ -20,15 +20,15 @@ impl APIClient { } } - pub fn pet_api(&self) -> &crate::apis::PetApi{ + pub fn pet_api(&self) -> &dyn crate::apis::PetApi{ self.pet_api.as_ref() } - pub fn store_api(&self) -> &crate::apis::StoreApi{ + pub fn store_api(&self) -> &dyn crate::apis::StoreApi{ self.store_api.as_ref() } - pub fn user_api(&self) -> &crate::apis::UserApi{ + pub fn user_api(&self) -> &dyn crate::apis::UserApi{ self.user_api.as_ref() } diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs index e3fe372fc9b..9adfde81aa7 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs @@ -25,25 +25,25 @@ pub struct PetApiClient { impl PetApiClient { pub fn new(configuration: Rc>) -> PetApiClient { PetApiClient { - configuration: configuration, + configuration, } } } pub trait PetApi { - fn add_pet(&self, body: crate::models::Pet) -> Box>>; - fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box>>; - fn find_pets_by_status(&self, status: Vec) -> Box, Error = Error>>; - fn find_pets_by_tags(&self, tags: Vec) -> Box, Error = Error>>; - fn get_pet_by_id(&self, pet_id: i64) -> Box>>; - fn update_pet(&self, body: crate::models::Pet) -> Box>>; - fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box>>; - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box>>; + fn add_pet(&self, body: crate::models::Pet) -> Box>>; + fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box>>; + fn find_pets_by_status(&self, status: Vec) -> Box, Error = Error>>; + fn find_pets_by_tags(&self, tags: Vec) -> Box, Error = Error>>; + fn get_pet_by_id(&self, pet_id: i64) -> Box>>; + fn update_pet(&self, body: crate::models::Pet) -> Box>>; + fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box>>; + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box>>; } implPetApi for PetApiClient { - fn add_pet(&self, body: crate::models::Pet) -> Box>> { + fn add_pet(&self, body: crate::models::Pet) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_body_param(body) @@ -51,7 +51,7 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box>> { + fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Delete, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_path_param("petId".to_string(), pet_id.to_string()) @@ -60,21 +60,21 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn find_pets_by_status(&self, status: Vec) -> Box, Error = Error>> { + fn find_pets_by_status(&self, status: Vec) -> Box, Error = Error>> { __internal_request::Request::new(hyper::Method::Get, "/pet/findByStatus".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_query_param("status".to_string(), status.join(",").to_string()) .execute(self.configuration.borrow()) } - fn find_pets_by_tags(&self, tags: Vec) -> Box, Error = Error>> { + fn find_pets_by_tags(&self, tags: Vec) -> Box, Error = Error>> { __internal_request::Request::new(hyper::Method::Get, "/pet/findByTags".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_query_param("tags".to_string(), tags.join(",").to_string()) .execute(self.configuration.borrow()) } - fn get_pet_by_id(&self, pet_id: i64) -> Box>> { + fn get_pet_by_id(&self, pet_id: i64) -> Box>> { __internal_request::Request::new(hyper::Method::Get, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -85,7 +85,7 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn update_pet(&self, body: crate::models::Pet) -> Box>> { + fn update_pet(&self, body: crate::models::Pet) -> Box>> { __internal_request::Request::new(hyper::Method::Put, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_body_param(body) @@ -93,7 +93,7 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box>> { + fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_path_param("petId".to_string(), pet_id.to_string()) @@ -103,7 +103,7 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box>> { + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/pet/{petId}/uploadImage".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_path_param("petId".to_string(), pet_id.to_string()) diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs index 2d5c7eb5a64..f97b5277196 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs @@ -98,7 +98,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Box> + 'a> + ) -> Box> + 'a> where C: hyper::client::Connect, U: Sized + 'a, diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs index 2c827cce045..5b4c3dc233c 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs @@ -25,28 +25,28 @@ pub struct StoreApiClient { impl StoreApiClient { pub fn new(configuration: Rc>) -> StoreApiClient { StoreApiClient { - configuration: configuration, + configuration, } } } pub trait StoreApi { - fn delete_order(&self, order_id: &str) -> Box>>; - fn get_inventory(&self, ) -> Box, Error = Error>>; - fn get_order_by_id(&self, order_id: i64) -> Box>>; - fn place_order(&self, body: crate::models::Order) -> Box>>; + fn delete_order(&self, order_id: &str) -> Box>>; + fn get_inventory(&self, ) -> Box, Error = Error>>; + fn get_order_by_id(&self, order_id: i64) -> Box>>; + fn place_order(&self, body: crate::models::Order) -> Box>>; } implStoreApi for StoreApiClient { - fn delete_order(&self, order_id: &str) -> Box>> { + fn delete_order(&self, order_id: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Delete, "/store/order/{orderId}".to_string()) .with_path_param("orderId".to_string(), order_id.to_string()) .returns_nothing() .execute(self.configuration.borrow()) } - fn get_inventory(&self, ) -> Box, Error = Error>> { + fn get_inventory(&self, ) -> Box, Error = Error>> { __internal_request::Request::new(hyper::Method::Get, "/store/inventory".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -56,13 +56,13 @@ implStoreApi for StoreApiClient { .execute(self.configuration.borrow()) } - fn get_order_by_id(&self, order_id: i64) -> Box>> { + fn get_order_by_id(&self, order_id: i64) -> Box>> { __internal_request::Request::new(hyper::Method::Get, "/store/order/{orderId}".to_string()) .with_path_param("orderId".to_string(), order_id.to_string()) .execute(self.configuration.borrow()) } - fn place_order(&self, body: crate::models::Order) -> Box>> { + fn place_order(&self, body: crate::models::Order) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/store/order".to_string()) .with_body_param(body) .execute(self.configuration.borrow()) diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs index 1ea00f7536d..d6131520db1 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs @@ -25,72 +25,72 @@ pub struct UserApiClient { impl UserApiClient { pub fn new(configuration: Rc>) -> UserApiClient { UserApiClient { - configuration: configuration, + configuration, } } } pub trait UserApi { - fn create_user(&self, body: crate::models::User) -> Box>>; - fn create_users_with_array_input(&self, body: Vec) -> Box>>; - fn create_users_with_list_input(&self, body: Vec) -> Box>>; - fn delete_user(&self, username: &str) -> Box>>; - fn get_user_by_name(&self, username: &str) -> Box>>; - fn login_user(&self, username: &str, password: &str) -> Box>>; - fn logout_user(&self, ) -> Box>>; - fn update_user(&self, username: &str, body: crate::models::User) -> Box>>; + fn create_user(&self, body: crate::models::User) -> Box>>; + fn create_users_with_array_input(&self, body: Vec) -> Box>>; + fn create_users_with_list_input(&self, body: Vec) -> Box>>; + fn delete_user(&self, username: &str) -> Box>>; + fn get_user_by_name(&self, username: &str) -> Box>>; + fn login_user(&self, username: &str, password: &str) -> Box>>; + fn logout_user(&self, ) -> Box>>; + fn update_user(&self, username: &str, body: crate::models::User) -> Box>>; } implUserApi for UserApiClient { - fn create_user(&self, body: crate::models::User) -> Box>> { + fn create_user(&self, body: crate::models::User) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user".to_string()) .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } - fn create_users_with_array_input(&self, body: Vec) -> Box>> { + fn create_users_with_array_input(&self, body: Vec) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user/createWithArray".to_string()) .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } - fn create_users_with_list_input(&self, body: Vec) -> Box>> { + fn create_users_with_list_input(&self, body: Vec) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user/createWithList".to_string()) .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } - fn delete_user(&self, username: &str) -> Box>> { + fn delete_user(&self, username: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Delete, "/user/{username}".to_string()) .with_path_param("username".to_string(), username.to_string()) .returns_nothing() .execute(self.configuration.borrow()) } - fn get_user_by_name(&self, username: &str) -> Box>> { + fn get_user_by_name(&self, username: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Get, "/user/{username}".to_string()) .with_path_param("username".to_string(), username.to_string()) .execute(self.configuration.borrow()) } - fn login_user(&self, username: &str, password: &str) -> Box>> { + fn login_user(&self, username: &str, password: &str) -> Box>> { __internal_request::Request::new(hyper::Method::Get, "/user/login".to_string()) .with_query_param("username".to_string(), username.to_string()) .with_query_param("password".to_string(), password.to_string()) .execute(self.configuration.borrow()) } - fn logout_user(&self, ) -> Box>> { + fn logout_user(&self, ) -> Box>> { __internal_request::Request::new(hyper::Method::Get, "/user/logout".to_string()) .returns_nothing() .execute(self.configuration.borrow()) } - fn update_user(&self, username: &str, body: crate::models::User) -> Box>> { + fn update_user(&self, username: &str, body: crate::models::User) -> Box>> { __internal_request::Request::new(hyper::Method::Put, "/user/{username}".to_string()) .with_path_param("username".to_string(), username.to_string()) .with_body_param(body) diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs b/samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs index 45395215a3f..f1286a5d1c8 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/api_response.rs @@ -11,6 +11,7 @@ /// ApiResponse : Describes the result of uploading an image resource + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct ApiResponse { #[serde(rename = "code", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/category.rs b/samples/client/petstore/rust/hyper/petstore/src/models/category.rs index 1c8763902ba..dcd2dc38630 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/category.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/category.rs @@ -11,6 +11,7 @@ /// Category : A category for a pet + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Category { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs index b4495b6a5fc..1baf2f7528e 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -1,12 +1,12 @@ -mod api_response; +pub mod api_response; pub use self::api_response::ApiResponse; -mod category; +pub mod category; pub use self::category::Category; -mod order; +pub mod order; pub use self::order::Order; -mod pet; +pub mod pet; pub use self::pet::Pet; -mod tag; +pub mod tag; pub use self::tag::Tag; -mod user; +pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs index 685e080e312..89cab91e62c 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs @@ -11,6 +11,7 @@ /// Order : An order for a pets from the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Order { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/pet.rs b/samples/client/petstore/rust/hyper/petstore/src/models/pet.rs index 2da297169eb..ff8a32fee3a 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/pet.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/pet.rs @@ -11,6 +11,7 @@ /// Pet : A pet for sale in the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Pet { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] @@ -34,8 +35,8 @@ impl Pet { Pet { id: None, category: None, - name: name, - photo_urls: photo_urls, + name, + photo_urls, tags: None, status: None, } diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/tag.rs b/samples/client/petstore/rust/hyper/petstore/src/models/tag.rs index 364143932c0..f6bcb5c78d6 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/tag.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/tag.rs @@ -11,6 +11,7 @@ /// Tag : A tag for a pet + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Tag { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/user.rs b/samples/client/petstore/rust/hyper/petstore/src/models/user.rs index b6b9fc78fb9..cf863af7b58 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/user.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/user.rs @@ -11,6 +11,7 @@ /// User : A User who is purchasing from the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct User { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION index 83a328a9227..0e97bd19efb 100644 --- a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.0-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/rust-test/git_push.sh b/samples/client/petstore/rust/hyper/rust-test/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/hyper/rust-test/git_push.sh +++ b/samples/client/petstore/rust/hyper/rust-test/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs index 6105ed87f9d..4976ba81c65 100644 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/client.rs @@ -4,7 +4,7 @@ use hyper; use super::configuration::Configuration; pub struct APIClient { - default_api: Box, + default_api: Box, } impl APIClient { @@ -16,7 +16,7 @@ impl APIClient { } } - pub fn default_api(&self) -> &crate::apis::DefaultApi{ + pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ self.default_api.as_ref() } diff --git a/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/default_api.rs index b1894d69ef2..9f9873715cb 100644 --- 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 @@ -25,18 +25,18 @@ pub struct DefaultApiClient { impl DefaultApiClient { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { - configuration: configuration, + configuration, } } } pub trait DefaultApi { - fn dummy_get(&self, ) -> Box>>; + fn dummy_get(&self, ) -> Box>>; } implDefaultApi for DefaultApiClient { - fn dummy_get(&self, ) -> Box>> { + 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/request.rs b/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs index 2d5c7eb5a64..f97b5277196 100644 --- a/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/rust-test/src/apis/request.rs @@ -98,7 +98,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Box> + 'a> + ) -> Box> + 'a> where C: hyper::client::Connect, U: Sized + 'a, 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 index 8762207b5b3..97887b5798e 100644 --- a/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/rust-test/src/models/mod.rs @@ -1,2 +1,2 @@ -mod type_testing; +pub mod type_testing; pub use self::type_testing::TypeTesting; diff --git a/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs b/samples/client/petstore/rust/hyper/rust-test/src/models/type_testing.rs index abd6582cc66..57188e8ee7e 100644 --- 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 @@ -11,6 +11,7 @@ /// 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")] diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION index 83a328a9227..0e97bd19efb 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.0-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh b/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs index 2f76997d319..7566e9e8479 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/client.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use super::configuration::Configuration; pub struct APIClient { - default_api: Box, + default_api: Box, } impl APIClient { @@ -15,7 +15,7 @@ impl APIClient { } } - pub fn default_api(&self) -> &crate::apis::DefaultApi{ + pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ self.default_api.as_ref() } diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs index 487e5d3af60..13bc9939aef 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs @@ -22,7 +22,7 @@ pub struct DefaultApiClient { impl DefaultApiClient { pub fn new(configuration: Rc) -> DefaultApiClient { DefaultApiClient { - configuration: configuration, + configuration, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION index 2f81801b794..0e97bd19efb 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.1-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/petstore/git_push.sh b/samples/client/petstore/rust/reqwest/petstore/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore/git_push.sh +++ b/samples/client/petstore/rust/reqwest/petstore/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs index f2319088324..8a3963dcc53 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs @@ -3,9 +3,9 @@ use std::rc::Rc; use super::configuration::Configuration; pub struct APIClient { - pet_api: Box, - store_api: Box, - user_api: Box, + pet_api: Box, + store_api: Box, + user_api: Box, } impl APIClient { @@ -19,15 +19,15 @@ impl APIClient { } } - pub fn pet_api(&self) -> &crate::apis::PetApi{ + pub fn pet_api(&self) -> &dyn crate::apis::PetApi{ self.pet_api.as_ref() } - pub fn store_api(&self) -> &crate::apis::StoreApi{ + pub fn store_api(&self) -> &dyn crate::apis::StoreApi{ self.store_api.as_ref() } - pub fn user_api(&self) -> &crate::apis::UserApi{ + pub fn user_api(&self) -> &dyn crate::apis::UserApi{ self.user_api.as_ref() } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs index 428e75bbea6..81b049f96ba 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs @@ -22,7 +22,7 @@ pub struct PetApiClient { impl PetApiClient { pub fn new(configuration: Rc) -> PetApiClient { PetApiClient { - configuration: configuration, + configuration, } } } @@ -210,10 +210,10 @@ impl PetApi for PetApiClient { if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut form_params = std::collections::HashMap::new(); - form_params.insert("additionalMetadata", additional_metadata.to_string()); - form_params.insert("file", unimplemented!("File form param not supported with x-www-form-urlencoded content")); - req_builder = req_builder.form(&form_params); + let form = reqwest::multipart::Form::new() + .text("additionalMetadata", additional_metadata.to_string()) + .file("file", file)?; + req_builder = req_builder.multipart(form); // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs index 16b4176562c..419af90dc61 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs @@ -22,7 +22,7 @@ pub struct StoreApiClient { impl StoreApiClient { pub fn new(configuration: Rc) -> StoreApiClient { StoreApiClient { - configuration: configuration, + configuration, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs index 3c82ab1502a..9fb810d1df5 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs @@ -22,7 +22,7 @@ pub struct UserApiClient { impl UserApiClient { pub fn new(configuration: Rc) -> UserApiClient { UserApiClient { - configuration: configuration, + configuration, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs index 45395215a3f..f1286a5d1c8 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/api_response.rs @@ -11,6 +11,7 @@ /// ApiResponse : Describes the result of uploading an image resource + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct ApiResponse { #[serde(rename = "code", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/category.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/category.rs index 1c8763902ba..dcd2dc38630 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/category.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/category.rs @@ -11,6 +11,7 @@ /// Category : A category for a pet + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Category { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs index b4495b6a5fc..1baf2f7528e 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -1,12 +1,12 @@ -mod api_response; +pub mod api_response; pub use self::api_response::ApiResponse; -mod category; +pub mod category; pub use self::category::Category; -mod order; +pub mod order; pub use self::order::Order; -mod pet; +pub mod pet; pub use self::pet::Pet; -mod tag; +pub mod tag; pub use self::tag::Tag; -mod user; +pub mod user; pub use self::user::User; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs index 685e080e312..89cab91e62c 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs @@ -11,6 +11,7 @@ /// Order : An order for a pets from the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Order { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs index 2da297169eb..ff8a32fee3a 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/pet.rs @@ -11,6 +11,7 @@ /// Pet : A pet for sale in the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Pet { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] @@ -34,8 +35,8 @@ impl Pet { Pet { id: None, category: None, - name: name, - photo_urls: photo_urls, + name, + photo_urls, tags: None, status: None, } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs index 364143932c0..f6bcb5c78d6 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/tag.rs @@ -11,6 +11,7 @@ /// Tag : A tag for a pet + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Tag { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/user.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/user.rs index b6b9fc78fb9..cf863af7b58 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/user.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/user.rs @@ -11,6 +11,7 @@ /// User : A User who is purchasing from the pet store + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct User { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] diff --git a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION index 83a328a9227..0e97bd19efb 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.0-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/rust-test/git_push.sh b/samples/client/petstore/rust/reqwest/rust-test/git_push.sh index 8442b80bb44..ced3be2b0c7 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/git_push.sh +++ b/samples/client/petstore/rust/reqwest/rust-test/git_push.sh @@ -1,11 +1,17 @@ #!/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" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ 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 + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ 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" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs index 2f76997d319..7566e9e8479 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/client.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use super::configuration::Configuration; pub struct APIClient { - default_api: Box, + default_api: Box, } impl APIClient { @@ -15,7 +15,7 @@ impl APIClient { } } - pub fn default_api(&self) -> &crate::apis::DefaultApi{ + pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{ self.default_api.as_ref() } diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs index 9404fefb7dd..9466fd22a2d 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs @@ -22,7 +22,7 @@ pub struct DefaultApiClient { impl DefaultApiClient { pub fn new(configuration: Rc) -> DefaultApiClient { DefaultApiClient { - configuration: configuration, + configuration, } } } 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 index 8762207b5b3..97887b5798e 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/models/mod.rs @@ -1,2 +1,2 @@ -mod type_testing; +pub mod type_testing; pub use self::type_testing::TypeTesting; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/rust-test/src/models/type_testing.rs index abd6582cc66..57188e8ee7e 100644 --- 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 @@ -11,6 +11,7 @@ /// 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")]