From c5e170961fb433569680c8074375f367fbd1050f Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Thu, 19 Jul 2018 11:03:02 +0100 Subject: [PATCH] [rust-server] enhance support for middlewares (#552) * Generate RequestParser trait to allow retrieving operation ID in middlewares * Update function name * Fix incomplete comment * Add comment poitning out auotgenerated duplication * Final generation of sample scripts * MMORCH-913 - Allow passing wrapped hyper clients to codegen * Deprecate old API for back-compatibility rather than removing it * Actually test Rust-server example integrations --- .../resources/rust-server/client-mod.mustache | 73 +++++++--- .../resources/rust-server/server-mod.mustache | 20 ++- samples/server/petstore/rust-server/pom.xml | 16 ++- .../petstore/rust-server/src/client/mod.rs | 133 +++++++++++------- .../petstore/rust-server/src/server/mod.rs | 113 ++++++++++++++- 5 files changed, 282 insertions(+), 73 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache index 70e5b333a32..0e78e327394 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache @@ -65,26 +65,37 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, +pub struct Client where + F: Future + 'static { + client_service: Arc, Response=hyper::Response, Error=hyper::Error, Future=F>>>, base_path: String, } -impl fmt::Debug for Client { +impl fmt::Debug for Client where + F: Future + 'static { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Client {{ base_path: {} }}", self.base_path) } } -impl Client { +impl Clone for Client where + F: Future + 'static { + fn clone(&self) -> Self { + Client { + client_service: self.client_service.clone(), + base_path: self.base_path.clone() + } + } +} + +impl Client { /// Create an HTTP client. /// /// # Arguments /// * `handle` - tokio reactor handle to use for execution /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" - pub fn try_new_http(handle: Handle, base_path: &str) -> Result { + pub fn try_new_http(handle: Handle, base_path: &str) -> Result, ClientInitError> { let http_connector = swagger::http_connector(); Self::try_new_with_connector::( handle, @@ -104,7 +115,7 @@ impl Client { handle: Handle, base_path: &str, ca_certificate: CA, - ) -> Result + ) -> Result, ClientInitError> where CA: AsRef, { @@ -125,13 +136,13 @@ impl Client { /// * `ca_certificate` - Path to CA certificate used to authenticate the server /// * `client_key` - Path to the client private key /// * `client_certificate` - Path to the client's public certificate associated with the private key - pub fn try_new_https_mutual( + pub fn try_new_https_mutual( handle: Handle, base_path: &str, ca_certificate: CA, client_key: K, client_certificate: C, - ) -> Result + ) -> Result, ClientInitError> where CA: AsRef, K: AsRef, @@ -168,17 +179,17 @@ impl Client { base_path: &str, protocol: Option<&'static str>, connector_fn: Box C + Send + Sync>, - ) -> Result + ) -> Result, ClientInitError> where C: hyper::client::Connect + hyper::client::Service, { let connector = connector_fn(&handle); - let hyper_client = Box::new(hyper::Client::configure().connector(connector).build( + let client_service = Box::new(hyper::Client::configure().connector(connector).build( &handle, )); Ok(Client { - hyper_client: Arc::new(hyper_client), + client_service: Arc::new(client_service), base_path: into_base_path(base_path, protocol)?, }) } @@ -192,19 +203,41 @@ impl Client { /// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer. /// This is not a recommended way to write new tests. If other reasons are found for using this function, they /// should be mentioned here. - pub fn try_new_with_hyper_client(hyper_client: Arc, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, - handle: Handle, - base_path: &str) - -> Result + #[deprecated(note="Use try_new_with_client_service instead")] + pub fn try_new_with_hyper_client( + hyper_client: Arc, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, + handle: Handle, + base_path: &str + ) -> Result, ClientInitError> { Ok(Client { - hyper_client: hyper_client, + client_service: hyper_client, base_path: into_base_path(base_path, None)?, }) } } -impl Api for Client where C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}}{ +impl Client where + F: Future + 'static +{ + /// Constructor for creating a `Client` by passing in a pre-made `hyper` client Service. + /// + /// This allows adding custom wrappers around the underlying transport, for example for logging. + pub fn try_new_with_client_service(client_service: Arc, Response=hyper::Response, Error=hyper::Error, Future=F>>>, + handle: Handle, + base_path: &str) + -> Result, ClientInitError> + { + Ok(Client { + client_service: client_service, + base_path: into_base_path(base_path, None)?, + }) + } +} + +impl Api for Client where + F: Future + 'static, + C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}}{ {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} fn {{#vendorExtensions}}{{operation_id}}{{/vendorExtensions}}(&self{{#allParams}}, param_{{paramName}}: {{^required}}{{#isFile}}Box{{#isFile}}, Error=Error> + Send>{{/isFile}}{{/required}}{{/allParams}}, context: &C) -> Box> { {{#queryParams}}{{#-first}} @@ -312,13 +345,13 @@ impl Api for Client where C: Has {{#hasAuthMethods}}+ Has { -{{#headers}} header! { (Response{{nameInCamelCase}}, "{{baseName}}") => [{{{dataType}}}] } +{{#headers}} header! { (Response{{nameInCamelCase}}, "{{baseName}}") => [{{{datatype}}}] } let response_{{name}} = match response.headers().get::() { Some(response_{{name}}) => response_{{name}}.0.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header {{baseName}} for response {{code}} was not found.")))) as Box>, diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache index 70c07a2e980..a32d7031e0f 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache @@ -36,7 +36,7 @@ use std::io; use std::collections::BTreeSet; pub use swagger::auth::Authorization; -use swagger::{ApiError, XSpanId, XSpanIdString, Has}; +use swagger::{ApiError, XSpanId, XSpanIdString, Has, RequestParser}; use swagger::auth::Scopes; use {Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}, @@ -127,6 +127,9 @@ where let api_impl = self.api_impl.clone(); let (method, uri, _, headers, body) = req.deconstruct(); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); + + // This match statement is duplicated below in `parse_operation_id()`. + // Please update both places if changing how this code is autogenerated. match &method { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} // {{operationId}} - {{httpMethod}} {{path}} @@ -462,3 +465,18 @@ fn multipart_boundary<'a>(headers: &'a Headers) -> Option<&'a str> { }) } {{/apiHasFile}} + +/// Request parser for `Api`. +pub struct ApiRequestParser; + +impl RequestParser for ApiRequestParser { + fn parse_operation_id(request: &Request) -> Result<&'static str, ()> { + let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); + match request.method() { +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} + // {{operationId}} - {{httpMethod}} {{path}} + &hyper::Method::{{vendorExtensions.HttpMethod}} if path.matched(paths::ID_{{vendorExtensions.PATH_ID}}) => Ok("{{operationId}}"), +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} _ => Err(()), + } + } +} diff --git a/samples/server/petstore/rust-server/pom.xml b/samples/server/petstore/rust-server/pom.xml index 6255746d0ef..eeefcb808a5 100644 --- a/samples/server/petstore/rust-server/pom.xml +++ b/samples/server/petstore/rust-server/pom.xml @@ -27,7 +27,21 @@ 1.2.1 - bundle-test + build + integration-test + + exec + + + cargo + + build + --examples + + + + + test integration-test exec diff --git a/samples/server/petstore/rust-server/src/client/mod.rs b/samples/server/petstore/rust-server/src/client/mod.rs index 798313d573d..587837a9bd1 100644 --- a/samples/server/petstore/rust-server/src/client/mod.rs +++ b/samples/server/petstore/rust-server/src/client/mod.rs @@ -96,26 +96,37 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, +pub struct Client where + F: Future + 'static { + client_service: Arc, Response=hyper::Response, Error=hyper::Error, Future=F>>>, base_path: String, } -impl fmt::Debug for Client { +impl fmt::Debug for Client where + F: Future + 'static { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Client {{ base_path: {} }}", self.base_path) } } -impl Client { +impl Clone for Client where + F: Future + 'static { + fn clone(&self) -> Self { + Client { + client_service: self.client_service.clone(), + base_path: self.base_path.clone() + } + } +} + +impl Client { /// Create an HTTP client. /// /// # Arguments /// * `handle` - tokio reactor handle to use for execution /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" - pub fn try_new_http(handle: Handle, base_path: &str) -> Result { + pub fn try_new_http(handle: Handle, base_path: &str) -> Result, ClientInitError> { let http_connector = swagger::http_connector(); Self::try_new_with_connector::( handle, @@ -135,7 +146,7 @@ impl Client { handle: Handle, base_path: &str, ca_certificate: CA, - ) -> Result + ) -> Result, ClientInitError> where CA: AsRef, { @@ -156,13 +167,13 @@ impl Client { /// * `ca_certificate` - Path to CA certificate used to authenticate the server /// * `client_key` - Path to the client private key /// * `client_certificate` - Path to the client's public certificate associated with the private key - pub fn try_new_https_mutual( + pub fn try_new_https_mutual( handle: Handle, base_path: &str, ca_certificate: CA, client_key: K, client_certificate: C, - ) -> Result + ) -> Result, ClientInitError> where CA: AsRef, K: AsRef, @@ -199,17 +210,17 @@ impl Client { base_path: &str, protocol: Option<&'static str>, connector_fn: Box C + Send + Sync>, - ) -> Result + ) -> Result, ClientInitError> where C: hyper::client::Connect + hyper::client::Service, { let connector = connector_fn(&handle); - let hyper_client = Box::new(hyper::Client::configure().connector(connector).build( + let client_service = Box::new(hyper::Client::configure().connector(connector).build( &handle, )); Ok(Client { - hyper_client: Arc::new(hyper_client), + client_service: Arc::new(client_service), base_path: into_base_path(base_path, protocol)?, }) } @@ -223,19 +234,41 @@ impl Client { /// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer. /// This is not a recommended way to write new tests. If other reasons are found for using this function, they /// should be mentioned here. - pub fn try_new_with_hyper_client(hyper_client: Arc, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, - handle: Handle, - base_path: &str) - -> Result + #[deprecated(note="Use try_new_with_client_service instead")] + pub fn try_new_with_hyper_client( + hyper_client: Arc, Response=hyper::Response, Error=hyper::Error, Future=hyper::client::FutureResponse>>>, + handle: Handle, + base_path: &str + ) -> Result, ClientInitError> { Ok(Client { - hyper_client: hyper_client, + client_service: hyper_client, base_path: into_base_path(base_path, None)?, }) } } -impl Api for Client where C: Has + Has>{ +impl Client where + F: Future + 'static +{ + /// Constructor for creating a `Client` by passing in a pre-made `hyper` client Service. + /// + /// This allows adding custom wrappers around the underlying transport, for example for logging. + pub fn try_new_with_client_service(client_service: Arc, Response=hyper::Response, Error=hyper::Error, Future=F>>>, + handle: Handle, + base_path: &str) + -> Result, ClientInitError> + { + Ok(Client { + client_service: client_service, + base_path: into_base_path(base_path, None)?, + }) + } +} + +impl Api for Client where + F: Future + 'static, + C: Has + Has>{ fn test_special_tags(&self, param_client: models::Client, context: &C) -> Box> { @@ -267,7 +300,7 @@ impl Api for Client where C: Has + Has>{ - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -347,7 +380,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -425,7 +458,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -503,7 +536,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -581,7 +614,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -661,7 +694,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -726,7 +759,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -839,7 +872,7 @@ if let Some(body) = body { request.set_body(body_string.into_bytes()); - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -923,7 +956,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -997,7 +1030,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1063,7 +1096,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1130,7 +1163,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1208,7 +1241,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1271,7 +1304,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1334,7 +1367,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1419,7 +1452,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1500,7 +1533,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1596,7 +1629,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1680,7 +1713,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1776,7 +1809,7 @@ if let Some(body) = body { request.set_body(body_string.into_bytes()); - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1846,7 +1879,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1914,7 +1947,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -1984,7 +2017,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2080,7 +2113,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2169,7 +2202,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2234,7 +2267,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2299,7 +2332,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2358,7 +2391,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2426,7 +2459,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2522,7 +2555,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2613,7 +2646,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { @@ -2678,7 +2711,7 @@ if let Some(body) = body { - Box::new(self.hyper_client.call(request) + Box::new(self.client_service.call(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { diff --git a/samples/server/petstore/rust-server/src/server/mod.rs b/samples/server/petstore/rust-server/src/server/mod.rs index a71a4ded43d..a0142c41520 100644 --- a/samples/server/petstore/rust-server/src/server/mod.rs +++ b/samples/server/petstore/rust-server/src/server/mod.rs @@ -36,7 +36,7 @@ use std::io; use std::collections::BTreeSet; pub use swagger::auth::Authorization; -use swagger::{ApiError, XSpanId, XSpanIdString, Has}; +use swagger::{ApiError, XSpanId, XSpanIdString, Has, RequestParser}; use swagger::auth::Scopes; use {Api, @@ -207,6 +207,9 @@ where let api_impl = self.api_impl.clone(); let (method, uri, _, headers, body) = req.deconstruct(); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); + + // This match statement is duplicated below in `parse_operation_id()`. + // Please update both places if changing how this code is autogenerated. match &method { // TestSpecialTags - PATCH /another-fake/dummy @@ -3149,3 +3152,111 @@ fn multipart_boundary<'a>(headers: &'a Headers) -> Option<&'a str> { } }) } + +/// Request parser for `Api`. +pub struct ApiRequestParser; + +impl RequestParser for ApiRequestParser { + fn parse_operation_id(request: &Request) -> Result<&'static str, ()> { + let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); + match request.method() { + + // TestSpecialTags - PATCH /another-fake/dummy + &hyper::Method::Patch if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => Ok("TestSpecialTags"), + + // FakeOuterBooleanSerialize - POST /fake/outer/boolean + &hyper::Method::Post if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => Ok("FakeOuterBooleanSerialize"), + + // FakeOuterCompositeSerialize - POST /fake/outer/composite + &hyper::Method::Post if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => Ok("FakeOuterCompositeSerialize"), + + // FakeOuterNumberSerialize - POST /fake/outer/number + &hyper::Method::Post if path.matched(paths::ID_FAKE_OUTER_NUMBER) => Ok("FakeOuterNumberSerialize"), + + // FakeOuterStringSerialize - POST /fake/outer/string + &hyper::Method::Post if path.matched(paths::ID_FAKE_OUTER_STRING) => Ok("FakeOuterStringSerialize"), + + // TestBodyWithQueryParams - PUT /fake/body-with-query-params + &hyper::Method::Put if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Ok("TestBodyWithQueryParams"), + + // TestClientModel - PATCH /fake + &hyper::Method::Patch if path.matched(paths::ID_FAKE) => Ok("TestClientModel"), + + // TestEndpointParameters - POST /fake + &hyper::Method::Post if path.matched(paths::ID_FAKE) => Ok("TestEndpointParameters"), + + // TestEnumParameters - GET /fake + &hyper::Method::Get if path.matched(paths::ID_FAKE) => Ok("TestEnumParameters"), + + // TestInlineAdditionalProperties - POST /fake/inline-additionalProperties + &hyper::Method::Post if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Ok("TestInlineAdditionalProperties"), + + // TestJsonFormData - GET /fake/jsonFormData + &hyper::Method::Get if path.matched(paths::ID_FAKE_JSONFORMDATA) => Ok("TestJsonFormData"), + + // TestClassname - PATCH /fake_classname_test + &hyper::Method::Patch if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Ok("TestClassname"), + + // AddPet - POST /pet + &hyper::Method::Post if path.matched(paths::ID_PET) => Ok("AddPet"), + + // DeletePet - DELETE /pet/{petId} + &hyper::Method::Delete if path.matched(paths::ID_PET_PETID) => Ok("DeletePet"), + + // FindPetsByStatus - GET /pet/findByStatus + &hyper::Method::Get if path.matched(paths::ID_PET_FINDBYSTATUS) => Ok("FindPetsByStatus"), + + // FindPetsByTags - GET /pet/findByTags + &hyper::Method::Get if path.matched(paths::ID_PET_FINDBYTAGS) => Ok("FindPetsByTags"), + + // GetPetById - GET /pet/{petId} + &hyper::Method::Get if path.matched(paths::ID_PET_PETID) => Ok("GetPetById"), + + // UpdatePet - PUT /pet + &hyper::Method::Put if path.matched(paths::ID_PET) => Ok("UpdatePet"), + + // UpdatePetWithForm - POST /pet/{petId} + &hyper::Method::Post if path.matched(paths::ID_PET_PETID) => Ok("UpdatePetWithForm"), + + // UploadFile - POST /pet/{petId}/uploadImage + &hyper::Method::Post if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Ok("UploadFile"), + + // DeleteOrder - DELETE /store/order/{order_id} + &hyper::Method::Delete if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Ok("DeleteOrder"), + + // GetInventory - GET /store/inventory + &hyper::Method::Get if path.matched(paths::ID_STORE_INVENTORY) => Ok("GetInventory"), + + // GetOrderById - GET /store/order/{order_id} + &hyper::Method::Get if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Ok("GetOrderById"), + + // PlaceOrder - POST /store/order + &hyper::Method::Post if path.matched(paths::ID_STORE_ORDER) => Ok("PlaceOrder"), + + // CreateUser - POST /user + &hyper::Method::Post if path.matched(paths::ID_USER) => Ok("CreateUser"), + + // CreateUsersWithArrayInput - POST /user/createWithArray + &hyper::Method::Post if path.matched(paths::ID_USER_CREATEWITHARRAY) => Ok("CreateUsersWithArrayInput"), + + // CreateUsersWithListInput - POST /user/createWithList + &hyper::Method::Post if path.matched(paths::ID_USER_CREATEWITHLIST) => Ok("CreateUsersWithListInput"), + + // DeleteUser - DELETE /user/{username} + &hyper::Method::Delete if path.matched(paths::ID_USER_USERNAME) => Ok("DeleteUser"), + + // GetUserByName - GET /user/{username} + &hyper::Method::Get if path.matched(paths::ID_USER_USERNAME) => Ok("GetUserByName"), + + // LoginUser - GET /user/login + &hyper::Method::Get if path.matched(paths::ID_USER_LOGIN) => Ok("LoginUser"), + + // LogoutUser - GET /user/logout + &hyper::Method::Get if path.matched(paths::ID_USER_LOGOUT) => Ok("LogoutUser"), + + // UpdateUser - PUT /user/{username} + &hyper::Method::Put if path.matched(paths::ID_USER_USERNAME) => Ok("UpdateUser"), + _ => Err(()), + } + } +}