diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache index f79bfe5c9cfb..2f37da0e5c1b 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache @@ -49,6 +49,24 @@ use crate::{{{operationId}}}Response; {{/callbacks}} {{>server-service-footer}} +{{! Per-operation handler functions — extracted from the match arms in run() to + reduce per-function compilation-unit size and avoid rustc OOM on large APIs. }} +{{#apiInfo}} + {{#apis}} + {{#operations}} + {{#operation}} + {{#callbacks}} + {{#urls}} + {{#requests}} +{{>server-operation-handler}} + + {{/requests}} + {{/urls}} + {{/callbacks}} + {{/operation}} + {{/operations}} + {{/apis}} +{{/apiInfo}} /// Request parser for `Api`. pub struct ApiRequestParser; impl RequestParser for ApiRequestParser { 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 fb888be8922b..108195c74e37 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 @@ -30,6 +30,18 @@ pub mod callbacks; {{/pathSet}} {{>server-service-footer}} +{{! Per-operation handler functions — extracted from the match arms in run() to + reduce per-function compilation-unit size and avoid rustc OOM on large APIs. }} +{{#apiInfo}} + {{#apis}} + {{#operations}} + {{#operation}} +{{>server-operation-handler}} + + {{/operation}} + {{/operations}} + {{/apis}} +{{/apiInfo}} /// Request parser for `Api`. pub struct ApiRequestParser; impl RequestParser for ApiRequestParser { diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation-handler.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation-handler.mustache new file mode 100644 index 000000000000..947dae369228 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation-handler.mustache @@ -0,0 +1,356 @@ +{{! + server-operation-handler.mustache + + WHY THIS FILE EXISTS: + The rust-server generator previously inlined every route handler directly inside + a single `async fn run()` defined within `Service::call()`. For large APIs this + produces a single function with tens of thousands of lines, which causes rustc to + exhaust memory (OOM) on memory-constrained CI runners (e.g. 3 GB) when compiling + with `--all-features`. + + This template generates one standalone module-level `async fn handle_()` + per API operation. The `run()` match arms are replaced with thin single-line + dispatch calls (see server-operation.mustache). The generated behaviour is + identical; only the compilation-unit structure changes. +}} +#[allow(unused_variables)] +async fn handle_{{#exts}}{{{x-operation-id}}}{{/exts}}( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +{{#apiUsesMultipartFormData}} + multipart_form_size_limit: Option, +{{/apiUsesMultipartFormData}} +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ +{{#hasAuthMethods}} + { + let authorization = match *(&context as &dyn Has>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(body_from_str("Unauthenticated")) + .expect("Unable to create Authentication Forbidden response")), + }; + {{#authMethods}} + {{#isOAuth}} + + // Authorization + if let Scopes::Some(ref scopes) = authorization.scopes { + let required_scopes: std::collections::BTreeSet = vec![ + {{#scopes}} + "{{{scope}}}".to_string(), // {{{description}}} + {{/scopes}} + ].into_iter().collect(); + + if !required_scopes.is_subset(scopes) { + let missing_scopes = required_scopes.difference(scopes); + return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(BoxBody::new(missing_scopes.fold( + "Insufficient authorization, missing scopes".to_string(), + |s, scope| format!("{s} {scope}")) + )) + .expect("Unable to create Authentication Insufficient response") + ); + } + } + {{/isOAuth}} + {{/authMethods}} + } + +{{/hasAuthMethods}} +{{#exts}} + {{#x-has-path-params}} + // Path parameters + let path: &str = uri.path(); + let path_params = + paths::REGEX_{{{x-path-id}}} + .captures(path) + .unwrap_or_else(|| + panic!("Path {} matched RE {{{x-path-id}}} in set but failed match against \"{}\"", path, paths::REGEX_{{{x-path-id}}}.as_str()) + ); + + {{/x-has-path-params}} +{{/exts}} +{{#pathParams}} + let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() { + Ok(param_{{{paramName}}}) => match param_{{{paramName}}}.parse::<{{{dataType}}}>() { + Ok(param_{{{paramName}}}) => param_{{{paramName}}}, + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Couldn't parse path parameter {{{baseName}}}: {e}"))) + .expect("Unable to create Bad Request response for invalid path parameter")), + }, + Err(_) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["{{{baseName}}}"]))) + .expect("Unable to create Bad Request response for invalid percent decode")) + }; + +{{/pathParams}} +{{#exts}} + {{#x-callback-params}} + let callback_{{.}} = path_params["{{{.}}}"].to_string(); + {{/x-callback-params}} +{{/exts}} +{{#headerParams}} + {{#-first}} + // Header parameters + {{/-first}} + let param_{{{paramName}}} = headers.get(HeaderName::from_static("{{{nameInLowerCase}}}")); + + let param_{{{paramName}}} = match param_{{{paramName}}} { + Some(v) => match header::IntoHeaderValue::<{{{dataType}}}>::try_from((*v).clone()) { + Ok(result) => +{{#required}} + result.0, +{{/required}} +{{^required}} + Some(result.0), +{{/required}} + Err(err) => { + return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Invalid header {{{baseName}}} - {err}"))) + .expect("Unable to create Bad Request response for invalid header {{{baseName}}}")); + + }, + }, + None => { +{{#required}} + return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_str("Missing required header {{{baseName}}}")) + .expect("Unable to create Bad Request response for missing required header {{{baseName}}}")); +{{/required}} +{{^required}} + None +{{/required}} + } + }; + {{#-last}} + + {{/-last}} +{{/headerParams}} +{{#queryParams}} + {{#-first}} + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); + {{/-first}} + let param_{{{paramName}}} = query_params.iter().filter(|e| e.0 == "{{{baseName}}}").map(|e| e.1.clone()) + {{#isArray}} + {{^exts.x-consumes-json}} + .filter_map(|param_{{{paramName}}}| param_{{{paramName}}}.parse().ok()) + .collect::>(); + {{^required}} + let param_{{{paramName}}} = if !param_{{{paramName}}}.is_empty() { + Some(param_{{{paramName}}}) + } else { + None + }; + {{/required}} + {{/exts.x-consumes-json}} + {{#exts.x-consumes-json}} + .next(); + let param_{{{paramName}}} = match param_{{{paramName}}} { + Some(param_{{{paramName}}}) => { + let param_{{{paramName}}} = + serde_json::from_str::<{{{dataType}}}> + (¶m_{{{paramName}}}); + match param_{{{paramName}}} { + Ok(param_{{{paramName}}}) => Some(param_{{{paramName}}}), + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Couldn't parse query parameter {{{baseName}}} - doesn't match schema: {e}"))) + .expect("Unable to create Bad Request response for invalid query parameter {{{baseName}}}")), + } + }, + None => None, + }; + {{#required}} + let param_{{{paramName}}} = match param_{{{paramName}}} { + Some(param_{{{paramName}}}) => param_{{{paramName}}}, + None => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_str("Missing required query parameter {{{baseName}}}")) + .expect("Unable to create Bad Request response for missing query parameter {{{baseName}}}")), + }; + {{/required}} + {{/exts.x-consumes-json}} + {{/isArray}} + {{^isArray}} + .next(); + let param_{{{paramName}}} = match param_{{{paramName}}} { + Some(param_{{{paramName}}}) => { + let param_{{{paramName}}} = + {{#exts.x-consumes-json}} + serde_json::from_str::<{{{dataType}}}> + {{/exts.x-consumes-json}} + {{^exts.x-consumes-json}} + <{{{dataType}}} as std::str::FromStr>::from_str + {{/exts.x-consumes-json}} + (¶m_{{{paramName}}}); + match param_{{{paramName}}} { + Ok(param_{{{paramName}}}) => Some(param_{{{paramName}}}), + Err(e) => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Couldn't parse query parameter {{{baseName}}} - doesn't match schema: {e}"))) + .expect("Unable to create Bad Request response for invalid query parameter {{{baseName}}}")), + } + }, + None => None, + }; + {{#required}} + let param_{{{paramName}}} = match param_{{{paramName}}} { + Some(param_{{{paramName}}}) => param_{{{paramName}}}, + None => return Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_str("Missing required query parameter {{{baseName}}}")) + .expect("Unable to create Bad Request response for missing query parameter {{{baseName}}}")), + }; + {{/required}} + {{#exts.x-can-validate}} + #[cfg(not(feature = "validate"))] + run_validation!(param_{{{paramName}}}, "{{{baseName}}}", validation); + {{/exts.x-can-validate}} + {{/isArray}} + {{#-last}} + + {{/-last}} +{{/queryParams}} +{{#exts.x-has-request-body}} + // Handle body parameters (note that non-required body parameters will ignore garbage + // values, rather than causing a 400 response). Produce warning header and logs for + // any unused fields. + let result = http_body_util::BodyExt::collect(body).await.map(|f| f.to_bytes().to_vec()); + match result { + Ok(body) => { + {{^exts.x-consumes-multipart-form}} + {{^exts.x-consumes-form}} + {{^bodyParam.exts.x-consumes-plain-text}} + let mut unused_elements : Vec = vec![]; + {{/bodyParam.exts.x-consumes-plain-text}} + {{/exts.x-consumes-form}} + {{/exts.x-consumes-multipart-form}} +{{>server-request-body-instance}} + +{{/exts.x-has-request-body}} + let result = api_impl.{{#exts}}{{{x-operation-id}}}{{/exts}}( + {{#exts}} + {{#x-callback-params}} + callback_{{.}}, + {{/x-callback-params}} + {{/exts}} + {{#allParams}} + param_{{{paramName}}}{{#isArray}}.as_ref(){{/isArray}}, + {{/allParams}} + &context + ).await; + let mut response = Response::new(BoxBody::new(http_body_util::Empty::new())); + 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")); + +{{#exts.x-has-request-body}} + {{^exts.x-consumes-multipart-form}} + {{^exts.x-consumes-form}} + {{^bodyParam.exts.x-consumes-plain-text}} + if !unused_elements.is_empty() { + response.headers_mut().insert( + HeaderName::from_static("warning"), + HeaderValue::from_str(format!("Ignoring unknown fields in body: {unused_elements:?}").as_str()) + .expect("Unable to create Warning header value")); + } + {{/bodyParam.exts.x-consumes-plain-text}} + {{/exts.x-consumes-form}} + {{/exts.x-consumes-multipart-form}} +{{/exts.x-has-request-body}} + match result { + Ok(rsp) => match rsp { +{{#responses}} + {{{operationId}}}Response::{{#exts}}{{x-response-id}}{{/exts}} +{{#dataType}} +{{^headers}} + (body) +{{/headers}} +{{#headers}} +{{#-first}} + { + body, +{{/-first}} + {{{name}}}{{^-last}},{{/-last}} +{{#-last}} + } +{{/-last}} +{{/headers}} +{{/dataType}} +{{^dataType}} +{{#headers}} +{{#-first}} + { +{{/-first}} + {{{name}}}{{^-last}},{{/-last}} +{{#-last}} + } +{{/-last}} +{{/headers}} +{{/dataType}} + => { + *response.status_mut() = StatusCode::from_u16({{{code}}}).expect("Unable to turn {{{code}}} into a StatusCode"); +{{#headers}} + + {{^required}} + if let Some({{{name}}}) = {{{name}}} { + {{/required}} + let {{{name}}} = match header::IntoHeaderValue({{{name}}}).try_into() { + Ok(val) => val, + Err(e) => { + return Ok(Response::builder() + .status(StatusCode::INTERNAL_SERVER_ERROR) + .body(body_from_string(format!("An internal server error occurred handling {{name}} header - {e}"))) + .expect("Unable to create Internal Server Error for invalid response header")) + } + }; + + response.headers_mut().insert( + HeaderName::from_static("{{{nameInLowerCase}}}"), + {{name}} + ); + {{^required}} + } + {{/required}} +{{/headers}} +{{>server-response-body-instance}} + + }, +{{/responses}} + }, + 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_str("An internal error occurred"); + }, + } + + Ok(response) +{{#exts.x-has-request-body}} + }, + Err(e) => Ok(Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(body_from_string(format!("Unable to read body: {}", e.into()))) + .expect("Unable to create Bad Request response due to unable to read body")), + } +{{/exts.x-has-request-body}} +} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache index 956e2a5baef6..f3e803ce2717 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache @@ -1,324 +1,4 @@ // {{{operationId}}} - {{{httpMethod}}} {{{path}}} hyper::Method::{{exts.x-http-method}} if path.matched(paths::ID_{{exts.x-path-id}}) => { -{{#hasAuthMethods}} - { - let authorization = match *(&context as &dyn Has>).get() { - Some(ref authorization) => authorization, - None => return Ok(Response::builder() - .status(StatusCode::FORBIDDEN) - .body(body_from_str("Unauthenticated")) - .expect("Unable to create Authentication Forbidden response")), - }; - {{#authMethods}} - {{#isOAuth}} - - // Authorization - if let Scopes::Some(ref scopes) = authorization.scopes { - let required_scopes: std::collections::BTreeSet = vec![ - {{#scopes}} - "{{{scope}}}".to_string(), // {{{description}}} - {{/scopes}} - ].into_iter().collect(); - - if !required_scopes.is_subset(scopes) { - let missing_scopes = required_scopes.difference(scopes); - return Ok(Response::builder() - .status(StatusCode::FORBIDDEN) - .body(BoxBody::new(missing_scopes.fold( - "Insufficient authorization, missing scopes".to_string(), - |s, scope| format!("{s} {scope}")) - )) - .expect("Unable to create Authentication Insufficient response") - ); - } - } - {{/isOAuth}} - {{/authMethods}} - } - -{{/hasAuthMethods}} -{{#exts}} - {{#x-has-path-params}} - // Path parameters - let path: &str = uri.path(); - let path_params = - paths::REGEX_{{{x-path-id}}} - .captures(path) - .unwrap_or_else(|| - panic!("Path {} matched RE {{{x-path-id}}} in set but failed match against \"{}\"", path, paths::REGEX_{{{x-path-id}}}.as_str()) - ); - - {{/x-has-path-params}} -{{/exts}} -{{#pathParams}} - let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() { - Ok(param_{{{paramName}}}) => match param_{{{paramName}}}.parse::<{{{dataType}}}>() { - Ok(param_{{{paramName}}}) => param_{{{paramName}}}, - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Couldn't parse path parameter {{{baseName}}}: {e}"))) - .expect("Unable to create Bad Request response for invalid path parameter")), - }, - Err(_) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["{{{baseName}}}"]))) - .expect("Unable to create Bad Request response for invalid percent decode")) - }; - -{{/pathParams}} -{{#exts}} - {{#x-callback-params}} - let callback_{{.}} = path_params["{{{.}}}"].to_string(); - {{/x-callback-params}} -{{/exts}} -{{#headerParams}} - {{#-first}} - // Header parameters - {{/-first}} - let param_{{{paramName}}} = headers.get(HeaderName::from_static("{{{nameInLowerCase}}}")); - - let param_{{{paramName}}} = match param_{{{paramName}}} { - Some(v) => match header::IntoHeaderValue::<{{{dataType}}}>::try_from((*v).clone()) { - Ok(result) => -{{#required}} - result.0, -{{/required}} -{{^required}} - Some(result.0), -{{/required}} - Err(err) => { - return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Invalid header {{{baseName}}} - {err}"))) - .expect("Unable to create Bad Request response for invalid header {{{baseName}}}")); - - }, - }, - None => { -{{#required}} - return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_str("Missing required header {{{baseName}}}")) - .expect("Unable to create Bad Request response for missing required header {{{baseName}}}")); -{{/required}} -{{^required}} - None -{{/required}} - } - }; - {{#-last}} - - {{/-last}} -{{/headerParams}} -{{#queryParams}} - {{#-first}} - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); - {{/-first}} - let param_{{{paramName}}} = query_params.iter().filter(|e| e.0 == "{{{baseName}}}").map(|e| e.1.clone()) - {{#isArray}} - {{^exts.x-consumes-json}} - .filter_map(|param_{{{paramName}}}| param_{{{paramName}}}.parse().ok()) - .collect::>(); - {{^required}} - let param_{{{paramName}}} = if !param_{{{paramName}}}.is_empty() { - Some(param_{{{paramName}}}) - } else { - None - }; - {{/required}} - {{/exts.x-consumes-json}} - {{#exts.x-consumes-json}} - .next(); - let param_{{{paramName}}} = match param_{{{paramName}}} { - Some(param_{{{paramName}}}) => { - let param_{{{paramName}}} = - serde_json::from_str::<{{{dataType}}}> - (¶m_{{{paramName}}}); - match param_{{{paramName}}} { - Ok(param_{{{paramName}}}) => Some(param_{{{paramName}}}), - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Couldn't parse query parameter {{{baseName}}} - doesn't match schema: {e}"))) - .expect("Unable to create Bad Request response for invalid query parameter {{{baseName}}}")), - } - }, - None => None, - }; - {{#required}} - let param_{{{paramName}}} = match param_{{{paramName}}} { - Some(param_{{{paramName}}}) => param_{{{paramName}}}, - None => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_str("Missing required query parameter {{{baseName}}}")) - .expect("Unable to create Bad Request response for missing query parameter {{{baseName}}}")), - }; - {{/required}} - {{/exts.x-consumes-json}} - {{/isArray}} - {{^isArray}} - .next(); - let param_{{{paramName}}} = match param_{{{paramName}}} { - Some(param_{{{paramName}}}) => { - let param_{{{paramName}}} = - {{#exts.x-consumes-json}} - serde_json::from_str::<{{{dataType}}}> - {{/exts.x-consumes-json}} - {{^exts.x-consumes-json}} - <{{{dataType}}} as std::str::FromStr>::from_str - {{/exts.x-consumes-json}} - (¶m_{{{paramName}}}); - match param_{{{paramName}}} { - Ok(param_{{{paramName}}}) => Some(param_{{{paramName}}}), - Err(e) => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Couldn't parse query parameter {{{baseName}}} - doesn't match schema: {e}"))) - .expect("Unable to create Bad Request response for invalid query parameter {{{baseName}}}")), - } - }, - None => None, - }; - {{#required}} - let param_{{{paramName}}} = match param_{{{paramName}}} { - Some(param_{{{paramName}}}) => param_{{{paramName}}}, - None => return Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_str("Missing required query parameter {{{baseName}}}")) - .expect("Unable to create Bad Request response for missing query parameter {{{baseName}}}")), - }; - {{/required}} - {{#exts.x-can-validate}} - #[cfg(not(feature = "validate"))] - run_validation!(param_{{{paramName}}}, "{{{baseName}}}", validation); - {{/exts.x-can-validate}} - {{/isArray}} - {{#-last}} - - {{/-last}} -{{/queryParams}} -{{#exts.x-has-request-body}} - // Handle body parameters (note that non-required body parameters will ignore garbage - // values, rather than causing a 400 response). Produce warning header and logs for - // any unused fields. - let result = http_body_util::BodyExt::collect(body).await.map(|f| f.to_bytes().to_vec()); - match result { - Ok(body) => { - {{^exts.x-consumes-multipart-form}} - {{^exts.x-consumes-form}} - {{^bodyParam.exts.x-consumes-plain-text}} - let mut unused_elements : Vec = vec![]; - {{/bodyParam.exts.x-consumes-plain-text}} - {{/exts.x-consumes-form}} - {{/exts.x-consumes-multipart-form}} -{{>server-request-body-instance}} - -{{/exts.x-has-request-body}} - let result = api_impl.{{#exts}}{{{x-operation-id}}}{{/exts}}( - {{#exts}} - {{#x-callback-params}} - callback_{{.}}, - {{/x-callback-params}} - {{/exts}} - {{#allParams}} - param_{{{paramName}}}{{#isArray}}.as_ref(){{/isArray}}, - {{/allParams}} - &context - ).await; - let mut response = Response::new(BoxBody::new(http_body_util::Empty::new())); - 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")); - -{{#exts.x-has-request-body}} - {{^exts.x-consumes-multipart-form}} - {{^exts.x-consumes-form}} - {{^bodyParam.exts.x-consumes-plain-text}} - if !unused_elements.is_empty() { - response.headers_mut().insert( - HeaderName::from_static("warning"), - HeaderValue::from_str(format!("Ignoring unknown fields in body: {unused_elements:?}").as_str()) - .expect("Unable to create Warning header value")); - } - {{/bodyParam.exts.x-consumes-plain-text}} - {{/exts.x-consumes-form}} - {{/exts.x-consumes-multipart-form}} -{{/exts.x-has-request-body}} - match result { - Ok(rsp) => match rsp { -{{#responses}} - {{{operationId}}}Response::{{#exts}}{{x-response-id}}{{/exts}} -{{#dataType}} -{{^headers}} - (body) -{{/headers}} -{{#headers}} -{{#-first}} - { - body, -{{/-first}} - {{{name}}}{{^-last}},{{/-last}} -{{#-last}} - } -{{/-last}} -{{/headers}} -{{/dataType}} -{{^dataType}} -{{#headers}} -{{#-first}} - { -{{/-first}} - {{{name}}}{{^-last}},{{/-last}} -{{#-last}} - } -{{/-last}} -{{/headers}} -{{/dataType}} - => { - *response.status_mut() = StatusCode::from_u16({{{code}}}).expect("Unable to turn {{{code}}} into a StatusCode"); -{{#headers}} - - {{^required}} - if let Some({{{name}}}) = {{{name}}} { - {{/required}} - let {{{name}}} = match header::IntoHeaderValue({{{name}}}).try_into() { - Ok(val) => val, - Err(e) => { - return Ok(Response::builder() - .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(body_from_string(format!("An internal server error occurred handling {{name}} header - {e}"))) - .expect("Unable to create Internal Server Error for invalid response header")) - } - }; - - response.headers_mut().insert( - HeaderName::from_static("{{{nameInLowerCase}}}"), - {{name}} - ); - {{^required}} - } - {{/required}} -{{/headers}} -{{>server-response-body-instance}} - - }, -{{/responses}} - }, - 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_str("An internal error occurred"); - }, - } - - Ok(response) -{{#exts.x-has-request-body}} - }, - Err(e) => Ok(Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(body_from_string(format!("Unable to read body: {}", e.into()))) - .expect("Unable to create Bad Request response due to unable to read body")), - } -{{/exts.x-has-request-body}} + handle_{{#exts}}{{{x-operation-id}}}{{/exts}}(api_impl, uri, headers, body, context, validation{{#apiUsesMultipartFormData}}, multipart_form_size_limit{{/apiUsesMultipartFormData}}).await }, diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs index 0401d842dc72..6613e1e72d34 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs @@ -256,6 +256,53 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_multipart_related_request_post(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // MultipartRequestPost - POST /multipart_request + hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => { + handle_multipart_request_post(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types + hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => { + handle_multiple_identical_mime_types_post(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + _ if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPART_REQUEST) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation, + self.multipart_form_size_limit + )) + } +} + +#[allow(unused_variables)] +async fn handle_multipart_related_request_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -383,10 +430,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_multipart_request_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -571,10 +633,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_multiple_identical_mime_types_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -677,23 +754,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_MULTIPART_REQUEST) => method_not_allowed(), - _ if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation, - self.multipart_form_size_limit - )) - } } /// Request parser for `Api`. diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs index ddac5c1d1be3..0c132409b284 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs @@ -219,6 +219,39 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_op_get(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_OP) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_op_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -292,20 +325,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`. diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index fdfb3c8dd62d..963414318c2e 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -233,6 +233,45 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_callback_callback_with_header_post(api_impl, uri, headers, body, context, validation).await + }, + + // CallbackCallbackPost - POST /{$request.query.url}/callback + hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => { + handle_callback_callback_post(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => method_not_allowed(), + _ if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_callback_callback_with_header_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -291,10 +330,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_callback_callback_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -332,21 +385,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`. 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 04ce905c268f..eed0dc8578a1 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 @@ -328,6 +328,223 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_any_of_get(api_impl, uri, headers, body, context, validation).await + }, + + // CallbackWithHeaderPost - POST /callback-with-header + hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => { + handle_callback_with_header_post(api_impl, uri, headers, body, context, validation).await + }, + + // ComplexQueryParamGet - GET /complex-query-param + hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => { + handle_complex_query_param_get(api_impl, uri, headers, body, context, validation).await + }, + + // ExamplesTest - GET /examples-test + hyper::Method::GET if path.matched(paths::ID_EXAMPLES_TEST) => { + handle_examples_test(api_impl, uri, headers, body, context, validation).await + }, + + // FormTest - POST /form-test + hyper::Method::POST if path.matched(paths::ID_FORM_TEST) => { + handle_form_test(api_impl, uri, headers, body, context, validation).await + }, + + // GetWithBooleanParameter - GET /get-with-bool + hyper::Method::GET if path.matched(paths::ID_GET_WITH_BOOL) => { + handle_get_with_boolean_parameter(api_impl, uri, headers, body, context, validation).await + }, + + // JsonComplexQueryParamGet - GET /json-complex-query-param + hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => { + handle_json_complex_query_param_get(api_impl, uri, headers, body, context, validation).await + }, + + // MandatoryRequestHeaderGet - GET /mandatory-request-header + hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => { + handle_mandatory_request_header_get(api_impl, uri, headers, body, context, validation).await + }, + + // MergePatchJsonGet - GET /merge-patch-json + hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => { + handle_merge_patch_json_get(api_impl, uri, headers, body, context, validation).await + }, + + // MultigetGet - GET /multiget + hyper::Method::GET if path.matched(paths::ID_MULTIGET) => { + handle_multiget_get(api_impl, uri, headers, body, context, validation).await + }, + + // MultipleAuthSchemeGet - GET /multiple_auth_scheme + hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => { + handle_multiple_auth_scheme_get(api_impl, uri, headers, body, context, validation).await + }, + + // OneOfGet - GET /one-of + hyper::Method::GET if path.matched(paths::ID_ONE_OF) => { + handle_one_of_get(api_impl, uri, headers, body, context, validation).await + }, + + // OverrideServerGet - GET /override-server + hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => { + handle_override_server_get(api_impl, uri, headers, body, context, validation).await + }, + + // ParamgetGet - GET /paramget + hyper::Method::GET if path.matched(paths::ID_PARAMGET) => { + handle_paramget_get(api_impl, uri, headers, body, context, validation).await + }, + + // QueryExampleGet - GET /query-example + hyper::Method::GET if path.matched(paths::ID_QUERY_EXAMPLE) => { + handle_query_example_get(api_impl, uri, headers, body, context, validation).await + }, + + // ReadonlyAuthSchemeGet - GET /readonly_auth_scheme + hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => { + handle_readonly_auth_scheme_get(api_impl, uri, headers, body, context, validation).await + }, + + // RegisterCallbackPost - POST /register-callback + hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => { + handle_register_callback_post(api_impl, uri, headers, body, context, validation).await + }, + + // RequiredOctetStreamPut - PUT /required_octet_stream + hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => { + handle_required_octet_stream_put(api_impl, uri, headers, body, context, validation).await + }, + + // ResponsesWithHeadersGet - GET /responses_with_headers + hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => { + handle_responses_with_headers_get(api_impl, uri, headers, body, context, validation).await + }, + + // Rfc7807Get - GET /rfc7807 + hyper::Method::GET if path.matched(paths::ID_RFC7807) => { + handle_rfc7807_get(api_impl, uri, headers, body, context, validation).await + }, + + // TwoFirstLetterHeaders - POST /operation-two-first-letter-headers + hyper::Method::POST if path.matched(paths::ID_OPERATION_TWO_FIRST_LETTER_HEADERS) => { + handle_two_first_letter_headers(api_impl, uri, headers, body, context, validation).await + }, + + // UntypedPropertyGet - GET /untyped_property + hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => { + handle_untyped_property_get(api_impl, uri, headers, body, context, validation).await + }, + + // UuidGet - GET /uuid + hyper::Method::GET if path.matched(paths::ID_UUID) => { + handle_uuid_get(api_impl, uri, headers, body, context, validation).await + }, + + // XmlExtraPost - POST /xml_extra + hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => { + handle_xml_extra_post(api_impl, uri, headers, body, context, validation).await + }, + + // XmlOtherPost - POST /xml_other + hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => { + handle_xml_other_post(api_impl, uri, headers, body, context, validation).await + }, + + // XmlOtherPut - PUT /xml_other + hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => { + handle_xml_other_put(api_impl, uri, headers, body, context, validation).await + }, + + // XmlPost - POST /xml + hyper::Method::POST if path.matched(paths::ID_XML) => { + handle_xml_post(api_impl, uri, headers, body, context, validation).await + }, + + // XmlPut - PUT /xml + hyper::Method::PUT if path.matched(paths::ID_XML) => { + handle_xml_put(api_impl, uri, headers, body, context, validation).await + }, + + // EnumInPathPathParamGet - GET /enum_in_path/{path_param} + hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => { + handle_enum_in_path_path_param_get(api_impl, uri, headers, body, context, validation).await + }, + + // MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b} + hyper::Method::GET if path.matched(paths::ID_MULTIPLE_PATH_PARAMS_WITH_VERY_LONG_PATH_TO_TEST_FORMATTING_PATH_PARAM_A_PATH_PARAM_B) => { + handle_multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get(api_impl, uri, headers, body, context, validation).await + }, + + // CreateRepo - POST /repos + hyper::Method::POST if path.matched(paths::ID_REPOS) => { + handle_create_repo(api_impl, uri, headers, body, context, validation).await + }, + + // GetRepoInfo - GET /repos/{repoId} + hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => { + handle_get_repo_info(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_ANY_OF) => method_not_allowed(), + _ if path.matched(paths::ID_CALLBACK_WITH_HEADER) => method_not_allowed(), + _ if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_EXAMPLES_TEST) => method_not_allowed(), + _ if path.matched(paths::ID_FORM_TEST) => method_not_allowed(), + _ if path.matched(paths::ID_GET_WITH_BOOL) => method_not_allowed(), + _ if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => method_not_allowed(), + _ if path.matched(paths::ID_MERGE_PATCH_JSON) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIGET) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPLE_PATH_PARAMS_WITH_VERY_LONG_PATH_TO_TEST_FORMATTING_PATH_PARAM_A_PATH_PARAM_B) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => method_not_allowed(), + _ if path.matched(paths::ID_ONE_OF) => method_not_allowed(), + _ if path.matched(paths::ID_OPERATION_TWO_FIRST_LETTER_HEADERS) => method_not_allowed(), + _ if path.matched(paths::ID_OVERRIDE_SERVER) => method_not_allowed(), + _ if path.matched(paths::ID_PARAMGET) => method_not_allowed(), + _ if path.matched(paths::ID_QUERY_EXAMPLE) => method_not_allowed(), + _ if path.matched(paths::ID_READONLY_AUTH_SCHEME) => method_not_allowed(), + _ if path.matched(paths::ID_REGISTER_CALLBACK) => method_not_allowed(), + _ if path.matched(paths::ID_REPOS) => method_not_allowed(), + _ if path.matched(paths::ID_REPOS_REPOID) => method_not_allowed(), + _ if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => method_not_allowed(), + _ if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => method_not_allowed(), + _ if path.matched(paths::ID_RFC7807) => method_not_allowed(), + _ if path.matched(paths::ID_UNTYPED_PROPERTY) => method_not_allowed(), + _ if path.matched(paths::ID_UUID) => method_not_allowed(), + _ if path.matched(paths::ID_XML) => method_not_allowed(), + _ if path.matched(paths::ID_XML_EXTRA) => method_not_allowed(), + _ if path.matched(paths::ID_XML_OTHER) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_any_of_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_any_of = query_params.iter().filter(|e| e.0 == "any-of").map(|e| e.1.clone()) @@ -397,10 +614,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_callback_with_header_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.clone()) @@ -455,10 +686,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_complex_query_param_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.clone()) @@ -497,10 +742,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_examples_test( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_ids = query_params.iter().filter(|e| e.0 == "ids").map(|e| e.1.clone()) @@ -546,10 +805,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_form_test( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -597,10 +870,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_with_boolean_parameter( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_iambool = query_params.iter().filter(|e| e.0 == "iambool").map(|e| e.1.clone()) @@ -655,10 +942,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_json_complex_query_param_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.clone()) @@ -706,10 +1007,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_mandatory_request_header_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Header parameters let param_x_header = headers.get(HeaderName::from_static("x-header")); @@ -760,10 +1075,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_merge_patch_json_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.merge_patch_json_get( &context ).await; @@ -797,10 +1126,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_multiget_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.multiget_get( &context ).await; @@ -904,10 +1247,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_multiple_auth_scheme_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -964,10 +1321,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_one_of_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.one_of_get( &context ).await; @@ -1001,10 +1372,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_override_server_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.override_server_get( &context ).await; @@ -1031,10 +1416,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_paramget_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_uuid = query_params.iter().filter(|e| e.0 == "uuid").map(|e| e.1.clone()) @@ -1129,10 +1528,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_query_example_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_required_no_example = query_params.iter().filter(|e| e.0 == "required_no_example").map(|e| e.1.clone()) @@ -1212,10 +1625,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_readonly_auth_scheme_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1271,10 +1698,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_register_callback_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.clone()) @@ -1329,10 +1770,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_required_octet_stream_put( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1386,10 +1841,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_responses_with_headers_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.responses_with_headers_get( &context ).await; @@ -1520,10 +1989,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_rfc7807_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.rfc7807_get( &context ).await; @@ -1581,10 +2064,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_two_first_letter_headers( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Header parameters let param_x_header_one = headers.get(HeaderName::from_static("x-header-one")); @@ -1651,10 +2148,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_untyped_property_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1715,10 +2226,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_uuid_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.uuid_get( &context ).await; @@ -1752,10 +2277,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_xml_extra_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1821,10 +2360,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_xml_other_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1900,10 +2453,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_xml_other_put( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1969,10 +2536,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_xml_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2038,10 +2619,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_xml_put( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2107,10 +2702,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_enum_in_path_path_param_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -2161,10 +2770,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -2230,10 +2853,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_create_repo( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2307,10 +2944,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_repo_info( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -2368,49 +3019,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_CALLBACK_WITH_HEADER) => method_not_allowed(), - _ if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => method_not_allowed(), - _ if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => method_not_allowed(), - _ if path.matched(paths::ID_EXAMPLES_TEST) => method_not_allowed(), - _ if path.matched(paths::ID_FORM_TEST) => method_not_allowed(), - _ if path.matched(paths::ID_GET_WITH_BOOL) => method_not_allowed(), - _ if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => method_not_allowed(), - _ if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => method_not_allowed(), - _ if path.matched(paths::ID_MERGE_PATCH_JSON) => method_not_allowed(), - _ if path.matched(paths::ID_MULTIGET) => method_not_allowed(), - _ if path.matched(paths::ID_MULTIPLE_PATH_PARAMS_WITH_VERY_LONG_PATH_TO_TEST_FORMATTING_PATH_PARAM_A_PATH_PARAM_B) => method_not_allowed(), - _ if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => method_not_allowed(), - _ if path.matched(paths::ID_ONE_OF) => method_not_allowed(), - _ if path.matched(paths::ID_OPERATION_TWO_FIRST_LETTER_HEADERS) => method_not_allowed(), - _ if path.matched(paths::ID_OVERRIDE_SERVER) => method_not_allowed(), - _ if path.matched(paths::ID_PARAMGET) => method_not_allowed(), - _ if path.matched(paths::ID_QUERY_EXAMPLE) => method_not_allowed(), - _ if path.matched(paths::ID_READONLY_AUTH_SCHEME) => method_not_allowed(), - _ if path.matched(paths::ID_REGISTER_CALLBACK) => method_not_allowed(), - _ if path.matched(paths::ID_REPOS) => method_not_allowed(), - _ if path.matched(paths::ID_REPOS_REPOID) => method_not_allowed(), - _ if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => method_not_allowed(), - _ if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => method_not_allowed(), - _ if path.matched(paths::ID_RFC7807) => method_not_allowed(), - _ if path.matched(paths::ID_UNTYPED_PROPERTY) => method_not_allowed(), - _ if path.matched(paths::ID_UUID) => method_not_allowed(), - _ if path.matched(paths::ID_XML) => method_not_allowed(), - _ if path.matched(paths::ID_XML_EXTRA) => method_not_allowed(), - _ if path.matched(paths::ID_XML_OTHER) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`. diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index 294a1dd10f43..a2bb94a0b38f 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -327,6 +327,255 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_op10_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op11Get - GET /op11 + hyper::Method::GET if path.matched(paths::ID_OP11) => { + handle_op11_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op12Get - GET /op12 + hyper::Method::GET if path.matched(paths::ID_OP12) => { + handle_op12_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op13Get - GET /op13 + hyper::Method::GET if path.matched(paths::ID_OP13) => { + handle_op13_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op14Get - GET /op14 + hyper::Method::GET if path.matched(paths::ID_OP14) => { + handle_op14_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op15Get - GET /op15 + hyper::Method::GET if path.matched(paths::ID_OP15) => { + handle_op15_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op16Get - GET /op16 + hyper::Method::GET if path.matched(paths::ID_OP16) => { + handle_op16_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op17Get - GET /op17 + hyper::Method::GET if path.matched(paths::ID_OP17) => { + handle_op17_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op18Get - GET /op18 + hyper::Method::GET if path.matched(paths::ID_OP18) => { + handle_op18_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op19Get - GET /op19 + hyper::Method::GET if path.matched(paths::ID_OP19) => { + handle_op19_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op1Get - GET /op1 + hyper::Method::GET if path.matched(paths::ID_OP1) => { + handle_op1_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op20Get - GET /op20 + hyper::Method::GET if path.matched(paths::ID_OP20) => { + handle_op20_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op21Get - GET /op21 + hyper::Method::GET if path.matched(paths::ID_OP21) => { + handle_op21_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op22Get - GET /op22 + hyper::Method::GET if path.matched(paths::ID_OP22) => { + handle_op22_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op23Get - GET /op23 + hyper::Method::GET if path.matched(paths::ID_OP23) => { + handle_op23_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op24Get - GET /op24 + hyper::Method::GET if path.matched(paths::ID_OP24) => { + handle_op24_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op25Get - GET /op25 + hyper::Method::GET if path.matched(paths::ID_OP25) => { + handle_op25_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op26Get - GET /op26 + hyper::Method::GET if path.matched(paths::ID_OP26) => { + handle_op26_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op27Get - GET /op27 + hyper::Method::GET if path.matched(paths::ID_OP27) => { + handle_op27_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op28Get - GET /op28 + hyper::Method::GET if path.matched(paths::ID_OP28) => { + handle_op28_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op29Get - GET /op29 + hyper::Method::GET if path.matched(paths::ID_OP29) => { + handle_op29_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op2Get - GET /op2 + hyper::Method::GET if path.matched(paths::ID_OP2) => { + handle_op2_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op30Get - GET /op30 + hyper::Method::GET if path.matched(paths::ID_OP30) => { + handle_op30_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op31Get - GET /op31 + hyper::Method::GET if path.matched(paths::ID_OP31) => { + handle_op31_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op32Get - GET /op32 + hyper::Method::GET if path.matched(paths::ID_OP32) => { + handle_op32_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op33Get - GET /op33 + hyper::Method::GET if path.matched(paths::ID_OP33) => { + handle_op33_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op34Get - GET /op34 + hyper::Method::GET if path.matched(paths::ID_OP34) => { + handle_op34_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op35Get - GET /op35 + hyper::Method::GET if path.matched(paths::ID_OP35) => { + handle_op35_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op36Get - GET /op36 + hyper::Method::GET if path.matched(paths::ID_OP36) => { + handle_op36_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op37Get - GET /op37 + hyper::Method::GET if path.matched(paths::ID_OP37) => { + handle_op37_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op3Get - GET /op3 + hyper::Method::GET if path.matched(paths::ID_OP3) => { + handle_op3_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op4Get - GET /op4 + hyper::Method::GET if path.matched(paths::ID_OP4) => { + handle_op4_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op5Get - GET /op5 + hyper::Method::GET if path.matched(paths::ID_OP5) => { + handle_op5_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op6Get - GET /op6 + hyper::Method::GET if path.matched(paths::ID_OP6) => { + handle_op6_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op7Get - GET /op7 + hyper::Method::GET if path.matched(paths::ID_OP7) => { + handle_op7_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op8Get - GET /op8 + hyper::Method::GET if path.matched(paths::ID_OP8) => { + handle_op8_get(api_impl, uri, headers, body, context, validation).await + }, + + // Op9Get - GET /op9 + hyper::Method::GET if path.matched(paths::ID_OP9) => { + handle_op9_get(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_OP1) => method_not_allowed(), + _ if path.matched(paths::ID_OP10) => method_not_allowed(), + _ if path.matched(paths::ID_OP11) => method_not_allowed(), + _ if path.matched(paths::ID_OP12) => method_not_allowed(), + _ if path.matched(paths::ID_OP13) => method_not_allowed(), + _ if path.matched(paths::ID_OP14) => method_not_allowed(), + _ if path.matched(paths::ID_OP15) => method_not_allowed(), + _ if path.matched(paths::ID_OP16) => method_not_allowed(), + _ if path.matched(paths::ID_OP17) => method_not_allowed(), + _ if path.matched(paths::ID_OP18) => method_not_allowed(), + _ if path.matched(paths::ID_OP19) => method_not_allowed(), + _ if path.matched(paths::ID_OP2) => method_not_allowed(), + _ if path.matched(paths::ID_OP20) => method_not_allowed(), + _ if path.matched(paths::ID_OP21) => method_not_allowed(), + _ if path.matched(paths::ID_OP22) => method_not_allowed(), + _ if path.matched(paths::ID_OP23) => method_not_allowed(), + _ if path.matched(paths::ID_OP24) => method_not_allowed(), + _ if path.matched(paths::ID_OP25) => method_not_allowed(), + _ if path.matched(paths::ID_OP26) => method_not_allowed(), + _ if path.matched(paths::ID_OP27) => method_not_allowed(), + _ if path.matched(paths::ID_OP28) => method_not_allowed(), + _ if path.matched(paths::ID_OP29) => method_not_allowed(), + _ if path.matched(paths::ID_OP3) => method_not_allowed(), + _ if path.matched(paths::ID_OP30) => method_not_allowed(), + _ if path.matched(paths::ID_OP31) => method_not_allowed(), + _ if path.matched(paths::ID_OP32) => method_not_allowed(), + _ if path.matched(paths::ID_OP33) => method_not_allowed(), + _ if path.matched(paths::ID_OP34) => method_not_allowed(), + _ if path.matched(paths::ID_OP35) => method_not_allowed(), + _ if path.matched(paths::ID_OP36) => method_not_allowed(), + _ if path.matched(paths::ID_OP37) => method_not_allowed(), + _ if path.matched(paths::ID_OP4) => method_not_allowed(), + _ if path.matched(paths::ID_OP5) => method_not_allowed(), + _ if path.matched(paths::ID_OP6) => method_not_allowed(), + _ if path.matched(paths::ID_OP7) => method_not_allowed(), + _ if path.matched(paths::ID_OP8) => method_not_allowed(), + _ if path.matched(paths::ID_OP9) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_op10_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op10_get( &context ).await; @@ -353,10 +602,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op11_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op11_get( &context ).await; @@ -383,10 +646,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op12_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op12_get( &context ).await; @@ -413,10 +690,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op13_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op13_get( &context ).await; @@ -443,10 +734,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op14_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op14_get( &context ).await; @@ -473,10 +778,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op15_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op15_get( &context ).await; @@ -503,10 +822,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op16_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op16_get( &context ).await; @@ -533,10 +866,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op17_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op17_get( &context ).await; @@ -563,10 +910,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op18_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op18_get( &context ).await; @@ -593,10 +954,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op19_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op19_get( &context ).await; @@ -623,10 +998,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op1_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op1_get( &context ).await; @@ -653,10 +1042,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op20_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op20_get( &context ).await; @@ -683,10 +1086,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op21_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op21_get( &context ).await; @@ -713,10 +1130,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op22_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op22_get( &context ).await; @@ -743,10 +1174,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op23_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op23_get( &context ).await; @@ -773,10 +1218,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op24_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op24_get( &context ).await; @@ -803,10 +1262,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op25_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op25_get( &context ).await; @@ -833,10 +1306,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op26_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op26_get( &context ).await; @@ -863,10 +1350,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op27_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op27_get( &context ).await; @@ -893,10 +1394,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op28_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op28_get( &context ).await; @@ -923,10 +1438,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op29_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op29_get( &context ).await; @@ -953,10 +1482,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op2_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op2_get( &context ).await; @@ -983,10 +1526,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op30_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op30_get( &context ).await; @@ -1013,10 +1570,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op31_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op31_get( &context ).await; @@ -1043,10 +1614,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op32_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op32_get( &context ).await; @@ -1073,10 +1658,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op33_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op33_get( &context ).await; @@ -1103,10 +1702,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op34_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op34_get( &context ).await; @@ -1133,10 +1746,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op35_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op35_get( &context ).await; @@ -1163,10 +1790,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op36_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op36_get( &context ).await; @@ -1193,10 +1834,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op37_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op37_get( &context ).await; @@ -1223,10 +1878,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op3_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op3_get( &context ).await; @@ -1253,10 +1922,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op4_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op4_get( &context ).await; @@ -1283,10 +1966,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op5_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op5_get( &context ).await; @@ -1313,10 +2010,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op6_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op6_get( &context ).await; @@ -1343,10 +2054,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op7_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op7_get( &context ).await; @@ -1373,10 +2098,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op8_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op8_get( &context ).await; @@ -1403,10 +2142,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_op9_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.op9_get( &context ).await; @@ -1433,56 +2186,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_OP10) => method_not_allowed(), - _ if path.matched(paths::ID_OP11) => method_not_allowed(), - _ if path.matched(paths::ID_OP12) => method_not_allowed(), - _ if path.matched(paths::ID_OP13) => method_not_allowed(), - _ if path.matched(paths::ID_OP14) => method_not_allowed(), - _ if path.matched(paths::ID_OP15) => method_not_allowed(), - _ if path.matched(paths::ID_OP16) => method_not_allowed(), - _ if path.matched(paths::ID_OP17) => method_not_allowed(), - _ if path.matched(paths::ID_OP18) => method_not_allowed(), - _ if path.matched(paths::ID_OP19) => method_not_allowed(), - _ if path.matched(paths::ID_OP2) => method_not_allowed(), - _ if path.matched(paths::ID_OP20) => method_not_allowed(), - _ if path.matched(paths::ID_OP21) => method_not_allowed(), - _ if path.matched(paths::ID_OP22) => method_not_allowed(), - _ if path.matched(paths::ID_OP23) => method_not_allowed(), - _ if path.matched(paths::ID_OP24) => method_not_allowed(), - _ if path.matched(paths::ID_OP25) => method_not_allowed(), - _ if path.matched(paths::ID_OP26) => method_not_allowed(), - _ if path.matched(paths::ID_OP27) => method_not_allowed(), - _ if path.matched(paths::ID_OP28) => method_not_allowed(), - _ if path.matched(paths::ID_OP29) => method_not_allowed(), - _ if path.matched(paths::ID_OP3) => method_not_allowed(), - _ if path.matched(paths::ID_OP30) => method_not_allowed(), - _ if path.matched(paths::ID_OP31) => method_not_allowed(), - _ if path.matched(paths::ID_OP32) => method_not_allowed(), - _ if path.matched(paths::ID_OP33) => method_not_allowed(), - _ if path.matched(paths::ID_OP34) => method_not_allowed(), - _ if path.matched(paths::ID_OP35) => method_not_allowed(), - _ if path.matched(paths::ID_OP36) => method_not_allowed(), - _ if path.matched(paths::ID_OP37) => method_not_allowed(), - _ if path.matched(paths::ID_OP4) => method_not_allowed(), - _ if path.matched(paths::ID_OP5) => method_not_allowed(), - _ if path.matched(paths::ID_OP6) => method_not_allowed(), - _ if path.matched(paths::ID_OP7) => method_not_allowed(), - _ if path.matched(paths::ID_OP8) => method_not_allowed(), - _ if path.matched(paths::ID_OP9) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`. 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 83e6ca4f40a6..40da357dd587 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 @@ -365,6 +365,237 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_test_special_tags(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // Call123example - GET /fake/operation-with-numeric-id + hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => { + handle_call123example(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FakeOuterBooleanSerialize - POST /fake/outer/boolean + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => { + handle_fake_outer_boolean_serialize(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FakeOuterCompositeSerialize - POST /fake/outer/composite + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => { + handle_fake_outer_composite_serialize(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FakeOuterNumberSerialize - POST /fake/outer/number + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => { + handle_fake_outer_number_serialize(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FakeOuterStringSerialize - POST /fake/outer/string + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => { + handle_fake_outer_string_serialize(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description + hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => { + handle_fake_response_with_numerical_description(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestBodyWithQueryParams - PUT /fake/body-with-query-params + hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => { + handle_test_body_with_query_params(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestClientModel - PATCH /fake + hyper::Method::PATCH if path.matched(paths::ID_FAKE) => { + handle_test_client_model(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestEndpointParameters - POST /fake + hyper::Method::POST if path.matched(paths::ID_FAKE) => { + handle_test_endpoint_parameters(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestEnumParameters - GET /fake + hyper::Method::GET if path.matched(paths::ID_FAKE) => { + handle_test_enum_parameters(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestInlineAdditionalProperties - POST /fake/inline-additionalProperties + hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => { + handle_test_inline_additional_properties(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestJsonFormData - GET /fake/jsonFormData + hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => { + handle_test_json_form_data(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // HyphenParam - GET /fake/hyphenParam/{hyphen-param} + hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => { + handle_hyphen_param(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // TestClassname - PATCH /fake_classname_test + hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => { + handle_test_classname(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // AddPet - POST /pet + hyper::Method::POST if path.matched(paths::ID_PET) => { + handle_add_pet(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FindPetsByStatus - GET /pet/findByStatus + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => { + handle_find_pets_by_status(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // FindPetsByTags - GET /pet/findByTags + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => { + handle_find_pets_by_tags(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // UpdatePet - PUT /pet + hyper::Method::PUT if path.matched(paths::ID_PET) => { + handle_update_pet(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // DeletePet - DELETE /pet/{petId} + hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => { + handle_delete_pet(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // GetPetById - GET /pet/{petId} + hyper::Method::GET if path.matched(paths::ID_PET_PETID) => { + handle_get_pet_by_id(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // UpdatePetWithForm - POST /pet/{petId} + hyper::Method::POST if path.matched(paths::ID_PET_PETID) => { + handle_update_pet_with_form(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // UploadFile - POST /pet/{petId}/uploadImage + hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => { + handle_upload_file(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // GetInventory - GET /store/inventory + hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => { + handle_get_inventory(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // PlaceOrder - POST /store/order + hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => { + handle_place_order(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // DeleteOrder - DELETE /store/order/{order_id} + hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + handle_delete_order(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // GetOrderById - GET /store/order/{order_id} + hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + handle_get_order_by_id(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // CreateUser - POST /user + hyper::Method::POST if path.matched(paths::ID_USER) => { + handle_create_user(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // CreateUsersWithArrayInput - POST /user/createWithArray + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => { + handle_create_users_with_array_input(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // CreateUsersWithListInput - POST /user/createWithList + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => { + handle_create_users_with_list_input(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // LoginUser - GET /user/login + hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => { + handle_login_user(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // LogoutUser - GET /user/logout + hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => { + handle_logout_user(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // DeleteUser - DELETE /user/{username} + hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => { + handle_delete_user(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // GetUserByName - GET /user/{username} + hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => { + handle_get_user_by_name(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + // UpdateUser - PUT /user/{username} + hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => { + handle_update_user(api_impl, uri, headers, body, context, validation, multipart_form_size_limit).await + }, + + _ if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_JSONFORMDATA) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_NUMBER) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_STRING) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => method_not_allowed(), + _ if path.matched(paths::ID_PET) => method_not_allowed(), + _ if path.matched(paths::ID_PET_FINDBYSTATUS) => method_not_allowed(), + _ if path.matched(paths::ID_PET_FINDBYTAGS) => method_not_allowed(), + _ if path.matched(paths::ID_PET_PETID) => method_not_allowed(), + _ if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_INVENTORY) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_ORDER) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => method_not_allowed(), + _ if path.matched(paths::ID_USER) => method_not_allowed(), + _ if path.matched(paths::ID_USER_CREATEWITHARRAY) => method_not_allowed(), + _ if path.matched(paths::ID_USER_CREATEWITHLIST) => method_not_allowed(), + _ if path.matched(paths::ID_USER_LOGIN) => method_not_allowed(), + _ if path.matched(paths::ID_USER_LOGOUT) => method_not_allowed(), + _ if path.matched(paths::ID_USER_USERNAME) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation, + self.multipart_form_size_limit + )) + } +} + +#[allow(unused_variables)] +async fn handle_test_special_tags( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -445,10 +676,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_call123example( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.call123example( &context ).await; @@ -475,10 +721,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_fake_outer_boolean_serialize( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -546,10 +807,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_fake_outer_composite_serialize( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -617,10 +893,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_fake_outer_number_serialize( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -688,10 +979,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_fake_outer_string_serialize( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -759,10 +1065,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_fake_response_with_numerical_description( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.fake_response_with_numerical_description( &context ).await; @@ -789,10 +1110,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_body_with_query_params( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_query = query_params.iter().filter(|e| e.0 == "query").map(|e| e.1.clone()) @@ -894,10 +1230,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_client_model( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -978,10 +1329,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_endpoint_parameters( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1080,10 +1446,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_enum_parameters( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Header parameters let param_enum_header_string_array = headers.get(HeaderName::from_static("enum_header_string_array")); @@ -1245,10 +1626,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_inline_additional_properties( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1320,10 +1716,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_json_form_data( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1371,10 +1782,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_hyphen_param( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -1425,10 +1851,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_test_classname( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1519,10 +1960,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_add_pet( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1626,10 +2082,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_find_pets_by_status( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1705,10 +2176,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_find_pets_by_tags( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1784,10 +2270,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_update_pet( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -1901,10 +2402,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_delete_pet( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -2006,10 +2522,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_pet_by_id( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -2087,10 +2618,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_update_pet_with_form( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -2192,10 +2738,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_upload_file( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -2397,10 +2958,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_inventory( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -2444,10 +3020,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_place_order( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2533,10 +3124,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_delete_order( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -2592,10 +3198,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_order_by_id( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -2663,10 +3284,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_create_user( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2740,10 +3376,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_create_users_with_array_input( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2817,10 +3468,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_create_users_with_list_input( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2894,10 +3560,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_login_user( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::>(); let param_username = query_params.iter().filter(|e| e.0 == "username").map(|e| e.1.clone()) @@ -3027,10 +3708,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_logout_user( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.logout_user( &context ).await; @@ -3057,10 +3753,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_delete_user( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -3116,10 +3827,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_user_by_name( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -3187,10 +3913,25 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_update_user( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, + multipart_form_size_limit: Option, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Path parameters let path: &str = uri.path(); let path_params = @@ -3293,47 +4034,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_FAKE) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_JSONFORMDATA) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_OUTER_NUMBER) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_OUTER_STRING) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => method_not_allowed(), - _ if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => method_not_allowed(), - _ if path.matched(paths::ID_PET) => method_not_allowed(), - _ if path.matched(paths::ID_PET_FINDBYSTATUS) => method_not_allowed(), - _ if path.matched(paths::ID_PET_FINDBYTAGS) => method_not_allowed(), - _ if path.matched(paths::ID_PET_PETID) => method_not_allowed(), - _ if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => method_not_allowed(), - _ if path.matched(paths::ID_STORE_INVENTORY) => method_not_allowed(), - _ if path.matched(paths::ID_STORE_ORDER) => method_not_allowed(), - _ if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => method_not_allowed(), - _ if path.matched(paths::ID_USER) => method_not_allowed(), - _ if path.matched(paths::ID_USER_CREATEWITHARRAY) => method_not_allowed(), - _ if path.matched(paths::ID_USER_CREATEWITHLIST) => method_not_allowed(), - _ if path.matched(paths::ID_USER_LOGIN) => method_not_allowed(), - _ if path.matched(paths::ID_USER_LOGOUT) => method_not_allowed(), - _ if path.matched(paths::ID_USER_USERNAME) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation, - self.multipart_form_size_limit - )) - } } /// Request parser for `Api`. diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs index adce42a8b6ae..701c40d5f073 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs @@ -219,6 +219,39 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_ping_get(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_PING) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_ping_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Has> + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ { let authorization = match *(&context as &dyn Has>).get() { Some(ref authorization) => authorization, @@ -255,20 +288,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`. diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index 29c4795d608e..5dd853f2a1eb 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -241,6 +241,86 @@ impl hyper::service::Service<(Request, C)> for Service { + handle_all_of_get(api_impl, uri, headers, body, context, validation).await + }, + + // DummyGet - GET /dummy + hyper::Method::GET if path.matched(paths::ID_DUMMY) => { + handle_dummy_get(api_impl, uri, headers, body, context, validation).await + }, + + // DummyPut - PUT /dummy + hyper::Method::PUT if path.matched(paths::ID_DUMMY) => { + handle_dummy_put(api_impl, uri, headers, body, context, validation).await + }, + + // FileResponseGet - GET /file_response + hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => { + handle_file_response_get(api_impl, uri, headers, body, context, validation).await + }, + + // GetStructuredYaml - GET /get-structured-yaml + hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => { + handle_get_structured_yaml(api_impl, uri, headers, body, context, validation).await + }, + + // HtmlPost - POST /html + hyper::Method::POST if path.matched(paths::ID_HTML) => { + handle_html_post(api_impl, uri, headers, body, context, validation).await + }, + + // PostYaml - POST /post-yaml + hyper::Method::POST if path.matched(paths::ID_POST_YAML) => { + handle_post_yaml(api_impl, uri, headers, body, context, validation).await + }, + + // RawJsonGet - GET /raw_json + hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => { + handle_raw_json_get(api_impl, uri, headers, body, context, validation).await + }, + + // SoloObjectPost - POST /solo-object + hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => { + handle_solo_object_post(api_impl, uri, headers, body, context, validation).await + }, + + _ if path.matched(paths::ID_ALLOF) => method_not_allowed(), + _ if path.matched(paths::ID_DUMMY) => method_not_allowed(), + _ if path.matched(paths::ID_FILE_RESPONSE) => method_not_allowed(), + _ if path.matched(paths::ID_GET_STRUCTURED_YAML) => method_not_allowed(), + _ if path.matched(paths::ID_HTML) => method_not_allowed(), + _ if path.matched(paths::ID_POST_YAML) => method_not_allowed(), + _ if path.matched(paths::ID_RAW_JSON) => method_not_allowed(), + _ if path.matched(paths::ID_SOLO_OBJECT) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(BoxBody::new(http_body_util::Empty::new())) + .expect("Unable to create Not Found response")) + } + } + Box::pin(run( + self.api_impl.clone(), + req, + self.validation + )) + } +} + +#[allow(unused_variables)] +async fn handle_all_of_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.all_of_get( &context ).await; @@ -274,10 +354,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_dummy_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.dummy_get( &context ).await; @@ -304,10 +398,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_dummy_put( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -381,10 +489,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_file_response_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.file_response_get( &context ).await; @@ -418,10 +540,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_get_structured_yaml( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.get_structured_yaml( &context ).await; @@ -454,10 +590,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_html_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -523,10 +673,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_post_yaml( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -586,10 +750,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_raw_json_get( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ let result = api_impl.raw_json_get( &context ).await; @@ -623,10 +801,24 @@ impl hyper::service::Service<(Request, C)> for Service { +#[allow(unused_variables)] +async fn handle_solo_object_post( + mut api_impl: T, + uri: hyper::Uri, + headers: HeaderMap, + body: ReqBody, + context: C, + validation: bool, +) -> Result>, crate::ServiceError> +where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static, + ReqBody: Body + Send + 'static, + ReqBody::Error: Into> + Send, + ReqBody::Data: Send, +{ // Handle body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -698,27 +890,6 @@ impl hyper::service::Service<(Request, C)> for Service method_not_allowed(), - _ if path.matched(paths::ID_DUMMY) => method_not_allowed(), - _ if path.matched(paths::ID_FILE_RESPONSE) => method_not_allowed(), - _ if path.matched(paths::ID_GET_STRUCTURED_YAML) => method_not_allowed(), - _ if path.matched(paths::ID_HTML) => method_not_allowed(), - _ if path.matched(paths::ID_POST_YAML) => method_not_allowed(), - _ if path.matched(paths::ID_RAW_JSON) => method_not_allowed(), - _ if path.matched(paths::ID_SOLO_OBJECT) => method_not_allowed(), - _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) - .body(BoxBody::new(http_body_util::Empty::new())) - .expect("Unable to create Not Found response")) - } - } - Box::pin(run( - self.api_impl.clone(), - req, - self.validation - )) - } } /// Request parser for `Api`.