diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index 75933ea708c..13a890147ad 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -31,6 +31,7 @@ import io.swagger.v3.oas.models.servers.Server; import joptsimple.internal.Strings; import lombok.Setter; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.meta.features.*; @@ -803,6 +804,15 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon postProcessOperationWithModels(op, allModels); } + operationList.sort((one, another) -> { + int params_compare = ObjectUtils.compare(one.pathParams.size(), another.pathParams.size()); + if (params_compare == 0) { + return ObjectUtils.compare(one.operationId, another.operationId); + } else { + return params_compare; + } + }); + return objs; } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/README.md b/samples/server/petstore/rust-server/output/openapi-v3/README.md index c12f26067e0..c6a16835d35 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/README.md @@ -122,7 +122,6 @@ Method | HTTP request | Description [****](docs/default_api.md#) | **GET** /any-of | [****](docs/default_api.md#) | **POST** /callback-with-header | [****](docs/default_api.md#) | **GET** /complex-query-param | -[****](docs/default_api.md#) | **GET** /enum_in_path/{path_param} | [****](docs/default_api.md#) | **GET** /json-complex-query-param | [****](docs/default_api.md#) | **GET** /mandatory-request-header | [****](docs/default_api.md#) | **GET** /merge-patch-json | @@ -143,6 +142,7 @@ Method | HTTP request | Description [****](docs/default_api.md#) | **PUT** /xml_other | [****](docs/default_api.md#) | **POST** /xml | Post an array [****](docs/default_api.md#) | **PUT** /xml | +[****](docs/default_api.md#) | **GET** /enum_in_path/{path_param} | [**CreateRepo**](docs/repo_api.md#CreateRepo) | **POST** /repos | [**GetRepoInfo**](docs/repo_api.md#GetRepoInfo) | **GET** /repos/{repoId} | diff --git a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md index 192101ead31..e0897cd495b 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md @@ -7,7 +7,6 @@ Method | HTTP request | Description ****](default_api.md#) | **GET** /any-of | ****](default_api.md#) | **POST** /callback-with-header | ****](default_api.md#) | **GET** /complex-query-param | -****](default_api.md#) | **GET** /enum_in_path/{path_param} | ****](default_api.md#) | **GET** /json-complex-query-param | ****](default_api.md#) | **GET** /mandatory-request-header | ****](default_api.md#) | **GET** /merge-patch-json | @@ -28,6 +27,7 @@ Method | HTTP request | Description ****](default_api.md#) | **PUT** /xml_other | ****](default_api.md#) | **POST** /xml | Post an array ****](default_api.md#) | **PUT** /xml | +****](default_api.md#) | **GET** /enum_in_path/{path_param} | # **** @@ -119,31 +119,6 @@ No authorization required [[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) -# **** -> (path_param) - - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **path_param** | [****](.md)| | - -### 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) - # **** > (optional) @@ -677,3 +652,28 @@ No authorization required [[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) +# **** +> (path_param) + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **path_param** | [****](.md)| | + +### 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/server/petstore/rust-server/output/openapi-v3/examples/client/main.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/client/main.rs index 3285d554799..3a4b47067d3 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/client/main.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/client/main.rs @@ -9,7 +9,6 @@ use openapi_v3::{Api, ApiNoContext, Claims, Client, ContextWrapperExt, models, AnyOfGetResponse, CallbackWithHeaderPostResponse, ComplexQueryParamGetResponse, - EnumInPathPathParamGetResponse, JsonComplexQueryParamGetResponse, MandatoryRequestHeaderGetResponse, MergePatchJsonGetResponse, @@ -30,6 +29,7 @@ use openapi_v3::{Api, ApiNoContext, Claims, Client, ContextWrapperExt, models, XmlOtherPutResponse, XmlPostResponse, XmlPutResponse, + EnumInPathPathParamGetResponse, CreateRepoResponse, GetRepoInfoResponse, }; @@ -177,14 +177,6 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - /* Disabled because there's no example. - Some("EnumInPathPathParamGet") => { - let result = rt.block_on(client.enum_in_path_path_param_get( - ??? - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, - */ Some("JsonComplexQueryParamGet") => { let result = rt.block_on(client.json_complex_query_param_get( Some(&Vec::new()) @@ -298,6 +290,14 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, + /* Disabled because there's no example. + Some("EnumInPathPathParamGet") => { + let result = rt.block_on(client.enum_in_path_path_param_get( + ??? + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, + */ Some("CreateRepo") => { let result = rt.block_on(client.create_repo( serde_json::from_str::(r#"{"requiredParam":true}"#).expect("Failed to parse JSON example") diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs index c8482bcb3e0..7d1ea3e6973 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs @@ -105,7 +105,6 @@ use openapi_v3::{ AnyOfGetResponse, CallbackWithHeaderPostResponse, ComplexQueryParamGetResponse, - EnumInPathPathParamGetResponse, JsonComplexQueryParamGetResponse, MandatoryRequestHeaderGetResponse, MergePatchJsonGetResponse, @@ -126,6 +125,7 @@ use openapi_v3::{ XmlOtherPutResponse, XmlPostResponse, XmlPutResponse, + EnumInPathPathParamGetResponse, CreateRepoResponse, GetRepoInfoResponse, }; @@ -163,15 +163,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - async fn enum_in_path_path_param_get( - &self, - path_param: models::StringEnum, - context: &C) -> Result - { - info!("enum_in_path_path_param_get({:?}) - X-Span-ID: {:?}", path_param, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - async fn json_complex_query_param_get( &self, list_of_strings: Option<&Vec>, @@ -348,6 +339,15 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } + async fn enum_in_path_path_param_get( + &self, + path_param: models::StringEnum, + context: &C) -> Result + { + info!("enum_in_path_path_param_get({:?}) - X-Span-ID: {:?}", path_param, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + async fn create_repo( &self, object_param: models::ObjectParam, diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 8b23bc38e85..f6c7c703598 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -39,7 +39,6 @@ use crate::{Api, AnyOfGetResponse, CallbackWithHeaderPostResponse, ComplexQueryParamGetResponse, - EnumInPathPathParamGetResponse, JsonComplexQueryParamGetResponse, MandatoryRequestHeaderGetResponse, MergePatchJsonGetResponse, @@ -60,6 +59,7 @@ use crate::{Api, XmlOtherPutResponse, XmlPostResponse, XmlPutResponse, + EnumInPathPathParamGetResponse, CreateRepoResponse, GetRepoInfoResponse }; @@ -667,76 +667,6 @@ impl Api for Client where } } - async fn enum_in_path_path_param_get( - &self, - param_path_param: models::StringEnum, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/enum_in_path/{path_param}", - self.base_path - ,path_param=utf8_percent_encode(¶m_path_param.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("GET") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 200 => { - Ok( - EnumInPathPathParamGetResponse::Success - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn json_complex_query_param_get( &self, param_list_of_strings: Option<&Vec>, @@ -2597,6 +2527,76 @@ impl Api for Client where } } + async fn enum_in_path_path_param_get( + &self, + param_path_param: models::StringEnum, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/enum_in_path/{path_param}", + self.base_path + ,path_param=utf8_percent_encode(¶m_path_param.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + Ok( + EnumInPathPathParamGetResponse::Success + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + async fn create_repo( &self, param_object_param: models::ObjectParam, diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 02500e5701e..ed43bd647d3 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -48,12 +48,6 @@ pub enum ComplexQueryParamGetResponse { Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub enum EnumInPathPathParamGetResponse { - /// Success - Success -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum JsonComplexQueryParamGetResponse { /// Success @@ -265,6 +259,12 @@ pub enum XmlPutResponse { BadRequest } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub enum EnumInPathPathParamGetResponse { + /// Success + Success +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateRepoResponse { /// Success @@ -301,11 +301,6 @@ pub trait Api { list_of_strings: Option<&Vec>, context: &C) -> Result; - async fn enum_in_path_path_param_get( - &self, - path_param: models::StringEnum, - context: &C) -> Result; - async fn json_complex_query_param_get( &self, list_of_strings: Option<&Vec>, @@ -402,6 +397,11 @@ pub trait Api { xml_object: Option, context: &C) -> Result; + async fn enum_in_path_path_param_get( + &self, + path_param: models::StringEnum, + context: &C) -> Result; + async fn create_repo( &self, object_param: models::ObjectParam, @@ -438,11 +438,6 @@ pub trait ApiNoContext { list_of_strings: Option<&Vec>, ) -> Result; - async fn enum_in_path_path_param_get( - &self, - path_param: models::StringEnum, - ) -> Result; - async fn json_complex_query_param_get( &self, list_of_strings: Option<&Vec>, @@ -539,6 +534,11 @@ pub trait ApiNoContext { xml_object: Option, ) -> Result; + async fn enum_in_path_path_param_get( + &self, + path_param: models::StringEnum, + ) -> Result; + async fn create_repo( &self, object_param: models::ObjectParam, @@ -601,15 +601,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().complex_query_param_get(list_of_strings, &context).await } - async fn enum_in_path_path_param_get( - &self, - path_param: models::StringEnum, - ) -> Result - { - let context = self.context().clone(); - self.api().enum_in_path_path_param_get(path_param, &context).await - } - async fn json_complex_query_param_get( &self, list_of_strings: Option<&Vec>, @@ -786,6 +777,15 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().xml_put(xml_object, &context).await } + async fn enum_in_path_path_param_get( + &self, + path_param: models::StringEnum, + ) -> Result + { + let context = self.context().clone(); + self.api().enum_in_path_path_param_get(path_param, &context).await + } + async fn create_repo( &self, object_param: models::ObjectParam, diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index af72c843ad0..025004ed700 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -24,7 +24,6 @@ use crate::{Api, AnyOfGetResponse, CallbackWithHeaderPostResponse, ComplexQueryParamGetResponse, - EnumInPathPathParamGetResponse, JsonComplexQueryParamGetResponse, MandatoryRequestHeaderGetResponse, MergePatchJsonGetResponse, @@ -45,6 +44,7 @@ use crate::{Api, XmlOtherPutResponse, XmlPostResponse, XmlPutResponse, + EnumInPathPathParamGetResponse, CreateRepoResponse, GetRepoInfoResponse }; @@ -406,60 +406,6 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(response) }, - // EnumInPathPathParamGet - GET /enum_in_path/{path_param} - hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_ENUM_IN_PATH_PATH_PARAM - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE ENUM_IN_PATH_PATH_PARAM in set but failed match against \"{}\"", path, paths::REGEX_ENUM_IN_PATH_PATH_PARAM.as_str()) - ); - - let param_path_param = match percent_encoding::percent_decode(path_params["path_param"].as_bytes()).decode_utf8() { - Ok(param_path_param) => match param_path_param.parse::() { - Ok(param_path_param) => param_path_param, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter path_param: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["path_param"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.enum_in_path_path_param_get( - param_path_param, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - EnumInPathPathParamGetResponse::Success - => { - *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // JsonComplexQueryParamGet - GET /json-complex-query-param hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) @@ -1774,6 +1720,60 @@ impl hyper::service::Service<(Request, C)> for Service where } }, + // EnumInPathPathParamGet - GET /enum_in_path/{path_param} + hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_ENUM_IN_PATH_PATH_PARAM + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE ENUM_IN_PATH_PATH_PARAM in set but failed match against \"{}\"", path, paths::REGEX_ENUM_IN_PATH_PATH_PARAM.as_str()) + ); + + let param_path_param = match percent_encoding::percent_decode(path_params["path_param"].as_bytes()).decode_utf8() { + Ok(param_path_param) => match param_path_param.parse::() { + Ok(param_path_param) => param_path_param, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter path_param: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["path_param"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.enum_in_path_path_param_get( + param_path_param, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + EnumInPathPathParamGetResponse::Success + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + // CreateRepo - POST /repos hyper::Method::POST if path.matched(paths::ID_REPOS) => { // Handle body parameters (note that non-required body parameters will ignore garbage @@ -1958,8 +1958,6 @@ impl RequestParser for ApiRequestParser { hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => Some("CallbackWithHeaderPost"), // ComplexQueryParamGet - GET /complex-query-param hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => Some("ComplexQueryParamGet"), - // EnumInPathPathParamGet - GET /enum_in_path/{path_param} - hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"), // JsonComplexQueryParamGet - GET /json-complex-query-param hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => Some("JsonComplexQueryParamGet"), // MandatoryRequestHeaderGet - GET /mandatory-request-header @@ -2000,6 +1998,8 @@ impl RequestParser for ApiRequestParser { hyper::Method::POST if path.matched(paths::ID_XML) => Some("XmlPost"), // XmlPut - PUT /xml hyper::Method::PUT if path.matched(paths::ID_XML) => Some("XmlPut"), + // EnumInPathPathParamGet - GET /enum_in_path/{path_param} + hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"), // CreateRepo - POST /repos hyper::Method::POST if path.matched(paths::ID_REPOS) => Some("CreateRepo"), // GetRepoInfo - GET /repos/{repoId} diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md index 58e716118d2..1d806cd13c1 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -67,25 +67,25 @@ cargo run --example client FakeOuterCompositeSerialize cargo run --example client FakeOuterNumberSerialize cargo run --example client FakeOuterStringSerialize cargo run --example client FakeResponseWithNumericalDescription -cargo run --example client HyphenParam cargo run --example client TestEndpointParameters cargo run --example client TestEnumParameters cargo run --example client TestJsonFormData -cargo run --example client DeletePet +cargo run --example client HyphenParam cargo run --example client FindPetsByStatus cargo run --example client FindPetsByTags +cargo run --example client DeletePet cargo run --example client GetPetById cargo run --example client UpdatePetWithForm cargo run --example client UploadFile -cargo run --example client DeleteOrder cargo run --example client GetInventory +cargo run --example client DeleteOrder cargo run --example client GetOrderById cargo run --example client CreateUsersWithArrayInput cargo run --example client CreateUsersWithListInput -cargo run --example client DeleteUser -cargo run --example client GetUserByName cargo run --example client LoginUser cargo run --example client LogoutUser +cargo run --example client DeleteUser +cargo run --example client GetUserByName ``` ### HTTPS @@ -126,33 +126,33 @@ Method | HTTP request | Description [**fakeOuterNumberSerialize**](docs/fake_api.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterStringSerialize**](docs/fake_api.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fake_response_with_numerical_description**](docs/fake_api.md#fake_response_with_numerical_description) | **GET** /fake/response-with-numerical-description | -[**hyphenParam**](docs/fake_api.md#hyphenParam) | **GET** /fake/hyphenParam/{hyphen-param} | [**testBodyWithQueryParams**](docs/fake_api.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testClientModel**](docs/fake_api.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](docs/fake_api.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](docs/fake_api.md#testEnumParameters) | **GET** /fake | To test enum parameters [**testInlineAdditionalProperties**](docs/fake_api.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](docs/fake_api.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +[**hyphenParam**](docs/fake_api.md#hyphenParam) | **GET** /fake/hyphenParam/{hyphen-param} | [**testClassname**](docs/fake_classname_tags123_api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case [**addPet**](docs/pet_api.md#addPet) | **POST** /pet | Add a new pet to the store -[**deletePet**](docs/pet_api.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**findPetsByStatus**](docs/pet_api.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByTags**](docs/pet_api.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -[**getPetById**](docs/pet_api.md#getPetById) | **GET** /pet/{petId} | Find pet by ID [**updatePet**](docs/pet_api.md#updatePet) | **PUT** /pet | Update an existing pet +[**deletePet**](docs/pet_api.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**getPetById**](docs/pet_api.md#getPetById) | **GET** /pet/{petId} | Find pet by ID [**updatePetWithForm**](docs/pet_api.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](docs/pet_api.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -[**deleteOrder**](docs/store_api.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID [**getInventory**](docs/store_api.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](docs/store_api.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID [**placeOrder**](docs/store_api.md#placeOrder) | **POST** /store/order | Place an order for a pet +[**deleteOrder**](docs/store_api.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**getOrderById**](docs/store_api.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID [**createUser**](docs/user_api.md#createUser) | **POST** /user | Create user [**createUsersWithArrayInput**](docs/user_api.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array [**createUsersWithListInput**](docs/user_api.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -[**deleteUser**](docs/user_api.md#deleteUser) | **DELETE** /user/{username} | Delete user -[**getUserByName**](docs/user_api.md#getUserByName) | **GET** /user/{username} | Get user by user name [**loginUser**](docs/user_api.md#loginUser) | **GET** /user/login | Logs user into the system [**logoutUser**](docs/user_api.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**deleteUser**](docs/user_api.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](docs/user_api.md#getUserByName) | **GET** /user/{username} | Get user by user name [**updateUser**](docs/user_api.md#updateUser) | **PUT** /user/{username} | Updated user diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md index ddc0786bbe0..e2821df2e6d 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md @@ -10,13 +10,13 @@ Method | HTTP request | Description **fakeOuterNumberSerialize**](fake_api.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | **fakeOuterStringSerialize**](fake_api.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | **fake_response_with_numerical_description**](fake_api.md#fake_response_with_numerical_description) | **GET** /fake/response-with-numerical-description | -**hyphenParam**](fake_api.md#hyphenParam) | **GET** /fake/hyphenParam/{hyphen-param} | **testBodyWithQueryParams**](fake_api.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | **testClientModel**](fake_api.md#testClientModel) | **PATCH** /fake | To test \"client\" model **testEndpointParameters**](fake_api.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 **testEnumParameters**](fake_api.md#testEnumParameters) | **GET** /fake | To test enum parameters **testInlineAdditionalProperties**](fake_api.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties **testJsonFormData**](fake_api.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +**hyphenParam**](fake_api.md#hyphenParam) | **GET** /fake/hyphenParam/{hyphen-param} | # **123example** @@ -199,33 +199,6 @@ No authorization required [[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) -# **hyphenParam** -> hyphenParam(hyphen_param) - - -To test hyphen in path parameter name - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **hyphen_param** | **String**| Parameter with hyphen in name | - -### 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) - # **testBodyWithQueryParams** > testBodyWithQueryParams(query, body) @@ -422,3 +395,30 @@ No authorization required [[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) +# **hyphenParam** +> hyphenParam(hyphen_param) + + +To test hyphen in path parameter name + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **hyphen_param** | **String**| Parameter with hyphen in name | + +### 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/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md index 48dc1d0aefa..636d660c548 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md @@ -5,11 +5,11 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- **addPet**](pet_api.md#addPet) | **POST** /pet | Add a new pet to the store -**deletePet**](pet_api.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet **findPetsByStatus**](pet_api.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status **findPetsByTags**](pet_api.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -**getPetById**](pet_api.md#getPetById) | **GET** /pet/{petId} | Find pet by ID **updatePet**](pet_api.md#updatePet) | **PUT** /pet | Update an existing pet +**deletePet**](pet_api.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +**getPetById**](pet_api.md#getPetById) | **GET** /pet/{petId} | Find pet by ID **updatePetWithForm**](pet_api.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data **uploadFile**](pet_api.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image @@ -40,41 +40,6 @@ Name | Type | Description | Notes [[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) -# **deletePet** -> deletePet(ctx, pet_id, optional) -Deletes a pet - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **pet_id** | **i64**| Pet id to delete | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters - -### Optional Parameters -Optional parameters are passed through a map[string]interface{}. - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **i64**| Pet id to delete | - **api_key** | **String**| | - -### Return type - - (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **findPetsByStatus** > Vec findPetsByStatus(ctx, status) Finds Pets by status @@ -131,6 +96,67 @@ Name | Type | Description | Notes [[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) +# **updatePet** +> updatePet(ctx, body) +Update an existing pet + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context containing the authentication | nil if no authentication + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deletePet** +> deletePet(ctx, pet_id, optional) +Deletes a pet + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context containing the authentication | nil if no authentication + **pet_id** | **i64**| Pet id to delete | + **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a map[string]interface{}. + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **i64**| Pet id to delete | + **api_key** | **String**| | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **getPetById** > models::Pet getPetById(ctx, pet_id) Find pet by ID @@ -159,32 +185,6 @@ Name | Type | Description | Notes [[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) -# **updatePet** -> updatePet(ctx, body) -Update an existing pet - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - - (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **updatePetWithForm** > updatePetWithForm(ctx, pet_id, optional) Updates a pet in the store with form data diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/store_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/store_api.md index 9c8c27bcc36..f8e633abd83 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/store_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/store_api.md @@ -4,12 +4,61 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -**deleteOrder**](store_api.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID **getInventory**](store_api.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -**getOrderById**](store_api.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID **placeOrder**](store_api.md#placeOrder) | **POST** /store/order | Place an order for a pet +**deleteOrder**](store_api.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +**getOrderById**](store_api.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID +# **getInventory** +> std::collections::HashMap getInventory(ctx, ) +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**std::collections::HashMap**](integer.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **placeOrder** +> models::Order placeOrder(body) +Place an order for a pet + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + # **deleteOrder** > deleteOrder(order_id) Delete purchase order by ID @@ -37,30 +86,6 @@ No authorization required [[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) -# **getInventory** -> std::collections::HashMap getInventory(ctx, ) -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Required Parameters -This endpoint does not need any parameter. - -### Return type - -[**std::collections::HashMap**](integer.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **getOrderById** > models::Order getOrderById(order_id) Find purchase order by ID @@ -88,28 +113,3 @@ No authorization required [[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) -# **placeOrder** -> models::Order placeOrder(body) -Place an order for a pet - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | - -### Return type - -[**models::Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[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/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/user_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/user_api.md index 7e3c1b2ca1f..9518a5d031c 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/user_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/user_api.md @@ -7,10 +7,10 @@ Method | HTTP request | Description **createUser**](user_api.md#createUser) | **POST** /user | Create user **createUsersWithArrayInput**](user_api.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array **createUsersWithListInput**](user_api.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -**deleteUser**](user_api.md#deleteUser) | **DELETE** /user/{username} | Delete user -**getUserByName**](user_api.md#getUserByName) | **GET** /user/{username} | Get user by user name **loginUser**](user_api.md#loginUser) | **GET** /user/login | Logs user into the system **logoutUser**](user_api.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +**deleteUser**](user_api.md#deleteUser) | **DELETE** /user/{username} | Delete user +**getUserByName**](user_api.md#getUserByName) | **GET** /user/{username} | Get user by user name **updateUser**](user_api.md#updateUser) | **PUT** /user/{username} | Updated user @@ -91,6 +91,54 @@ No authorization required [[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) +# **loginUser** +> String loginUser(username, password) +Logs user into the system + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +[**String**](string.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **logoutUser** +> logoutUser() +Logs out current logged in user session + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **deleteUser** > deleteUser(username) Delete user @@ -143,54 +191,6 @@ No authorization required [[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) -# **loginUser** -> String loginUser(username, password) -Logs user into the system - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | - **password** | **String**| The password for login in clear text | - -### Return type - -[**String**](string.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[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) - -# **logoutUser** -> logoutUser() -Logs out current logged in user session - -### Required Parameters -This endpoint does not need any parameter. - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **updateUser** > updateUser(username, body) Updated user diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs index 8e2629962dc..b0e76ca713c 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs @@ -12,33 +12,33 @@ use petstore_with_fake_endpoints_models_for_testing::{Api, ApiNoContext, Claims, FakeOuterNumberSerializeResponse, FakeOuterStringSerializeResponse, FakeResponseWithNumericalDescriptionResponse, - HyphenParamResponse, TestBodyWithQueryParamsResponse, TestClientModelResponse, TestEndpointParametersResponse, TestEnumParametersResponse, TestInlineAdditionalPropertiesResponse, TestJsonFormDataResponse, + HyphenParamResponse, TestClassnameResponse, AddPetResponse, - DeletePetResponse, FindPetsByStatusResponse, FindPetsByTagsResponse, - GetPetByIdResponse, UpdatePetResponse, + DeletePetResponse, + GetPetByIdResponse, UpdatePetWithFormResponse, UploadFileResponse, - DeleteOrderResponse, GetInventoryResponse, - GetOrderByIdResponse, PlaceOrderResponse, + DeleteOrderResponse, + GetOrderByIdResponse, CreateUserResponse, CreateUsersWithArrayInputResponse, CreateUsersWithListInputResponse, - DeleteUserResponse, - GetUserByNameResponse, LoginUserResponse, LogoutUserResponse, + DeleteUserResponse, + GetUserByNameResponse, UpdateUserResponse, }; use clap::{App, Arg}; @@ -74,25 +74,25 @@ fn main() { "FakeOuterNumberSerialize", "FakeOuterStringSerialize", "FakeResponseWithNumericalDescription", - "HyphenParam", "TestEndpointParameters", "TestEnumParameters", "TestJsonFormData", - "DeletePet", + "HyphenParam", "FindPetsByStatus", "FindPetsByTags", + "DeletePet", "GetPetById", "UpdatePetWithForm", "UploadFile", - "DeleteOrder", "GetInventory", + "DeleteOrder", "GetOrderById", "CreateUsersWithArrayInput", "CreateUsersWithListInput", - "DeleteUser", - "GetUserByName", "LoginUser", "LogoutUser", + "DeleteUser", + "GetUserByName", ]) .required(true) .index(1)) @@ -206,12 +206,6 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - Some("HyphenParam") => { - let result = rt.block_on(client.hyphen_param( - "hyphen_param_example".to_string() - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, /* Disabled because there's no example. Some("TestBodyWithQueryParams") => { let result = rt.block_on(client.test_body_with_query_params( @@ -275,6 +269,12 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, + Some("HyphenParam") => { + let result = rt.block_on(client.hyphen_param( + "hyphen_param_example".to_string() + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, /* Disabled because there's no example. Some("TestClassname") => { let result = rt.block_on(client.test_classname( @@ -291,13 +291,6 @@ fn main() { info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, */ - Some("DeletePet") => { - let result = rt.block_on(client.delete_pet( - 789, - Some("api_key_example".to_string()) - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, Some("FindPetsByStatus") => { let result = rt.block_on(client.find_pets_by_status( &Vec::new() @@ -310,12 +303,6 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - Some("GetPetById") => { - let result = rt.block_on(client.get_pet_by_id( - 789 - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, /* Disabled because there's no example. Some("UpdatePet") => { let result = rt.block_on(client.update_pet( @@ -324,6 +311,19 @@ fn main() { info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, */ + Some("DeletePet") => { + let result = rt.block_on(client.delete_pet( + 789, + Some("api_key_example".to_string()) + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, + Some("GetPetById") => { + let result = rt.block_on(client.get_pet_by_id( + 789 + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, Some("UpdatePetWithForm") => { let result = rt.block_on(client.update_pet_with_form( 789, @@ -340,23 +340,11 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - Some("DeleteOrder") => { - let result = rt.block_on(client.delete_order( - "order_id_example".to_string() - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, Some("GetInventory") => { let result = rt.block_on(client.get_inventory( )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - Some("GetOrderById") => { - let result = rt.block_on(client.get_order_by_id( - 789 - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, /* Disabled because there's no example. Some("PlaceOrder") => { let result = rt.block_on(client.place_order( @@ -365,6 +353,18 @@ fn main() { info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, */ + Some("DeleteOrder") => { + let result = rt.block_on(client.delete_order( + "order_id_example".to_string() + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, + Some("GetOrderById") => { + let result = rt.block_on(client.get_order_by_id( + 789 + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, /* Disabled because there's no example. Some("CreateUser") => { let result = rt.block_on(client.create_user( @@ -385,18 +385,6 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, - Some("DeleteUser") => { - let result = rt.block_on(client.delete_user( - "username_example".to_string() - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, - Some("GetUserByName") => { - let result = rt.block_on(client.get_user_by_name( - "username_example".to_string() - )); - info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); - }, Some("LoginUser") => { let result = rt.block_on(client.login_user( "username_example".to_string(), @@ -409,6 +397,18 @@ fn main() { )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, + Some("DeleteUser") => { + let result = rt.block_on(client.delete_user( + "username_example".to_string() + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, + Some("GetUserByName") => { + let result = rt.block_on(client.get_user_by_name( + "username_example".to_string() + )); + info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); + }, /* Disabled because there's no example. Some("UpdateUser") => { let result = rt.block_on(client.update_user( diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs index 2401ef5bc6c..06a4cfe60a8 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs @@ -109,33 +109,33 @@ use petstore_with_fake_endpoints_models_for_testing::{ FakeOuterNumberSerializeResponse, FakeOuterStringSerializeResponse, FakeResponseWithNumericalDescriptionResponse, - HyphenParamResponse, TestBodyWithQueryParamsResponse, TestClientModelResponse, TestEndpointParametersResponse, TestEnumParametersResponse, TestInlineAdditionalPropertiesResponse, TestJsonFormDataResponse, + HyphenParamResponse, TestClassnameResponse, AddPetResponse, - DeletePetResponse, FindPetsByStatusResponse, FindPetsByTagsResponse, - GetPetByIdResponse, UpdatePetResponse, + DeletePetResponse, + GetPetByIdResponse, UpdatePetWithFormResponse, UploadFileResponse, - DeleteOrderResponse, GetInventoryResponse, - GetOrderByIdResponse, PlaceOrderResponse, + DeleteOrderResponse, + GetOrderByIdResponse, CreateUserResponse, CreateUsersWithArrayInputResponse, CreateUsersWithListInputResponse, - DeleteUserResponse, - GetUserByNameResponse, LoginUserResponse, LogoutUserResponse, + DeleteUserResponse, + GetUserByNameResponse, UpdateUserResponse, }; use petstore_with_fake_endpoints_models_for_testing::server::MakeService; @@ -207,15 +207,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - async fn hyphen_param( - &self, - hyphen_param: String, - context: &C) -> Result - { - info!("hyphen_param(\"{}\") - X-Span-ID: {:?}", hyphen_param, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - async fn test_body_with_query_params( &self, query: String, @@ -296,6 +287,15 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } + async fn hyphen_param( + &self, + hyphen_param: String, + context: &C) -> Result + { + info!("hyphen_param(\"{}\") - X-Span-ID: {:?}", hyphen_param, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + /// To test class name in snake case async fn test_classname( &self, @@ -316,17 +316,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - /// Deletes a pet - async fn delete_pet( - &self, - pet_id: i64, - api_key: Option, - context: &C) -> Result - { - info!("delete_pet({}, {:?}) - X-Span-ID: {:?}", pet_id, api_key, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - /// Finds Pets by status async fn find_pets_by_status( &self, @@ -347,16 +336,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - /// Find pet by ID - async fn get_pet_by_id( - &self, - pet_id: i64, - context: &C) -> Result - { - info!("get_pet_by_id({}) - X-Span-ID: {:?}", pet_id, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - /// Update an existing pet async fn update_pet( &self, @@ -367,6 +346,27 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } + /// Deletes a pet + async fn delete_pet( + &self, + pet_id: i64, + api_key: Option, + context: &C) -> Result + { + info!("delete_pet({}, {:?}) - X-Span-ID: {:?}", pet_id, api_key, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + + /// Find pet by ID + async fn get_pet_by_id( + &self, + pet_id: i64, + context: &C) -> Result + { + info!("get_pet_by_id({}) - X-Span-ID: {:?}", pet_id, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + /// Updates a pet in the store with form data async fn update_pet_with_form( &self, @@ -391,16 +391,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - /// Delete purchase order by ID - async fn delete_order( - &self, - order_id: String, - context: &C) -> Result - { - info!("delete_order(\"{}\") - X-Span-ID: {:?}", order_id, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - /// Returns pet inventories by status async fn get_inventory( &self, @@ -410,16 +400,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - /// Find purchase order by ID - async fn get_order_by_id( - &self, - order_id: i64, - context: &C) -> Result - { - info!("get_order_by_id({}) - X-Span-ID: {:?}", order_id, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - /// Place an order for a pet async fn place_order( &self, @@ -430,6 +410,26 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } + /// Delete purchase order by ID + async fn delete_order( + &self, + order_id: String, + context: &C) -> Result + { + info!("delete_order(\"{}\") - X-Span-ID: {:?}", order_id, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + + /// Find purchase order by ID + async fn get_order_by_id( + &self, + order_id: i64, + context: &C) -> Result + { + info!("get_order_by_id({}) - X-Span-ID: {:?}", order_id, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + /// Create user async fn create_user( &self, @@ -460,26 +460,6 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } - /// Delete user - async fn delete_user( - &self, - username: String, - context: &C) -> Result - { - info!("delete_user(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - - /// Get user by user name - async fn get_user_by_name( - &self, - username: String, - context: &C) -> Result - { - info!("get_user_by_name(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone()); - Err(ApiError("Api-Error: Operation is NOT implemented".into())) - } - /// Logs user into the system async fn login_user( &self, @@ -500,6 +480,26 @@ impl Api for Server where C: Has + Send + Sync Err(ApiError("Api-Error: Operation is NOT implemented".into())) } + /// Delete user + async fn delete_user( + &self, + username: String, + context: &C) -> Result + { + info!("delete_user(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + + /// Get user by user name + async fn get_user_by_name( + &self, + username: String, + context: &C) -> Result + { + info!("get_user_by_name(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone()); + Err(ApiError("Api-Error: Operation is NOT implemented".into())) + } + /// Updated user async fn update_user( &self, diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs index 7657258a406..6accda4cb1e 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs @@ -46,33 +46,33 @@ use crate::{Api, FakeOuterNumberSerializeResponse, FakeOuterStringSerializeResponse, FakeResponseWithNumericalDescriptionResponse, - HyphenParamResponse, TestBodyWithQueryParamsResponse, TestClientModelResponse, TestEndpointParametersResponse, TestEnumParametersResponse, TestInlineAdditionalPropertiesResponse, TestJsonFormDataResponse, + HyphenParamResponse, TestClassnameResponse, AddPetResponse, - DeletePetResponse, FindPetsByStatusResponse, FindPetsByTagsResponse, - GetPetByIdResponse, UpdatePetResponse, + DeletePetResponse, + GetPetByIdResponse, UpdatePetWithFormResponse, UploadFileResponse, - DeleteOrderResponse, GetInventoryResponse, - GetOrderByIdResponse, PlaceOrderResponse, + DeleteOrderResponse, + GetOrderByIdResponse, CreateUserResponse, CreateUsersWithArrayInputResponse, CreateUsersWithListInputResponse, - DeleteUserResponse, - GetUserByNameResponse, LoginUserResponse, LogoutUserResponse, + DeleteUserResponse, + GetUserByNameResponse, UpdateUserResponse }; @@ -1016,76 +1016,6 @@ impl Api for Client where } } - async fn hyphen_param( - &self, - param_hyphen_param: String, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/fake/hyphenParam/{hyphen_param}", - self.base_path - ,hyphen_param=utf8_percent_encode(¶m_hyphen_param.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("GET") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 200 => { - Ok( - HyphenParamResponse::Success - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn test_body_with_query_params( &self, param_query: String, @@ -1703,6 +1633,76 @@ impl Api for Client where } } + async fn hyphen_param( + &self, + param_hyphen_param: String, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/fake/hyphenParam/{hyphen_param}", + self.base_path + ,hyphen_param=utf8_percent_encode(¶m_hyphen_param.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + Ok( + HyphenParamResponse::Success + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + async fn test_classname( &self, param_body: models::Client, @@ -1905,114 +1905,6 @@ impl Api for Client where } } - async fn delete_pet( - &self, - param_pet_id: i64, - param_api_key: Option, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/pet/{pet_id}", - self.base_path - ,pet_id=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("DELETE") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - #[allow(clippy::collapsible_match)] - if let Some(auth_data) = Has::>::get(context).as_ref() { - // Currently only authentication with Basic and Bearer are supported - #[allow(clippy::single_match, clippy::match_single_binding)] - match auth_data { - AuthData::Bearer(bearer_header) => { - let auth = swagger::auth::Header(bearer_header.clone()); - let header = match HeaderValue::from_str(&format!("{}", auth)) { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create Authorization header: {}", e))) - }; - request.headers_mut().insert( - hyper::header::AUTHORIZATION, - header); - }, - _ => {} - } - } - - // Header parameters - #[allow(clippy::single_match)] - match param_api_key { - Some(param_api_key) => { - request.headers_mut().append( - HeaderName::from_static("api_key"), - #[allow(clippy::redundant_clone)] - match header::IntoHeaderValue(param_api_key.clone()).try_into() { - Ok(header) => header, - Err(e) => { - return Err(ApiError(format!( - "Invalid header api_key - {}", e))); - }, - }); - }, - None => {} - } - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 400 => { - Ok( - DeletePetResponse::InvalidPetValue - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn find_pets_by_status( &self, param_status: &Vec, @@ -2229,108 +2121,6 @@ impl Api for Client where } } - async fn get_pet_by_id( - &self, - param_pet_id: i64, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/pet/{pet_id}", - self.base_path - ,pet_id=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("GET") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - #[allow(clippy::collapsible_match)] - if let Some(auth_data) = Has::>::get(context).as_ref() { - // Currently only authentication with Basic and Bearer are supported - #[allow(clippy::single_match, clippy::match_single_binding)] - match auth_data { - _ => {} - } - } - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 200 => { - let body = response.into_body(); - let body = body - .into_raw() - .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; - - let body = str::from_utf8(&body) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - // ToDo: this will move to swagger-rs and become a standard From conversion trait - // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream - let body = serde_xml_rs::from_str::(body) - .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; - - - Ok(GetPetByIdResponse::SuccessfulOperation - (body) - ) - } - 400 => { - Ok( - GetPetByIdResponse::InvalidIDSupplied - ) - } - 404 => { - Ok( - GetPetByIdResponse::PetNotFound - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn update_pet( &self, param_body: models::Pet, @@ -2440,6 +2230,216 @@ impl Api for Client where } } + async fn delete_pet( + &self, + param_pet_id: i64, + param_api_key: Option, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/pet/{pet_id}", + self.base_path + ,pet_id=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("DELETE") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + #[allow(clippy::collapsible_match)] + if let Some(auth_data) = Has::>::get(context).as_ref() { + // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] + match auth_data { + AuthData::Bearer(bearer_header) => { + let auth = swagger::auth::Header(bearer_header.clone()); + let header = match HeaderValue::from_str(&format!("{}", auth)) { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create Authorization header: {}", e))) + }; + request.headers_mut().insert( + hyper::header::AUTHORIZATION, + header); + }, + _ => {} + } + } + + // Header parameters + #[allow(clippy::single_match)] + match param_api_key { + Some(param_api_key) => { + request.headers_mut().append( + HeaderName::from_static("api_key"), + #[allow(clippy::redundant_clone)] + match header::IntoHeaderValue(param_api_key.clone()).try_into() { + Ok(header) => header, + Err(e) => { + return Err(ApiError(format!( + "Invalid header api_key - {}", e))); + }, + }); + }, + None => {} + } + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 400 => { + Ok( + DeletePetResponse::InvalidPetValue + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + + async fn get_pet_by_id( + &self, + param_pet_id: i64, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/pet/{pet_id}", + self.base_path + ,pet_id=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + #[allow(clippy::collapsible_match)] + if let Some(auth_data) = Has::>::get(context).as_ref() { + // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] + match auth_data { + _ => {} + } + } + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + let body = response.into_body(); + let body = body + .into_raw() + .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; + + let body = str::from_utf8(&body) + .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + // ToDo: this will move to swagger-rs and become a standard From conversion trait + // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream + let body = serde_xml_rs::from_str::(body) + .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; + + + Ok(GetPetByIdResponse::SuccessfulOperation + (body) + ) + } + 400 => { + Ok( + GetPetByIdResponse::InvalidIDSupplied + ) + } + 404 => { + Ok( + GetPetByIdResponse::PetNotFound + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + async fn update_pet_with_form( &self, param_pet_id: i64, @@ -2705,81 +2705,6 @@ impl Api for Client where } } - async fn delete_order( - &self, - param_order_id: String, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/store/order/{order_id}", - self.base_path - ,order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("DELETE") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 400 => { - Ok( - DeleteOrderResponse::InvalidIDSupplied - ) - } - 404 => { - Ok( - DeleteOrderResponse::OrderNotFound - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn get_inventory( &self, context: &C) -> Result @@ -2868,99 +2793,6 @@ impl Api for Client where } } - async fn get_order_by_id( - &self, - param_order_id: i64, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/store/order/{order_id}", - self.base_path - ,order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("GET") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 200 => { - let body = response.into_body(); - let body = body - .into_raw() - .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; - - let body = str::from_utf8(&body) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - // ToDo: this will move to swagger-rs and become a standard From conversion trait - // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream - let body = serde_xml_rs::from_str::(body) - .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; - - - Ok(GetOrderByIdResponse::SuccessfulOperation - (body) - ) - } - 400 => { - Ok( - GetOrderByIdResponse::InvalidIDSupplied - ) - } - 404 => { - Ok( - GetOrderByIdResponse::OrderNotFound - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn place_order( &self, param_body: models::Order, @@ -3059,6 +2891,174 @@ impl Api for Client where } } + async fn delete_order( + &self, + param_order_id: String, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/store/order/{order_id}", + self.base_path + ,order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("DELETE") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 400 => { + Ok( + DeleteOrderResponse::InvalidIDSupplied + ) + } + 404 => { + Ok( + DeleteOrderResponse::OrderNotFound + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + + async fn get_order_by_id( + &self, + param_order_id: i64, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/store/order/{order_id}", + self.base_path + ,order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + let body = response.into_body(); + let body = body + .into_raw() + .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; + + let body = str::from_utf8(&body) + .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + // ToDo: this will move to swagger-rs and become a standard From conversion trait + // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream + let body = serde_xml_rs::from_str::(body) + .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; + + + Ok(GetOrderByIdResponse::SuccessfulOperation + (body) + ) + } + 400 => { + Ok( + GetOrderByIdResponse::InvalidIDSupplied + ) + } + 404 => { + Ok( + GetOrderByIdResponse::OrderNotFound + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + async fn create_user( &self, param_body: models::User, @@ -3299,174 +3299,6 @@ impl Api for Client where } } - async fn delete_user( - &self, - param_username: String, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/user/{username}", - self.base_path - ,username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("DELETE") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 400 => { - Ok( - DeleteUserResponse::InvalidUsernameSupplied - ) - } - 404 => { - Ok( - DeleteUserResponse::UserNotFound - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - - async fn get_user_by_name( - &self, - param_username: String, - context: &C) -> Result - { - let mut client_service = self.client_service.clone(); - let mut uri = format!( - "{}/v2/user/{username}", - self.base_path - ,username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET) - ); - - // Query parameters - let query_string = { - let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - query_string.finish() - }; - if !query_string.is_empty() { - uri += "?"; - uri += &query_string; - } - - let uri = match Uri::from_str(&uri) { - Ok(uri) => uri, - Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), - }; - - let mut request = match Request::builder() - .method("GET") - .uri(uri) - .body(Body::empty()) { - Ok(req) => req, - Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) - }; - - let header = HeaderValue::from_str(Has::::get(context).0.as_str()); - request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { - Ok(h) => h, - Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) - }); - - let response = client_service.call((request, context.clone())) - .map_err(|e| ApiError(format!("No response received: {}", e))).await?; - - match response.status().as_u16() { - 200 => { - let body = response.into_body(); - let body = body - .into_raw() - .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; - - let body = str::from_utf8(&body) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - // ToDo: this will move to swagger-rs and become a standard From conversion trait - // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream - let body = serde_xml_rs::from_str::(body) - .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; - - - Ok(GetUserByNameResponse::SuccessfulOperation - (body) - ) - } - 400 => { - Ok( - GetUserByNameResponse::InvalidUsernameSupplied - ) - } - 404 => { - Ok( - GetUserByNameResponse::UserNotFound - ) - } - code => { - let headers = response.headers().clone(); - let body = response.into_body() - .take(100) - .into_raw().await; - Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", - code, - headers, - match body { - Ok(body) => match String::from_utf8(body) { - Ok(body) => body, - Err(e) => format!("", e), - }, - Err(e) => format!("", e), - } - ))) - } - } - } - async fn login_user( &self, param_username: String, @@ -3659,6 +3491,174 @@ impl Api for Client where } } + async fn delete_user( + &self, + param_username: String, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/user/{username}", + self.base_path + ,username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("DELETE") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 400 => { + Ok( + DeleteUserResponse::InvalidUsernameSupplied + ) + } + 404 => { + Ok( + DeleteUserResponse::UserNotFound + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + + async fn get_user_by_name( + &self, + param_username: String, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/v2/user/{username}", + self.base_path + ,username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET) + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + let header = HeaderValue::from_str(Has::::get(context).0.as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + let body = response.into_body(); + let body = body + .into_raw() + .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; + + let body = str::from_utf8(&body) + .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + // ToDo: this will move to swagger-rs and become a standard From conversion trait + // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream + let body = serde_xml_rs::from_str::(body) + .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; + + + Ok(GetUserByNameResponse::SuccessfulOperation + (body) + ) + } + 400 => { + Ok( + GetUserByNameResponse::InvalidUsernameSupplied + ) + } + 404 => { + Ok( + GetUserByNameResponse::UserNotFound + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + async fn update_user( &self, param_username: String, diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index 1e80dc87bb7..93d3dbb0e47 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -67,12 +67,6 @@ pub enum FakeResponseWithNumericalDescriptionResponse { Status200 } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub enum HyphenParamResponse { - /// Success - Success -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestBodyWithQueryParamsResponse { /// Success @@ -118,6 +112,12 @@ pub enum TestJsonFormDataResponse { SuccessfulOperation } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub enum HyphenParamResponse { + /// Success + Success +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestClassnameResponse { /// successful operation @@ -131,12 +131,6 @@ pub enum AddPetResponse { InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub enum DeletePetResponse { - /// Invalid pet value - InvalidPetValue -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum FindPetsByStatusResponse { @@ -159,6 +153,25 @@ pub enum FindPetsByTagsResponse { InvalidTagValue } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[must_use] +pub enum UpdatePetResponse { + /// Invalid ID supplied + InvalidIDSupplied + , + /// Pet not found + PetNotFound + , + /// Validation exception + ValidationException +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub enum DeletePetResponse { + /// Invalid pet value + InvalidPetValue +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum GetPetByIdResponse { @@ -173,19 +186,6 @@ pub enum GetPetByIdResponse { PetNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -#[must_use] -pub enum UpdatePetResponse { - /// Invalid ID supplied - InvalidIDSupplied - , - /// Pet not found - PetNotFound - , - /// Validation exception - ValidationException -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum UpdatePetWithFormResponse { /// Invalid input @@ -199,6 +199,24 @@ pub enum UploadFileResponse { (models::ApiResponse) } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub enum GetInventoryResponse { + /// successful operation + SuccessfulOperation + (std::collections::HashMap) +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[must_use] +pub enum PlaceOrderResponse { + /// successful operation + SuccessfulOperation + (models::Order) + , + /// Invalid Order + InvalidOrder +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum DeleteOrderResponse { @@ -209,13 +227,6 @@ pub enum DeleteOrderResponse { OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub enum GetInventoryResponse { - /// successful operation - SuccessfulOperation - (std::collections::HashMap) -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum GetOrderByIdResponse { @@ -230,17 +241,6 @@ pub enum GetOrderByIdResponse { OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -#[must_use] -pub enum PlaceOrderResponse { - /// successful operation - SuccessfulOperation - (models::Order) - , - /// Invalid Order - InvalidOrder -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateUserResponse { /// successful operation @@ -259,30 +259,6 @@ pub enum CreateUsersWithListInputResponse { SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] -#[must_use] -pub enum DeleteUserResponse { - /// Invalid username supplied - InvalidUsernameSupplied - , - /// User not found - UserNotFound -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -#[must_use] -pub enum GetUserByNameResponse { - /// successful operation - SuccessfulOperation - (models::User) - , - /// Invalid username supplied - InvalidUsernameSupplied - , - /// User not found - UserNotFound -} - #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum LoginUserResponse { @@ -311,6 +287,30 @@ pub enum LogoutUserResponse { SuccessfulOperation } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[must_use] +pub enum DeleteUserResponse { + /// Invalid username supplied + InvalidUsernameSupplied + , + /// User not found + UserNotFound +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[must_use] +pub enum GetUserByNameResponse { + /// successful operation + SuccessfulOperation + (models::User) + , + /// Invalid username supplied + InvalidUsernameSupplied + , + /// User not found + UserNotFound +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum UpdateUserResponse { @@ -363,11 +363,6 @@ pub trait Api { &self, context: &C) -> Result; - async fn hyphen_param( - &self, - hyphen_param: String, - context: &C) -> Result; - async fn test_body_with_query_params( &self, query: String, @@ -424,6 +419,11 @@ pub trait Api { param2: String, context: &C) -> Result; + async fn hyphen_param( + &self, + hyphen_param: String, + context: &C) -> Result; + /// To test class name in snake case async fn test_classname( &self, @@ -436,13 +436,6 @@ pub trait Api { body: models::Pet, context: &C) -> Result; - /// Deletes a pet - async fn delete_pet( - &self, - pet_id: i64, - api_key: Option, - context: &C) -> Result; - /// Finds Pets by status async fn find_pets_by_status( &self, @@ -455,18 +448,25 @@ pub trait Api { tags: &Vec, context: &C) -> Result; - /// Find pet by ID - async fn get_pet_by_id( - &self, - pet_id: i64, - context: &C) -> Result; - /// Update an existing pet async fn update_pet( &self, body: models::Pet, context: &C) -> Result; + /// Deletes a pet + async fn delete_pet( + &self, + pet_id: i64, + api_key: Option, + context: &C) -> Result; + + /// Find pet by ID + async fn get_pet_by_id( + &self, + pet_id: i64, + context: &C) -> Result; + /// Updates a pet in the store with form data async fn update_pet_with_form( &self, @@ -483,29 +483,29 @@ pub trait Api { file: Option, context: &C) -> Result; - /// Delete purchase order by ID - async fn delete_order( - &self, - order_id: String, - context: &C) -> Result; - /// Returns pet inventories by status async fn get_inventory( &self, context: &C) -> Result; - /// Find purchase order by ID - async fn get_order_by_id( - &self, - order_id: i64, - context: &C) -> Result; - /// Place an order for a pet async fn place_order( &self, body: models::Order, context: &C) -> Result; + /// Delete purchase order by ID + async fn delete_order( + &self, + order_id: String, + context: &C) -> Result; + + /// Find purchase order by ID + async fn get_order_by_id( + &self, + order_id: i64, + context: &C) -> Result; + /// Create user async fn create_user( &self, @@ -524,18 +524,6 @@ pub trait Api { body: &Vec, context: &C) -> Result; - /// Delete user - async fn delete_user( - &self, - username: String, - context: &C) -> Result; - - /// Get user by user name - async fn get_user_by_name( - &self, - username: String, - context: &C) -> Result; - /// Logs user into the system async fn login_user( &self, @@ -548,6 +536,18 @@ pub trait Api { &self, context: &C) -> Result; + /// Delete user + async fn delete_user( + &self, + username: String, + context: &C) -> Result; + + /// Get user by user name + async fn get_user_by_name( + &self, + username: String, + context: &C) -> Result; + /// Updated user async fn update_user( &self, @@ -600,11 +600,6 @@ pub trait ApiNoContext { &self, ) -> Result; - async fn hyphen_param( - &self, - hyphen_param: String, - ) -> Result; - async fn test_body_with_query_params( &self, query: String, @@ -661,6 +656,11 @@ pub trait ApiNoContext { param2: String, ) -> Result; + async fn hyphen_param( + &self, + hyphen_param: String, + ) -> Result; + /// To test class name in snake case async fn test_classname( &self, @@ -673,13 +673,6 @@ pub trait ApiNoContext { body: models::Pet, ) -> Result; - /// Deletes a pet - async fn delete_pet( - &self, - pet_id: i64, - api_key: Option, - ) -> Result; - /// Finds Pets by status async fn find_pets_by_status( &self, @@ -692,18 +685,25 @@ pub trait ApiNoContext { tags: &Vec, ) -> Result; - /// Find pet by ID - async fn get_pet_by_id( - &self, - pet_id: i64, - ) -> Result; - /// Update an existing pet async fn update_pet( &self, body: models::Pet, ) -> Result; + /// Deletes a pet + async fn delete_pet( + &self, + pet_id: i64, + api_key: Option, + ) -> Result; + + /// Find pet by ID + async fn get_pet_by_id( + &self, + pet_id: i64, + ) -> Result; + /// Updates a pet in the store with form data async fn update_pet_with_form( &self, @@ -720,29 +720,29 @@ pub trait ApiNoContext { file: Option, ) -> Result; - /// Delete purchase order by ID - async fn delete_order( - &self, - order_id: String, - ) -> Result; - /// Returns pet inventories by status async fn get_inventory( &self, ) -> Result; - /// Find purchase order by ID - async fn get_order_by_id( - &self, - order_id: i64, - ) -> Result; - /// Place an order for a pet async fn place_order( &self, body: models::Order, ) -> Result; + /// Delete purchase order by ID + async fn delete_order( + &self, + order_id: String, + ) -> Result; + + /// Find purchase order by ID + async fn get_order_by_id( + &self, + order_id: i64, + ) -> Result; + /// Create user async fn create_user( &self, @@ -761,18 +761,6 @@ pub trait ApiNoContext { body: &Vec, ) -> Result; - /// Delete user - async fn delete_user( - &self, - username: String, - ) -> Result; - - /// Get user by user name - async fn get_user_by_name( - &self, - username: String, - ) -> Result; - /// Logs user into the system async fn login_user( &self, @@ -785,6 +773,18 @@ pub trait ApiNoContext { &self, ) -> Result; + /// Delete user + async fn delete_user( + &self, + username: String, + ) -> Result; + + /// Get user by user name + async fn get_user_by_name( + &self, + username: String, + ) -> Result; + /// Updated user async fn update_user( &self, @@ -879,15 +879,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().fake_response_with_numerical_description(&context).await } - async fn hyphen_param( - &self, - hyphen_param: String, - ) -> Result - { - let context = self.context().clone(); - self.api().hyphen_param(hyphen_param, &context).await - } - async fn test_body_with_query_params( &self, query: String, @@ -968,6 +959,15 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().test_json_form_data(param, param2, &context).await } + async fn hyphen_param( + &self, + hyphen_param: String, + ) -> Result + { + let context = self.context().clone(); + self.api().hyphen_param(hyphen_param, &context).await + } + /// To test class name in snake case async fn test_classname( &self, @@ -988,17 +988,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().add_pet(body, &context).await } - /// Deletes a pet - async fn delete_pet( - &self, - pet_id: i64, - api_key: Option, - ) -> Result - { - let context = self.context().clone(); - self.api().delete_pet(pet_id, api_key, &context).await - } - /// Finds Pets by status async fn find_pets_by_status( &self, @@ -1019,16 +1008,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().find_pets_by_tags(tags, &context).await } - /// Find pet by ID - async fn get_pet_by_id( - &self, - pet_id: i64, - ) -> Result - { - let context = self.context().clone(); - self.api().get_pet_by_id(pet_id, &context).await - } - /// Update an existing pet async fn update_pet( &self, @@ -1039,6 +1018,27 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().update_pet(body, &context).await } + /// Deletes a pet + async fn delete_pet( + &self, + pet_id: i64, + api_key: Option, + ) -> Result + { + let context = self.context().clone(); + self.api().delete_pet(pet_id, api_key, &context).await + } + + /// Find pet by ID + async fn get_pet_by_id( + &self, + pet_id: i64, + ) -> Result + { + let context = self.context().clone(); + self.api().get_pet_by_id(pet_id, &context).await + } + /// Updates a pet in the store with form data async fn update_pet_with_form( &self, @@ -1063,16 +1063,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().upload_file(pet_id, additional_metadata, file, &context).await } - /// Delete purchase order by ID - async fn delete_order( - &self, - order_id: String, - ) -> Result - { - let context = self.context().clone(); - self.api().delete_order(order_id, &context).await - } - /// Returns pet inventories by status async fn get_inventory( &self, @@ -1082,16 +1072,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().get_inventory(&context).await } - /// Find purchase order by ID - async fn get_order_by_id( - &self, - order_id: i64, - ) -> Result - { - let context = self.context().clone(); - self.api().get_order_by_id(order_id, &context).await - } - /// Place an order for a pet async fn place_order( &self, @@ -1102,6 +1082,26 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().place_order(body, &context).await } + /// Delete purchase order by ID + async fn delete_order( + &self, + order_id: String, + ) -> Result + { + let context = self.context().clone(); + self.api().delete_order(order_id, &context).await + } + + /// Find purchase order by ID + async fn get_order_by_id( + &self, + order_id: i64, + ) -> Result + { + let context = self.context().clone(); + self.api().get_order_by_id(order_id, &context).await + } + /// Create user async fn create_user( &self, @@ -1132,26 +1132,6 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().create_users_with_list_input(body, &context).await } - /// Delete user - async fn delete_user( - &self, - username: String, - ) -> Result - { - let context = self.context().clone(); - self.api().delete_user(username, &context).await - } - - /// Get user by user name - async fn get_user_by_name( - &self, - username: String, - ) -> Result - { - let context = self.context().clone(); - self.api().get_user_by_name(username, &context).await - } - /// Logs user into the system async fn login_user( &self, @@ -1172,6 +1152,26 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex self.api().logout_user(&context).await } + /// Delete user + async fn delete_user( + &self, + username: String, + ) -> Result + { + let context = self.context().clone(); + self.api().delete_user(username, &context).await + } + + /// Get user by user name + async fn get_user_by_name( + &self, + username: String, + ) -> Result + { + let context = self.context().clone(); + self.api().get_user_by_name(username, &context).await + } + /// Updated user async fn update_user( &self, diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 95092bccc4a..1de6df73bc7 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -30,33 +30,33 @@ use crate::{Api, FakeOuterNumberSerializeResponse, FakeOuterStringSerializeResponse, FakeResponseWithNumericalDescriptionResponse, - HyphenParamResponse, TestBodyWithQueryParamsResponse, TestClientModelResponse, TestEndpointParametersResponse, TestEnumParametersResponse, TestInlineAdditionalPropertiesResponse, TestJsonFormDataResponse, + HyphenParamResponse, TestClassnameResponse, AddPetResponse, - DeletePetResponse, FindPetsByStatusResponse, FindPetsByTagsResponse, - GetPetByIdResponse, UpdatePetResponse, + DeletePetResponse, + GetPetByIdResponse, UpdatePetWithFormResponse, UploadFileResponse, - DeleteOrderResponse, GetInventoryResponse, - GetOrderByIdResponse, PlaceOrderResponse, + DeleteOrderResponse, + GetOrderByIdResponse, CreateUserResponse, CreateUsersWithArrayInputResponse, CreateUsersWithListInputResponse, - DeleteUserResponse, - GetUserByNameResponse, LoginUserResponse, LogoutUserResponse, + DeleteUserResponse, + GetUserByNameResponse, UpdateUserResponse }; @@ -720,60 +720,6 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(response) }, - // HyphenParam - GET /fake/hyphenParam/{hyphen-param} - hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE FAKE_HYPHENPARAM_HYPHEN_PARAM in set but failed match against \"{}\"", path, paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM.as_str()) - ); - - let param_hyphen_param = match percent_encoding::percent_decode(path_params["hyphen-param"].as_bytes()).decode_utf8() { - Ok(param_hyphen_param) => match param_hyphen_param.parse::() { - Ok(param_hyphen_param) => param_hyphen_param, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter hyphen-param: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["hyphen-param"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.hyphen_param( - param_hyphen_param, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - HyphenParamResponse::Success - => { - *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // TestBodyWithQueryParams - PUT /fake/body-with-query-params hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) @@ -1344,6 +1290,60 @@ impl hyper::service::Service<(Request, C)> for Service where } }, + // HyphenParam - GET /fake/hyphenParam/{hyphen-param} + hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE FAKE_HYPHENPARAM_HYPHEN_PARAM in set but failed match against \"{}\"", path, paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM.as_str()) + ); + + let param_hyphen_param = match percent_encoding::percent_decode(path_params["hyphen-param"].as_bytes()).decode_utf8() { + Ok(param_hyphen_param) => match param_hyphen_param.parse::() { + Ok(param_hyphen_param) => param_hyphen_param, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter hyphen-param: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["hyphen-param"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.hyphen_param( + param_hyphen_param, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + HyphenParamResponse::Success + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + // TestClassname - PATCH /fake_classname_test hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => { { @@ -1540,111 +1540,6 @@ impl hyper::service::Service<(Request, C)> for Service where } }, - // DeletePet - DELETE /pet/{petId} - hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => { - { - let authorization = match *(&context as &dyn Has>).get() { - Some(ref authorization) => authorization, - None => return Ok(Response::builder() - .status(StatusCode::FORBIDDEN) - .body(Body::from("Unauthenticated")) - .expect("Unable to create Authentication Forbidden response")), - }; - - // Authorization - if let Scopes::Some(ref scopes) = authorization.scopes { - let required_scopes: std::collections::BTreeSet = vec![ - "write:pets".to_string(), // modify pets in your account - "read:pets".to_string(), // read your pets - ].into_iter().collect(); - - if !required_scopes.is_subset(scopes) { - let missing_scopes = required_scopes.difference(scopes); - return Ok(Response::builder() - .status(StatusCode::FORBIDDEN) - .body(Body::from(missing_scopes.fold( - "Insufficient authorization, missing scopes".to_string(), - |s, scope| format!("{} {}", s, scope)) - )) - .expect("Unable to create Authentication Insufficient response") - ); - } - } - } - - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_PET_PETID - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) - ); - - let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() { - Ok(param_pet_id) => match param_pet_id.parse::() { - Ok(param_pet_id) => param_pet_id, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter petId: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - // Header parameters - let param_api_key = headers.get(HeaderName::from_static("api_key")); - - let param_api_key = match param_api_key { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { - Ok(result) => - Some(result.0), - Err(err) => { - return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Invalid header api_key - {}", err))) - .expect("Unable to create Bad Request response for invalid header api_key")); - - }, - }, - None => { - None - } - }; - - let result = api_impl.delete_pet( - param_pet_id, - param_api_key, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - DeletePetResponse::InvalidPetValue - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // FindPetsByStatus - GET /pet/findByStatus hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => { { @@ -1805,88 +1700,6 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(response) }, - // GetPetById - GET /pet/{petId} - hyper::Method::GET if path.matched(paths::ID_PET_PETID) => { - { - let authorization = match *(&context as &dyn Has>).get() { - Some(ref authorization) => authorization, - None => return Ok(Response::builder() - .status(StatusCode::FORBIDDEN) - .body(Body::from("Unauthenticated")) - .expect("Unable to create Authentication Forbidden response")), - }; - } - - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_PET_PETID - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) - ); - - let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() { - Ok(param_pet_id) => match param_pet_id.parse::() { - Ok(param_pet_id) => param_pet_id, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter petId: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.get_pet_by_id( - param_pet_id, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - GetPetByIdResponse::SuccessfulOperation - (body) - => { - *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); - response.headers_mut().insert( - CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); - // XML Body - let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); - - }, - GetPetByIdResponse::InvalidIDSupplied - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - GetPetByIdResponse::PetNotFound - => { - *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // UpdatePet - PUT /pet hyper::Method::PUT if path.matched(paths::ID_PET) => { { @@ -2001,6 +1814,193 @@ impl hyper::service::Service<(Request, C)> for Service where } }, + // DeletePet - DELETE /pet/{petId} + hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => { + { + let authorization = match *(&context as &dyn Has>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(Body::from("Unauthenticated")) + .expect("Unable to create Authentication Forbidden response")), + }; + + // Authorization + if let Scopes::Some(ref scopes) = authorization.scopes { + let required_scopes: std::collections::BTreeSet = vec![ + "write:pets".to_string(), // modify pets in your account + "read:pets".to_string(), // read your pets + ].into_iter().collect(); + + if !required_scopes.is_subset(scopes) { + let missing_scopes = required_scopes.difference(scopes); + return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(Body::from(missing_scopes.fold( + "Insufficient authorization, missing scopes".to_string(), + |s, scope| format!("{} {}", s, scope)) + )) + .expect("Unable to create Authentication Insufficient response") + ); + } + } + } + + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_PET_PETID + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) + ); + + let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() { + Ok(param_pet_id) => match param_pet_id.parse::() { + Ok(param_pet_id) => param_pet_id, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter petId: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + // Header parameters + let param_api_key = headers.get(HeaderName::from_static("api_key")); + + let param_api_key = match param_api_key { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Ok(result) => + Some(result.0), + Err(err) => { + return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header api_key - {}", err))) + .expect("Unable to create Bad Request response for invalid header api_key")); + + }, + }, + None => { + None + } + }; + + let result = api_impl.delete_pet( + param_pet_id, + param_api_key, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + DeletePetResponse::InvalidPetValue + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // GetPetById - GET /pet/{petId} + hyper::Method::GET if path.matched(paths::ID_PET_PETID) => { + { + let authorization = match *(&context as &dyn Has>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(Body::from("Unauthenticated")) + .expect("Unable to create Authentication Forbidden response")), + }; + } + + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_PET_PETID + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) + ); + + let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() { + Ok(param_pet_id) => match param_pet_id.parse::() { + Ok(param_pet_id) => param_pet_id, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter petId: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.get_pet_by_id( + param_pet_id, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + GetPetByIdResponse::SuccessfulOperation + (body) + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + response.headers_mut().insert( + CONTENT_TYPE, + HeaderValue::from_str("application/xml") + .expect("Unable to create Content-Type header for application/xml")); + // XML Body + let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body); + + }, + GetPetByIdResponse::InvalidIDSupplied + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + GetPetByIdResponse::PetNotFound + => { + *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + // UpdatePetWithForm - POST /pet/{petId} hyper::Method::POST if path.matched(paths::ID_PET_PETID) => { { @@ -2312,65 +2312,6 @@ impl hyper::service::Service<(Request, C)> for Service where } }, - // DeleteOrder - DELETE /store/order/{order_id} - hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_STORE_ORDER_ORDER_ID - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) - ); - - let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() { - Ok(param_order_id) => match param_order_id.parse::() { - Ok(param_order_id) => param_order_id, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter order_id: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.delete_order( - param_order_id, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - DeleteOrderResponse::InvalidIDSupplied - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - DeleteOrderResponse::OrderNotFound - => { - *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // GetInventory - GET /store/inventory hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => { { @@ -2419,78 +2360,6 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(response) }, - // GetOrderById - GET /store/order/{order_id} - hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_STORE_ORDER_ORDER_ID - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) - ); - - let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() { - Ok(param_order_id) => match param_order_id.parse::() { - Ok(param_order_id) => param_order_id, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter order_id: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.get_order_by_id( - param_order_id, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - GetOrderByIdResponse::SuccessfulOperation - (body) - => { - *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); - response.headers_mut().insert( - CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); - // XML Body - let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); - - }, - GetOrderByIdResponse::InvalidIDSupplied - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - GetOrderByIdResponse::OrderNotFound - => { - *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // PlaceOrder - POST /store/order hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => { // Handle body parameters (note that non-required body parameters will ignore garbage @@ -2578,6 +2447,137 @@ impl hyper::service::Service<(Request, C)> for Service where } }, + // DeleteOrder - DELETE /store/order/{order_id} + hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_STORE_ORDER_ORDER_ID + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) + ); + + let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() { + Ok(param_order_id) => match param_order_id.parse::() { + Ok(param_order_id) => param_order_id, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter order_id: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.delete_order( + param_order_id, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + DeleteOrderResponse::InvalidIDSupplied + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + DeleteOrderResponse::OrderNotFound + => { + *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // GetOrderById - GET /store/order/{order_id} + hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_STORE_ORDER_ORDER_ID + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) + ); + + let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() { + Ok(param_order_id) => match param_order_id.parse::() { + Ok(param_order_id) => param_order_id, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter order_id: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.get_order_by_id( + param_order_id, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + GetOrderByIdResponse::SuccessfulOperation + (body) + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + response.headers_mut().insert( + CONTENT_TYPE, + HeaderValue::from_str("application/xml") + .expect("Unable to create Content-Type header for application/xml")); + // XML Body + let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body); + + }, + GetOrderByIdResponse::InvalidIDSupplied + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + GetOrderByIdResponse::OrderNotFound + => { + *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + // CreateUser - POST /user hyper::Method::POST if path.matched(paths::ID_USER) => { // Handle body parameters (note that non-required body parameters will ignore garbage @@ -2800,137 +2800,6 @@ impl hyper::service::Service<(Request, C)> for Service where } }, - // DeleteUser - DELETE /user/{username} - hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_USER_USERNAME - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) - ); - - let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() { - Ok(param_username) => match param_username.parse::() { - Ok(param_username) => param_username, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter username: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.delete_user( - param_username, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - DeleteUserResponse::InvalidUsernameSupplied - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - DeleteUserResponse::UserNotFound - => { - *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - - // GetUserByName - GET /user/{username} - hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => { - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_USER_USERNAME - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) - ); - - let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() { - Ok(param_username) => match param_username.parse::() { - Ok(param_username) => param_username, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't parse path parameter username: {}", e))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - - let result = api_impl.get_user_by_name( - param_username, - &context - ).await; - let mut response = Response::new(Body::empty()); - response.headers_mut().insert( - HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) - .expect("Unable to create X-Span-ID header value")); - - match result { - Ok(rsp) => match rsp { - GetUserByNameResponse::SuccessfulOperation - (body) - => { - *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); - response.headers_mut().insert( - CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); - // XML Body - let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); - - }, - GetUserByNameResponse::InvalidUsernameSupplied - => { - *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); - - }, - GetUserByNameResponse::UserNotFound - => { - *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); - - }, - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - *response.body_mut() = Body::from("An internal error occurred"); - }, - } - - Ok(response) - }, - // LoginUser - GET /user/login hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) @@ -3095,6 +2964,137 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(response) }, + // DeleteUser - DELETE /user/{username} + hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_USER_USERNAME + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) + ); + + let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() { + Ok(param_username) => match param_username.parse::() { + Ok(param_username) => param_username, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter username: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.delete_user( + param_username, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + DeleteUserResponse::InvalidUsernameSupplied + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + DeleteUserResponse::UserNotFound + => { + *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // GetUserByName - GET /user/{username} + hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => { + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_USER_USERNAME + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) + ); + + let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() { + Ok(param_username) => match param_username.parse::() { + Ok(param_username) => param_username, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't parse path parameter username: {}", e))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + + let result = api_impl.get_user_by_name( + param_username, + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + GetUserByNameResponse::SuccessfulOperation + (body) + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + response.headers_mut().insert( + CONTENT_TYPE, + HeaderValue::from_str("application/xml") + .expect("Unable to create Content-Type header for application/xml")); + // XML Body + let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body); + + }, + GetUserByNameResponse::InvalidUsernameSupplied + => { + *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode"); + + }, + GetUserByNameResponse::UserNotFound + => { + *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); + + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + // UpdateUser - PUT /user/{username} hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => { // Path parameters @@ -3258,8 +3258,6 @@ impl RequestParser for ApiRequestParser { hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => Some("FakeOuterStringSerialize"), // FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => Some("FakeResponseWithNumericalDescription"), - // HyphenParam - GET /fake/hyphenParam/{hyphen-param} - hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"), // TestBodyWithQueryParams - PUT /fake/body-with-query-params hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Some("TestBodyWithQueryParams"), // TestClientModel - PATCH /fake @@ -3272,46 +3270,48 @@ impl RequestParser for ApiRequestParser { hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Some("TestInlineAdditionalProperties"), // TestJsonFormData - GET /fake/jsonFormData hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => Some("TestJsonFormData"), + // HyphenParam - GET /fake/hyphenParam/{hyphen-param} + hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"), // TestClassname - PATCH /fake_classname_test hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Some("TestClassname"), // AddPet - POST /pet hyper::Method::POST if path.matched(paths::ID_PET) => Some("AddPet"), - // DeletePet - DELETE /pet/{petId} - hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"), // FindPetsByStatus - GET /pet/findByStatus hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => Some("FindPetsByStatus"), // FindPetsByTags - GET /pet/findByTags hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => Some("FindPetsByTags"), - // GetPetById - GET /pet/{petId} - hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"), // UpdatePet - PUT /pet hyper::Method::PUT if path.matched(paths::ID_PET) => Some("UpdatePet"), + // DeletePet - DELETE /pet/{petId} + hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"), + // GetPetById - GET /pet/{petId} + hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"), // UpdatePetWithForm - POST /pet/{petId} hyper::Method::POST if path.matched(paths::ID_PET_PETID) => Some("UpdatePetWithForm"), // UploadFile - POST /pet/{petId}/uploadImage hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Some("UploadFile"), - // DeleteOrder - DELETE /store/order/{order_id} - hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"), // GetInventory - GET /store/inventory hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => Some("GetInventory"), - // GetOrderById - GET /store/order/{order_id} - hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"), // PlaceOrder - POST /store/order hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => Some("PlaceOrder"), + // DeleteOrder - DELETE /store/order/{order_id} + hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"), + // GetOrderById - GET /store/order/{order_id} + hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"), // CreateUser - POST /user hyper::Method::POST if path.matched(paths::ID_USER) => Some("CreateUser"), // CreateUsersWithArrayInput - POST /user/createWithArray hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => Some("CreateUsersWithArrayInput"), // CreateUsersWithListInput - POST /user/createWithList hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => Some("CreateUsersWithListInput"), - // DeleteUser - DELETE /user/{username} - hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"), - // GetUserByName - GET /user/{username} - hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"), // LoginUser - GET /user/login hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => Some("LoginUser"), // LogoutUser - GET /user/logout hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => Some("LogoutUser"), + // DeleteUser - DELETE /user/{username} + hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"), + // GetUserByName - GET /user/{username} + hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"), // UpdateUser - PUT /user/{username} hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => Some("UpdateUser"), _ => None,