forked from loafle/openapi-generator-original
[rust-server] Resolve clippy warnings (#13473)
* fix(rust-server): Use ok_or_else instead of ok_or * fix(rust-server): Remove empty format string * fix(rust-server): Remove redundant field names in struct initialisation * fix(rust-server): Remove redundant clones * fix(rust-server): Derive Eq with PartialEq always * fix(rust-server): Remove immediately pushes replaced by vec macro * fix(rust-server): Remove useless conversions * fix(rust-server): Dismiss clippy::new_without_default * fix(rust-server): Fix compilation failures * fix(rust-server): Resolve remaining warnings * build(rust-server): Add newly generated samples of petstore * fix(rust-server): Allow clippy::derive_partial_eq_without_eq to avoid float types try to derive Eq * fix(rust-server): Fix parts to compile samples successfully * fix(rust-server): Allow clippy::redundant_clone instead of removing redundant map_err * fix(rust-server): Resolve and dismiss lots of warnings to satisfy clippy on samples * build(rust-server): Add clippy execution to sample integration test * build(rust-server): Add .cargo/config to the test root to use -Dwarnings flag in tests * fix(rust-server): Allow unused_mut to avoid compilation fails in some environments
This commit is contained in:
@@ -568,6 +568,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
// basePath on the front.
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
// Replace {baseName} with (?P<baseName>[^/?#]*) for regex
|
||||
// TODO: Sanitize baseName to avoid using '-' (see clippy::invalid_regex)
|
||||
String paramSearch = "{" + param.baseName + "}";
|
||||
String paramReplace = "(?P<" + param.baseName + ">[^/?#]*)";
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
@@ -58,7 +58,7 @@ impl<T> RequestParser<T> for ApiRequestParser {
|
||||
{{#urls}}
|
||||
{{#requests}}
|
||||
// {{{operationId}}} - {{{httpMethod}}} {{{path}}}
|
||||
&hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"),
|
||||
hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"),
|
||||
{{/requests}}
|
||||
{{/urls}}
|
||||
{{/callbacks}}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
¶m_{{{paramName}}}.iter().map(ToString::to_string).collect::<Vec<String>>().join(","));
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
¶m_{{{paramName}}}.to_string());
|
||||
¶m_{{{paramName}}}{{^isString}}.to_string(){{/isString}});
|
||||
{{/isArray}}
|
||||
{{/x-consumes-json}}
|
||||
{{/vendorExtensions}}
|
||||
@@ -60,10 +60,8 @@
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInQuery}}
|
||||
if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
|
||||
if let AuthData::ApiKey(ref api_key) = *auth_data {
|
||||
query_string.append_pair("{{keyParamName}}", api_key);
|
||||
}
|
||||
if let Some(AuthData::ApiKey(ref api_key)) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
|
||||
query_string.append_pair("{{keyParamName}}", api_key);
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
@@ -187,8 +185,8 @@
|
||||
// no such boundary is used.
|
||||
let mut boundary = generate_boundary();
|
||||
for b in boundary.iter_mut() {
|
||||
if b == &('/' as u8) {
|
||||
*b = '=' as u8;
|
||||
if b == &(b'/') {
|
||||
*b = b'=';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +255,7 @@
|
||||
{{/x-consumes-plain-text}}
|
||||
{{#required}}
|
||||
{{#x-consumes-xml}}
|
||||
let body = param_{{{paramName}}}.to_xml();
|
||||
let body = param_{{{paramName}}}.as_xml();
|
||||
{{/x-consumes-xml}}
|
||||
{{#x-consumes-json}}
|
||||
let body = serde_json::to_string(¶m_{{{paramName}}}).expect("impossible to fail to serialize");
|
||||
@@ -266,7 +264,7 @@
|
||||
{{^required}}
|
||||
let body = param_{{{paramName}}}.map(|ref body| {
|
||||
{{#x-consumes-xml}}
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
{{/x-consumes-xml}}
|
||||
{{#x-consumes-json}}
|
||||
serde_json::to_string(body).expect("impossible to fail to serialize")
|
||||
@@ -305,8 +303,10 @@
|
||||
});
|
||||
|
||||
{{#hasAuthMethods}}
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
{{#authMethods}}
|
||||
{{#isBasicBasic}}
|
||||
@@ -364,6 +364,7 @@
|
||||
{{/required}}
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("{{{nameInLowerCase}}}"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_{{{paramName}}}.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
@@ -398,12 +399,11 @@
|
||||
return Err(ApiError(format!("Invalid response header {{baseName}} for response {{code}} - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_{{{name}}} = response_{{{name}}}.0;
|
||||
{{#required}}
|
||||
response_{{{name}}}
|
||||
response_{{{name}}}.0
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
Some(response_{{{name}}})
|
||||
Some(response_{{{name}}}.0)
|
||||
{{/required}}
|
||||
},
|
||||
{{#required}}
|
||||
@@ -450,7 +450,7 @@
|
||||
{{#headers}}
|
||||
{{#-first}}
|
||||
{
|
||||
body: body,
|
||||
body,
|
||||
{{/-first}}
|
||||
{{{name}}}: response_{{name}},
|
||||
{{#-last}}
|
||||
|
||||
@@ -110,7 +110,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Basic;
|
||||
use std::ops::Deref;
|
||||
if let Some(basic) = swagger::auth::from_headers::<Basic>(&headers) {
|
||||
if let Some(basic) = swagger::auth::from_headers::<Basic>(headers) {
|
||||
let auth_data = AuthData::Basic(basic);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -123,7 +123,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Bearer;
|
||||
use std::ops::Deref;
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) {
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) {
|
||||
let auth_data = AuthData::Bearer(bearer);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -137,7 +137,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Bearer;
|
||||
use std::ops::Deref;
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) {
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) {
|
||||
let auth_data = AuthData::Bearer(bearer);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -151,7 +151,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::api_key_from_header;
|
||||
|
||||
if let Some(header) = api_key_from_header(&headers, "{{{keyParamName}}}") {
|
||||
if let Some(header) = api_key_from_header(headers, "{{{keyParamName}}}") {
|
||||
let auth_data = AuthData::ApiKey(header);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -165,7 +165,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
let key = form_urlencoded::parse(request.uri().query().unwrap_or_default().as_bytes())
|
||||
.filter(|e| e.0 == "{{{keyParamName}}}")
|
||||
.map(|e| e.1.clone().into_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
if let Some(key) = key {
|
||||
let auth_data = AuthData::ApiKey(key);
|
||||
let context = context.push(Some(auth_data));
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
{{{externCrateName}}}::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -26,6 +27,7 @@ pub const API_VERSION: &str = "{{{.}}}";
|
||||
{{/apiInfo}}
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -53,6 +55,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
@@ -223,7 +226,7 @@ pub trait CallbackApiNoContext<C: Send + Sync> {
|
||||
pub trait CallbackContextWrapperExt<C: Send + Sync> where Self: Sized
|
||||
{
|
||||
/// Binds this API to a context.
|
||||
fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>;
|
||||
fn with_context(self, context: C) -> ContextWrapper<Self, C>;
|
||||
}
|
||||
|
||||
impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackContextWrapperExt<C> for T {
|
||||
|
||||
@@ -33,7 +33,7 @@ impl std::fmt::Display for {{{classname}}} {
|
||||
match *self {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{classname}}}::{{{name}}} => write!(f, "{}", {{{value}}}),
|
||||
{{{classname}}}::{{{name}}} => write!(f, {{{value}}}),
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ impl<'a> std::iter::IntoIterator for &'a {{{classname}}} {
|
||||
type IntoIter = std::slice::Iter<'a, {{{arrayModelType}}}>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
(&self.0).into_iter()
|
||||
(&self.0).iter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ impl<'a> std::iter::IntoIterator for &'a mut {{{classname}}} {
|
||||
type IntoIter = std::slice::IterMut<'a, {{{arrayModelType}}}>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
(&mut self.0).into_iter()
|
||||
(&mut self.0).iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ impl std::ops::DerefMut for {{{classname}}} {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,9 +274,10 @@ pub struct {{{classname}}} {
|
||||
}
|
||||
|
||||
impl {{{classname}}} {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new({{#vars}}{{^defaultValue}}{{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/vars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}} {{{name}}}: {{{defaultValue}}}{{^defaultValue}}{{{name}}}{{/defaultValue}},
|
||||
{{#vars}} {{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
@@ -287,64 +288,68 @@ impl {{{classname}}} {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
{{#vars}}
|
||||
{{#isByteArray}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isBinary}}
|
||||
{{#isMap}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isMap}}
|
||||
{{^isPrimitiveType}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isPrimitiveType}}
|
||||
{{^isByteArray}}{{^isBinary}}{{^isMap}}{{#isPrimitiveType}}
|
||||
{{#required}}
|
||||
params.push("{{{baseName}}}".to_string());
|
||||
Some("{{{baseName}}}".to_string()),
|
||||
{{^isArray}}
|
||||
{{#isNullable}}
|
||||
params.push(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
Some(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string())),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push(self.{{{name}}}.to_string());
|
||||
Some(self.{{{name}}}.to_string()),
|
||||
{{/isNullable}}
|
||||
{{/isArray}}
|
||||
{{#isArray}}
|
||||
{{#isNullable}}
|
||||
params.push(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()));
|
||||
Some(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
Some(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")),
|
||||
{{/isNullable}}
|
||||
{{/isArray}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if let Some(ref {{{name}}}) = self.{{{name}}} {
|
||||
params.push("{{{baseName}}}".to_string());
|
||||
self.{{{name}}}.as_ref().map(|{{{name}}}| {
|
||||
vec![
|
||||
"{{{baseName}}}".to_string(),
|
||||
{{^isArray}}
|
||||
{{#isNullable}}
|
||||
params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push({{{name}}}.to_string());
|
||||
{{{name}}}.to_string(),
|
||||
{{/isNullable}}
|
||||
{{/isArray}}
|
||||
{{#isArray}}
|
||||
{{#isNullable}}
|
||||
params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()));
|
||||
{{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push({{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
|
||||
{{/isNullable}}
|
||||
{{/isArray}}
|
||||
}
|
||||
].join(",")
|
||||
}),
|
||||
{{/required}}
|
||||
{{/isPrimitiveType}}{{/isMap}}{{/isBinary}}{{/isByteArray}}
|
||||
{{/vars}}
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,8 +360,9 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
{{#vars}}
|
||||
pub {{{name}}}: Vec<{{{dataType}}}>,
|
||||
@@ -366,7 +372,7 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -376,6 +382,7 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
{{#vars}}
|
||||
{{#isBinary}}
|
||||
@@ -394,7 +401,8 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
"{{{baseName}}}" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in {{{classname}}}".to_string()),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
"{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
{{/isNullable}}
|
||||
{{/isContainer}}
|
||||
{{/isByteArray}}
|
||||
@@ -415,7 +423,7 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
{{{name}}}: std::result::Result::Err("Nullable types not supported in {{{classname}}}".to_string())?,
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{{name}}}: intermediate_rep.{{{name}}}.into_iter().next(){{#required}}.ok_or("{{{baseName}}} missing in {{{classname}}}".to_string())?{{/required}},
|
||||
{{{name}}}: intermediate_rep.{{{name}}}.into_iter().next(){{#required}}.ok_or_else(|| "{{{baseName}}} missing in {{{classname}}}".to_string())?{{/required}},
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
})
|
||||
@@ -479,7 +487,7 @@ impl {{{classname}}} {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
/// Will panic if serialisation fails.
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn to_xml(&self) -> String {
|
||||
pub(crate) fn as_xml(&self) -> String {
|
||||
{{#xmlNamespace}}
|
||||
let mut namespaces = std::collections::BTreeMap::new();
|
||||
// An empty string is used to indicate a global namespace in xmltree.
|
||||
|
||||
@@ -28,13 +28,13 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
// {{{operationId}}} - {{{httpMethod}}} {{{path}}}
|
||||
&hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"),
|
||||
hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"),
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// {{{operationId}}} - {{{httpMethod}}} {{{path}}}
|
||||
&hyper::Method::{{vendorExtensions.x-http-method}} if path.matched(paths::ID_{{vendorExtensions.x-path-id}}) => {
|
||||
hyper::Method::{{vendorExtensions.x-http-method}} if path.matched(paths::ID_{{vendorExtensions.x-path-id}}) => {
|
||||
{{#hasAuthMethods}}
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -50,10 +50,10 @@
|
||||
{{/x-consumes-multipart}}
|
||||
{{#x-has-path-params}}
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_{{{x-path-id}}}
|
||||
.captures(&path)
|
||||
.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())
|
||||
);
|
||||
@@ -139,7 +139,7 @@
|
||||
{{/required}}
|
||||
{{/vendorExtensions.x-consumes-json}}
|
||||
{{#vendorExtensions.x-consumes-json}}
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_{{{paramName}}} = match param_{{{paramName}}} {
|
||||
Some(param_{{{paramName}}}) => {
|
||||
let param_{{{paramName}}} =
|
||||
@@ -167,7 +167,7 @@
|
||||
{{/vendorExtensions.x-consumes-json}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_{{{paramName}}} = match param_{{{paramName}}} {
|
||||
Some(param_{{{paramName}}}) => {
|
||||
let param_{{{paramName}}} =
|
||||
@@ -292,7 +292,7 @@
|
||||
_ => {
|
||||
return Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Unable to process all message parts")))
|
||||
.body(Body::from("Unable to process all message parts".to_string()))
|
||||
.expect("Unable to create Bad Request response due to failure to process all message"))
|
||||
},
|
||||
};
|
||||
@@ -335,7 +335,7 @@
|
||||
return Ok(
|
||||
Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Missing required form parameter {{{paramName}}}")))
|
||||
.body(Body::from("Missing required form parameter {{{paramName}}}".to_string()))
|
||||
.expect("Unable to create Bad Request due to missing required form parameter {{{paramName}}}"))
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
@@ -378,9 +378,9 @@
|
||||
// Extract the top-level content type header.
|
||||
let content_type_mime = headers
|
||||
.get(CONTENT_TYPE)
|
||||
.ok_or("Missing content-type header".to_string())
|
||||
.ok_or_else(|| "Missing content-type header".to_string())
|
||||
.and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for {{operationId}}: {}", e)))
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for {{operationId}}")));
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for {{operationId}}".to_string()));
|
||||
|
||||
// Insert top-level content type header into a Headers object.
|
||||
let mut multi_part_headers = Headers::new();
|
||||
@@ -415,7 +415,7 @@
|
||||
for node in nodes {
|
||||
if let Node::Part(part) = node {
|
||||
let content_type = part.content_type().map(|x| format!("{}",x));
|
||||
match content_type.as_ref().map(|x| x.as_str()) {
|
||||
match content_type.as_deref() {
|
||||
{{#formParams}}
|
||||
{{^isBinary}}
|
||||
Some("{{{contentType}}}") if param_{{{paramName}}}.is_none() => {
|
||||
@@ -464,7 +464,7 @@
|
||||
Some(x) => x,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Missing required multipart/related parameter {{{paramName}}}")))
|
||||
.body(Body::from("Missing required multipart/related parameter {{{paramName}}}".to_string()))
|
||||
.expect("Unable to create Bad Request response for missing multipart/related parameter {{{paramName}}} due to schema"))
|
||||
};
|
||||
{{/required}}
|
||||
@@ -488,7 +488,7 @@
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
{{#bodyParams}}
|
||||
@@ -641,7 +641,7 @@
|
||||
},
|
||||
Err(e) => Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Couldn't read multipart body")))
|
||||
.body(Body::from("Couldn't read multipart body".to_string()))
|
||||
.expect("Unable to create Bad Request response due to unable read multipart body")),
|
||||
}
|
||||
{{/vendorExtensions}}
|
||||
|
||||
@@ -14,6 +14,7 @@ mod paths {
|
||||
{{#hasPathParams}}
|
||||
lazy_static! {
|
||||
pub static ref REGEX_{{{PATH_ID}}}: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^{{{basePathWithoutHost}}}{{{pathRegEx}}}")
|
||||
.expect("Unable to create regex for {{{PATH_ID}}}");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,4 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
This match statement is duplicated below in `parse_operation_id()`.
|
||||
Please update both places if changing how this code is autogenerated.
|
||||
}}
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
18
samples/server/petstore/rust-server/.cargo/config
Normal file
18
samples/server/petstore/rust-server/.cargo/config
Normal file
@@ -0,0 +1,18 @@
|
||||
[build]
|
||||
rustflags = [
|
||||
"-W", "missing_docs", # detects missing documentation for public members
|
||||
|
||||
"-W", "trivial_casts", # detects trivial casts which could be removed
|
||||
|
||||
"-W", "trivial_numeric_casts", # detects trivial casts of numeric types which could be removed
|
||||
|
||||
"-W", "unsafe_code", # usage of `unsafe` code
|
||||
|
||||
"-W", "unused_qualifications", # detects unnecessarily qualified names
|
||||
|
||||
"-W", "unused_extern_crates", # extern crates that are never used
|
||||
|
||||
"-W", "unused_import_braces", # unnecessary braces around an imported item
|
||||
|
||||
"-D", "warnings", # all warnings should be denied
|
||||
]
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
multipart_v3::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -429,8 +429,8 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
// no such boundary is used.
|
||||
let mut boundary = generate_boundary();
|
||||
for b in boundary.iter_mut() {
|
||||
if b == &('/' as u8) {
|
||||
*b = '=' as u8;
|
||||
if b == &(b'/') {
|
||||
*b = b'=';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,8 +722,8 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
// no such boundary is used.
|
||||
let mut boundary = generate_boundary();
|
||||
for b in boundary.iter_mut() {
|
||||
if b == &('/' as u8) {
|
||||
*b = '=' as u8;
|
||||
if b == &(b'/') {
|
||||
*b = b'=';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -33,6 +34,7 @@ pub enum MultipleIdenticalMimeTypesPostResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -63,6 +65,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
@@ -21,11 +21,12 @@ pub struct MultipartRelatedRequest {
|
||||
}
|
||||
|
||||
impl MultipartRelatedRequest {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(required_binary_field: swagger::ByteArray, ) -> MultipartRelatedRequest {
|
||||
MultipartRelatedRequest {
|
||||
object_field: None,
|
||||
optional_binary_field: None,
|
||||
required_binary_field: required_binary_field,
|
||||
required_binary_field,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,16 +36,18 @@ impl MultipartRelatedRequest {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for MultipartRelatedRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
// Skipping object_field in query parameter serialization
|
||||
let params: Vec<Option<String>> = vec![
|
||||
// Skipping object_field in query parameter serialization
|
||||
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +58,9 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub object_field: Vec<models::MultipartRequestObjectField>,
|
||||
pub optional_binary_field: Vec<swagger::ByteArray>,
|
||||
@@ -66,7 +70,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -76,8 +80,10 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
"optional_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()),
|
||||
"required_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing MultipartRelatedRequest".to_string())
|
||||
@@ -92,7 +98,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
std::result::Result::Ok(MultipartRelatedRequest {
|
||||
object_field: intermediate_rep.object_field.into_iter().next(),
|
||||
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
|
||||
required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or("required_binary_field missing in MultipartRelatedRequest".to_string())?,
|
||||
required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or_else(|| "required_binary_field missing in MultipartRelatedRequest".to_string())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -149,9 +155,10 @@ pub struct MultipartRequestObjectField {
|
||||
}
|
||||
|
||||
impl MultipartRequestObjectField {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(field_a: String, ) -> MultipartRequestObjectField {
|
||||
MultipartRequestObjectField {
|
||||
field_a: field_a,
|
||||
field_a,
|
||||
field_b: None,
|
||||
}
|
||||
}
|
||||
@@ -162,18 +169,22 @@ impl MultipartRequestObjectField {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for MultipartRequestObjectField {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
params.push("field_a".to_string());
|
||||
params.push(self.field_a.to_string());
|
||||
Some("field_a".to_string()),
|
||||
Some(self.field_a.to_string()),
|
||||
|
||||
|
||||
if let Some(ref field_b) = self.field_b {
|
||||
params.push("field_b".to_string());
|
||||
params.push(field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
}
|
||||
self.field_b.as_ref().map(|field_b| {
|
||||
vec![
|
||||
"field_b".to_string(),
|
||||
field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +195,9 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub field_a: Vec<String>,
|
||||
pub field_b: Vec<Vec<String>>,
|
||||
@@ -194,7 +206,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -204,8 +216,10 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
"field_b" => return std::result::Result::Err("Parsing a container in this style is not supported in MultipartRequestObjectField".to_string()),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing MultipartRequestObjectField".to_string())
|
||||
}
|
||||
@@ -217,7 +231,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(MultipartRequestObjectField {
|
||||
field_a: intermediate_rep.field_a.into_iter().next().ok_or("field_a missing in MultipartRequestObjectField".to_string())?,
|
||||
field_a: intermediate_rep.field_a.into_iter().next().ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
|
||||
field_b: intermediate_rep.field_b.into_iter().next(),
|
||||
})
|
||||
}
|
||||
@@ -276,6 +290,7 @@ pub struct MultipleIdenticalMimeTypesPostRequest {
|
||||
}
|
||||
|
||||
impl MultipleIdenticalMimeTypesPostRequest {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
|
||||
MultipleIdenticalMimeTypesPostRequest {
|
||||
binary1: None,
|
||||
@@ -289,14 +304,16 @@ impl MultipleIdenticalMimeTypesPostRequest {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for MultipleIdenticalMimeTypesPostRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
// Skipping binary1 in query parameter serialization
|
||||
// Skipping binary1 in query parameter serialization
|
||||
let params: Vec<Option<String>> = vec![
|
||||
// Skipping binary1 in query parameter serialization
|
||||
// Skipping binary1 in query parameter serialization
|
||||
|
||||
// Skipping binary2 in query parameter serialization
|
||||
// Skipping binary2 in query parameter serialization
|
||||
// Skipping binary2 in query parameter serialization
|
||||
// Skipping binary2 in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,8 +324,9 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub binary1: Vec<swagger::ByteArray>,
|
||||
pub binary2: Vec<swagger::ByteArray>,
|
||||
@@ -317,7 +335,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -327,6 +345,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"binary1" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()),
|
||||
"binary2" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()),
|
||||
|
||||
@@ -109,7 +109,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,10 +148,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => {
|
||||
// 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.
|
||||
@@ -165,9 +165,9 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
// Extract the top-level content type header.
|
||||
let content_type_mime = headers
|
||||
.get(CONTENT_TYPE)
|
||||
.ok_or("Missing content-type header".to_string())
|
||||
.ok_or_else(|| "Missing content-type header".to_string())
|
||||
.and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for MultipartRelatedRequestPost: {}", e)))
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for MultipartRelatedRequestPost")));
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for MultipartRelatedRequestPost".to_string()));
|
||||
|
||||
// Insert top-level content type header into a Headers object.
|
||||
let mut multi_part_headers = Headers::new();
|
||||
@@ -202,7 +202,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
for node in nodes {
|
||||
if let Node::Part(part) = node {
|
||||
let content_type = part.content_type().map(|x| format!("{}",x));
|
||||
match content_type.as_ref().map(|x| x.as_str()) {
|
||||
match content_type.as_deref() {
|
||||
Some("application/json") if param_object_field.is_none() => {
|
||||
// Extract JSON part.
|
||||
let deserializer = &mut serde_json::Deserializer::from_slice(part.body.as_slice());
|
||||
@@ -244,7 +244,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
Some(x) => x,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Missing required multipart/related parameter required_binary_field")))
|
||||
.body(Body::from("Missing required multipart/related parameter required_binary_field".to_string()))
|
||||
.expect("Unable to create Bad Request response for missing multipart/related parameter required_binary_field due to schema"))
|
||||
};
|
||||
|
||||
@@ -257,7 +257,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -285,7 +285,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// MultipartRequestPost - POST /multipart_request
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => {
|
||||
let boundary = match swagger::multipart::form::boundary(&headers) {
|
||||
Some(boundary) => boundary.to_string(),
|
||||
None => return Ok(Response::builder()
|
||||
@@ -310,7 +310,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
_ => {
|
||||
return Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Unable to process all message parts")))
|
||||
.body(Body::from("Unable to process all message parts".to_string()))
|
||||
.expect("Unable to create Bad Request response due to failure to process all message"))
|
||||
},
|
||||
};
|
||||
@@ -336,7 +336,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
return Ok(
|
||||
Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Missing required form parameter string_field")))
|
||||
.body(Body::from("Missing required form parameter string_field".to_string()))
|
||||
.expect("Unable to create Bad Request due to missing required form parameter string_field"))
|
||||
}
|
||||
};
|
||||
@@ -400,7 +400,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
return Ok(
|
||||
Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Missing required form parameter binary_field")))
|
||||
.body(Body::from("Missing required form parameter binary_field".to_string()))
|
||||
.expect("Unable to create Bad Request due to missing required form parameter binary_field"))
|
||||
}
|
||||
};
|
||||
@@ -414,7 +414,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -436,13 +436,13 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
Err(e) => Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Couldn't read multipart body")))
|
||||
.body(Body::from("Couldn't read multipart body".to_string()))
|
||||
.expect("Unable to create Bad Request response due to unable read multipart body")),
|
||||
}
|
||||
},
|
||||
|
||||
// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => {
|
||||
// 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.
|
||||
@@ -456,9 +456,9 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
// Extract the top-level content type header.
|
||||
let content_type_mime = headers
|
||||
.get(CONTENT_TYPE)
|
||||
.ok_or("Missing content-type header".to_string())
|
||||
.ok_or_else(|| "Missing content-type header".to_string())
|
||||
.and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for MultipleIdenticalMimeTypesPost: {}", e)))
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for MultipleIdenticalMimeTypesPost")));
|
||||
.and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for MultipleIdenticalMimeTypesPost".to_string()));
|
||||
|
||||
// Insert top-level content type header into a Headers object.
|
||||
let mut multi_part_headers = Headers::new();
|
||||
@@ -492,7 +492,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
for node in nodes {
|
||||
if let Node::Part(part) = node {
|
||||
let content_type = part.content_type().map(|x| format!("{}",x));
|
||||
match content_type.as_ref().map(|x| x.as_str()) {
|
||||
match content_type.as_deref() {
|
||||
Some("application/octet-stream") if param_binary1.is_none() => {
|
||||
param_binary1.get_or_insert(swagger::ByteArray(part.body));
|
||||
},
|
||||
@@ -523,7 +523,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -565,13 +565,13 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => Some("MultipartRelatedRequestPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => Some("MultipartRelatedRequestPost"),
|
||||
// MultipartRequestPost - POST /multipart_request
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => Some("MultipartRequestPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => Some("MultipartRequestPost"),
|
||||
// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||
&hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => Some("MultipleIdenticalMimeTypesPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => Some("MultipleIdenticalMimeTypesPost"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
no_example_v3::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -21,6 +22,7 @@ pub enum OpGetResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -35,6 +37,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct OpGetRequest {
|
||||
}
|
||||
|
||||
impl OpGetRequest {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> OpGetRequest {
|
||||
OpGetRequest {
|
||||
propery: None,
|
||||
@@ -26,14 +27,18 @@ impl OpGetRequest {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for OpGetRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
if let Some(ref propery) = self.propery {
|
||||
params.push("propery".to_string());
|
||||
params.push(propery.to_string());
|
||||
}
|
||||
self.propery.as_ref().map(|propery| {
|
||||
vec![
|
||||
"propery".to_string(),
|
||||
propery.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +49,9 @@ impl std::str::FromStr for OpGetRequest {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub propery: Vec<String>,
|
||||
}
|
||||
@@ -53,7 +59,7 @@ impl std::str::FromStr for OpGetRequest {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -63,8 +69,10 @@ impl std::str::FromStr for OpGetRequest {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing OpGetRequest".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,10 +137,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// OpGet - GET /op
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP) => {
|
||||
// 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.
|
||||
@@ -178,7 +178,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -225,9 +225,9 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// OpGet - GET /op
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP) => Some("OpGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP) => Some("OpGet"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
openapi_v3::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
openapi_v3::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -38,12 +38,14 @@ mod paths {
|
||||
pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK: usize = 0;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/(?P<request_query_url>.*)/callback$")
|
||||
.expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK");
|
||||
}
|
||||
pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: usize = 1;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/(?P<request_query_url>.*)/callback-with-header$")
|
||||
.expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK_WITH_HEADER");
|
||||
}
|
||||
@@ -112,7 +114,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -125,7 +127,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,15 +153,15 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header
|
||||
&hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK_WITH_HEADER in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER.as_str())
|
||||
);
|
||||
@@ -193,7 +195,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -215,12 +217,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CallbackCallbackPost - POST /{$request.query.url}/callback
|
||||
&hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_REQUEST_QUERY_URL_CALLBACK
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK.as_str())
|
||||
);
|
||||
@@ -233,7 +235,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -268,11 +270,11 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header
|
||||
&hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => Some("CallbackCallbackWithHeaderPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => Some("CallbackCallbackWithHeaderPost"),
|
||||
// CallbackCallbackPost - POST /{$request.query.url}/callback
|
||||
&hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => Some("CallbackCallbackPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => Some("CallbackCallbackPost"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
let query_string = {
|
||||
let mut query_string = form_urlencoded::Serializer::new("".to_owned());
|
||||
query_string.append_pair("url",
|
||||
¶m_url.to_string());
|
||||
¶m_url);
|
||||
query_string.finish()
|
||||
};
|
||||
if !query_string.is_empty() {
|
||||
@@ -850,6 +850,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
// Header parameters
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("x-header"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_x_header.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
@@ -1159,8 +1160,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -1481,8 +1484,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -1542,7 +1547,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
let query_string = {
|
||||
let mut query_string = form_urlencoded::Serializer::new("".to_owned());
|
||||
query_string.append_pair("url",
|
||||
¶m_url.to_string());
|
||||
¶m_url);
|
||||
query_string.finish()
|
||||
};
|
||||
if !query_string.is_empty() {
|
||||
@@ -1728,8 +1733,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header Success-Info for response 200 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_success_info = response_success_info.0;
|
||||
response_success_info
|
||||
response_success_info.0
|
||||
},
|
||||
None => return Err(ApiError(String::from("Required response header Success-Info for response 200 was not found."))),
|
||||
};
|
||||
@@ -1743,8 +1747,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header Bool-Header for response 200 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_bool_header = response_bool_header.0;
|
||||
Some(response_bool_header)
|
||||
Some(response_bool_header.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -1758,8 +1761,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header Object-Header for response 200 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_object_header = response_object_header.0;
|
||||
Some(response_object_header)
|
||||
Some(response_object_header.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -1775,7 +1777,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
})?;
|
||||
Ok(ResponsesWithHeadersGetResponse::Success
|
||||
{
|
||||
body: body,
|
||||
body,
|
||||
success_info: response_success_info,
|
||||
bool_header: response_bool_header,
|
||||
object_header: response_object_header,
|
||||
@@ -1792,8 +1794,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header Further-Info for response 412 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_further_info = response_further_info.0;
|
||||
Some(response_further_info)
|
||||
Some(response_further_info.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -1807,8 +1808,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header Failure-Info for response 412 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_failure_info = response_failure_info.0;
|
||||
Some(response_failure_info)
|
||||
Some(response_failure_info.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -2140,7 +2140,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
let body = param_duplicate_xml_object.map(|ref body| {
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
});
|
||||
if let Some(body) = body {
|
||||
*request.body_mut() = Body::from(body);
|
||||
@@ -2226,7 +2226,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
let body = param_another_xml_object.map(|ref body| {
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
});
|
||||
if let Some(body) = body {
|
||||
*request.body_mut() = Body::from(body);
|
||||
@@ -2322,7 +2322,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
let body = param_another_xml_array.map(|ref body| {
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
});
|
||||
if let Some(body) = body {
|
||||
*request.body_mut() = Body::from(body);
|
||||
@@ -2408,7 +2408,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
let body = param_xml_array.map(|ref body| {
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
});
|
||||
if let Some(body) = body {
|
||||
*request.body_mut() = Body::from(body);
|
||||
@@ -2494,7 +2494,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
let body = param_xml_object.map(|ref body| {
|
||||
body.to_xml()
|
||||
body.as_xml()
|
||||
});
|
||||
|
||||
if let Some(body) = body {
|
||||
|
||||
@@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Bearer;
|
||||
use std::ops::Deref;
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) {
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) {
|
||||
let auth_data = AuthData::Bearer(bearer);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -273,6 +274,7 @@ pub enum GetRepoInfoResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -408,6 +410,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
@@ -854,7 +857,7 @@ pub trait CallbackApiNoContext<C: Send + Sync> {
|
||||
pub trait CallbackContextWrapperExt<C: Send + Sync> where Self: Sized
|
||||
{
|
||||
/// Binds this API to a context.
|
||||
fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>;
|
||||
fn with_context(self, context: C) -> ContextWrapper<Self, C>;
|
||||
}
|
||||
|
||||
impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackContextWrapperExt<C> for T {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -275,6 +275,7 @@ impl<S, C> CallbackApi<C> for Client<S, C> where
|
||||
Some(param_information) => {
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("information"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_information.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
|
||||
@@ -90,6 +90,7 @@ mod paths {
|
||||
pub(crate) static ID_ENUM_IN_PATH_PATH_PARAM: usize = 3;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_ENUM_IN_PATH_PATH_PARAM: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/enum_in_path/(?P<path_param>[^/?#]*)$")
|
||||
.expect("Unable to create regex for ENUM_IN_PATH_PATH_PARAM");
|
||||
}
|
||||
@@ -107,6 +108,7 @@ mod paths {
|
||||
pub(crate) static ID_REPOS_REPOID: usize = 15;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_REPOS_REPOID: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/repos/(?P<repoId>[^/?#]*)$")
|
||||
.expect("Unable to create regex for REPOS_REPOID");
|
||||
}
|
||||
@@ -181,7 +183,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -194,7 +196,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,10 +222,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// AnyOfGet - GET /any-of
|
||||
&hyper::Method::GET if path.matched(paths::ID_ANY_OF) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_ANY_OF) => {
|
||||
// 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::<Vec<_>>();
|
||||
let param_any_of = query_params.iter().filter(|e| e.0 == "any-of").map(|e| e.1.to_owned())
|
||||
@@ -242,7 +244,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -293,11 +295,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CallbackWithHeaderPost - POST /callback-with-header
|
||||
&hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => {
|
||||
// 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::<Vec<_>>();
|
||||
let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_url = match param_url {
|
||||
Some(param_url) => {
|
||||
let param_url =
|
||||
@@ -328,7 +330,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -350,7 +352,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// ComplexQueryParamGet - GET /complex-query-param
|
||||
&hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => {
|
||||
// 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::<Vec<_>>();
|
||||
let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.to_owned())
|
||||
@@ -369,7 +371,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -391,12 +393,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
|
||||
&hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_ENUM_IN_PATH_PATH_PARAM
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE ENUM_IN_PATH_PATH_PARAM in set but failed match against \"{}\"", path, paths::REGEX_ENUM_IN_PATH_PATH_PARAM.as_str())
|
||||
);
|
||||
@@ -422,7 +424,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -444,11 +446,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// JsonComplexQueryParamGet - GET /json-complex-query-param
|
||||
&hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => {
|
||||
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
|
||||
let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>();
|
||||
let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_list_of_strings = match param_list_of_strings {
|
||||
Some(param_list_of_strings) => {
|
||||
let param_list_of_strings =
|
||||
@@ -472,7 +474,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -494,7 +496,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// MandatoryRequestHeaderGet - GET /mandatory-request-header
|
||||
&hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => {
|
||||
// Header parameters
|
||||
let param_x_header = headers.get(HeaderName::from_static("x-header"));
|
||||
|
||||
@@ -525,7 +527,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -547,14 +549,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// MergePatchJsonGet - GET /merge-patch-json
|
||||
&hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => {
|
||||
let result = api_impl.merge_patch_json_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -583,14 +585,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// MultigetGet - GET /multiget
|
||||
&hyper::Method::GET if path.matched(paths::ID_MULTIGET) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_MULTIGET) => {
|
||||
let result = api_impl.multiget_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -685,11 +687,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -722,7 +724,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -744,14 +746,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// OneOfGet - GET /one-of
|
||||
&hyper::Method::GET if path.matched(paths::ID_ONE_OF) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_ONE_OF) => {
|
||||
let result = api_impl.one_of_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -780,14 +782,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// OverrideServerGet - GET /override-server
|
||||
&hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => {
|
||||
let result = api_impl.override_server_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -809,11 +811,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// ParamgetGet - GET /paramget
|
||||
&hyper::Method::GET if path.matched(paths::ID_PARAMGET) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_PARAMGET) => {
|
||||
// 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::<Vec<_>>();
|
||||
let param_uuid = query_params.iter().filter(|e| e.0 == "uuid").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_uuid = match param_uuid {
|
||||
Some(param_uuid) => {
|
||||
let param_uuid =
|
||||
@@ -830,7 +832,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
None => None,
|
||||
};
|
||||
let param_some_object = query_params.iter().filter(|e| e.0 == "someObject").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_some_object = match param_some_object {
|
||||
Some(param_some_object) => {
|
||||
let param_some_object =
|
||||
@@ -847,7 +849,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
None => None,
|
||||
};
|
||||
let param_some_list = query_params.iter().filter(|e| e.0 == "someList").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_some_list = match param_some_list {
|
||||
Some(param_some_list) => {
|
||||
let param_some_list =
|
||||
@@ -873,7 +875,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -902,11 +904,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -938,7 +940,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -960,11 +962,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// RegisterCallbackPost - POST /register-callback
|
||||
&hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => {
|
||||
// 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::<Vec<_>>();
|
||||
let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_url = match param_url {
|
||||
Some(param_url) => {
|
||||
let param_url =
|
||||
@@ -995,7 +997,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1017,7 +1019,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||
&hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => {
|
||||
// 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.
|
||||
@@ -1044,7 +1046,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1072,14 +1074,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// ResponsesWithHeadersGet - GET /responses_with_headers
|
||||
&hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => {
|
||||
let result = api_impl.responses_with_headers_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1199,14 +1201,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Rfc7807Get - GET /rfc7807
|
||||
&hyper::Method::GET if path.matched(paths::ID_RFC7807) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_RFC7807) => {
|
||||
let result = api_impl.rfc7807_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1257,7 +1259,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UntypedPropertyGet - GET /untyped_property
|
||||
&hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => {
|
||||
// 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.
|
||||
@@ -1285,7 +1287,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1320,14 +1322,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UuidGet - GET /uuid
|
||||
&hyper::Method::GET if path.matched(paths::ID_UUID) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_UUID) => {
|
||||
let result = api_impl.uuid_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1356,7 +1358,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// XmlExtraPost - POST /xml_extra
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => {
|
||||
// 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.
|
||||
@@ -1384,7 +1386,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1423,7 +1425,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// XmlOtherPost - POST /xml_other
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => {
|
||||
// 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.
|
||||
@@ -1451,7 +1453,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1501,7 +1503,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// XmlOtherPut - PUT /xml_other
|
||||
&hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => {
|
||||
// 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.
|
||||
@@ -1529,7 +1531,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1568,7 +1570,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// XmlPost - POST /xml
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_XML) => {
|
||||
// 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.
|
||||
@@ -1596,7 +1598,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1635,7 +1637,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// XmlPut - PUT /xml
|
||||
&hyper::Method::PUT if path.matched(paths::ID_XML) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_XML) => {
|
||||
// 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.
|
||||
@@ -1663,7 +1665,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1702,7 +1704,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CreateRepo - POST /repos
|
||||
&hyper::Method::POST if path.matched(paths::ID_REPOS) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_REPOS) => {
|
||||
// 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.
|
||||
@@ -1740,7 +1742,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1775,12 +1777,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetRepoInfo - GET /repos/{repoId}
|
||||
&hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_REPOS_REPOID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE REPOS_REPOID in set but failed match against \"{}\"", path, paths::REGEX_REPOS_REPOID.as_str())
|
||||
);
|
||||
@@ -1806,7 +1808,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1870,59 +1872,59 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// AnyOfGet - GET /any-of
|
||||
&hyper::Method::GET if path.matched(paths::ID_ANY_OF) => Some("AnyOfGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_ANY_OF) => Some("AnyOfGet"),
|
||||
// CallbackWithHeaderPost - POST /callback-with-header
|
||||
&hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => Some("CallbackWithHeaderPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => Some("CallbackWithHeaderPost"),
|
||||
// ComplexQueryParamGet - GET /complex-query-param
|
||||
&hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => Some("ComplexQueryParamGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => Some("ComplexQueryParamGet"),
|
||||
// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
|
||||
&hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"),
|
||||
// JsonComplexQueryParamGet - GET /json-complex-query-param
|
||||
&hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => Some("JsonComplexQueryParamGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => Some("JsonComplexQueryParamGet"),
|
||||
// MandatoryRequestHeaderGet - GET /mandatory-request-header
|
||||
&hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => Some("MandatoryRequestHeaderGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => Some("MandatoryRequestHeaderGet"),
|
||||
// MergePatchJsonGet - GET /merge-patch-json
|
||||
&hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => Some("MergePatchJsonGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => Some("MergePatchJsonGet"),
|
||||
// MultigetGet - GET /multiget
|
||||
&hyper::Method::GET if path.matched(paths::ID_MULTIGET) => Some("MultigetGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_MULTIGET) => Some("MultigetGet"),
|
||||
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Some("MultipleAuthSchemeGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Some("MultipleAuthSchemeGet"),
|
||||
// OneOfGet - GET /one-of
|
||||
&hyper::Method::GET if path.matched(paths::ID_ONE_OF) => Some("OneOfGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_ONE_OF) => Some("OneOfGet"),
|
||||
// OverrideServerGet - GET /override-server
|
||||
&hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => Some("OverrideServerGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => Some("OverrideServerGet"),
|
||||
// ParamgetGet - GET /paramget
|
||||
&hyper::Method::GET if path.matched(paths::ID_PARAMGET) => Some("ParamgetGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_PARAMGET) => Some("ParamgetGet"),
|
||||
// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Some("ReadonlyAuthSchemeGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Some("ReadonlyAuthSchemeGet"),
|
||||
// RegisterCallbackPost - POST /register-callback
|
||||
&hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => Some("RegisterCallbackPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => Some("RegisterCallbackPost"),
|
||||
// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||
&hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Some("RequiredOctetStreamPut"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Some("RequiredOctetStreamPut"),
|
||||
// ResponsesWithHeadersGet - GET /responses_with_headers
|
||||
&hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => Some("ResponsesWithHeadersGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => Some("ResponsesWithHeadersGet"),
|
||||
// Rfc7807Get - GET /rfc7807
|
||||
&hyper::Method::GET if path.matched(paths::ID_RFC7807) => Some("Rfc7807Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_RFC7807) => Some("Rfc7807Get"),
|
||||
// UntypedPropertyGet - GET /untyped_property
|
||||
&hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => Some("UntypedPropertyGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => Some("UntypedPropertyGet"),
|
||||
// UuidGet - GET /uuid
|
||||
&hyper::Method::GET if path.matched(paths::ID_UUID) => Some("UuidGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_UUID) => Some("UuidGet"),
|
||||
// XmlExtraPost - POST /xml_extra
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => Some("XmlExtraPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => Some("XmlExtraPost"),
|
||||
// XmlOtherPost - POST /xml_other
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPost"),
|
||||
// XmlOtherPut - PUT /xml_other
|
||||
&hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPut"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPut"),
|
||||
// XmlPost - POST /xml
|
||||
&hyper::Method::POST if path.matched(paths::ID_XML) => Some("XmlPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_XML) => Some("XmlPost"),
|
||||
// XmlPut - PUT /xml
|
||||
&hyper::Method::PUT if path.matched(paths::ID_XML) => Some("XmlPut"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_XML) => Some("XmlPut"),
|
||||
// CreateRepo - POST /repos
|
||||
&hyper::Method::POST if path.matched(paths::ID_REPOS) => Some("CreateRepo"),
|
||||
hyper::Method::POST if path.matched(paths::ID_REPOS) => Some("CreateRepo"),
|
||||
// GetRepoInfo - GET /repos/{repoId}
|
||||
&hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => Some("GetRepoInfo"),
|
||||
hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => Some("GetRepoInfo"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
ops_v3::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -237,6 +238,7 @@ pub enum Op9GetResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -394,6 +396,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
@@ -206,7 +206,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,17 +245,17 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// Op10Get - GET /op10
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP10) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP10) => {
|
||||
let result = api_impl.op10_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -277,14 +277,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op11Get - GET /op11
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP11) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP11) => {
|
||||
let result = api_impl.op11_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -306,14 +306,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op12Get - GET /op12
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP12) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP12) => {
|
||||
let result = api_impl.op12_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -335,14 +335,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op13Get - GET /op13
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP13) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP13) => {
|
||||
let result = api_impl.op13_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -364,14 +364,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op14Get - GET /op14
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP14) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP14) => {
|
||||
let result = api_impl.op14_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -393,14 +393,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op15Get - GET /op15
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP15) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP15) => {
|
||||
let result = api_impl.op15_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -422,14 +422,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op16Get - GET /op16
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP16) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP16) => {
|
||||
let result = api_impl.op16_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -451,14 +451,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op17Get - GET /op17
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP17) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP17) => {
|
||||
let result = api_impl.op17_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -480,14 +480,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op18Get - GET /op18
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP18) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP18) => {
|
||||
let result = api_impl.op18_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -509,14 +509,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op19Get - GET /op19
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP19) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP19) => {
|
||||
let result = api_impl.op19_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -538,14 +538,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op1Get - GET /op1
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP1) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP1) => {
|
||||
let result = api_impl.op1_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -567,14 +567,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op20Get - GET /op20
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP20) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP20) => {
|
||||
let result = api_impl.op20_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -596,14 +596,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op21Get - GET /op21
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP21) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP21) => {
|
||||
let result = api_impl.op21_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -625,14 +625,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op22Get - GET /op22
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP22) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP22) => {
|
||||
let result = api_impl.op22_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -654,14 +654,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op23Get - GET /op23
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP23) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP23) => {
|
||||
let result = api_impl.op23_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -683,14 +683,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op24Get - GET /op24
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP24) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP24) => {
|
||||
let result = api_impl.op24_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -712,14 +712,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op25Get - GET /op25
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP25) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP25) => {
|
||||
let result = api_impl.op25_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -741,14 +741,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op26Get - GET /op26
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP26) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP26) => {
|
||||
let result = api_impl.op26_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -770,14 +770,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op27Get - GET /op27
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP27) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP27) => {
|
||||
let result = api_impl.op27_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -799,14 +799,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op28Get - GET /op28
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP28) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP28) => {
|
||||
let result = api_impl.op28_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -828,14 +828,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op29Get - GET /op29
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP29) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP29) => {
|
||||
let result = api_impl.op29_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -857,14 +857,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op2Get - GET /op2
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP2) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP2) => {
|
||||
let result = api_impl.op2_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -886,14 +886,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op30Get - GET /op30
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP30) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP30) => {
|
||||
let result = api_impl.op30_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -915,14 +915,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op31Get - GET /op31
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP31) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP31) => {
|
||||
let result = api_impl.op31_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -944,14 +944,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op32Get - GET /op32
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP32) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP32) => {
|
||||
let result = api_impl.op32_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -973,14 +973,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op33Get - GET /op33
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP33) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP33) => {
|
||||
let result = api_impl.op33_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1002,14 +1002,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op34Get - GET /op34
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP34) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP34) => {
|
||||
let result = api_impl.op34_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1031,14 +1031,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op35Get - GET /op35
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP35) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP35) => {
|
||||
let result = api_impl.op35_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1060,14 +1060,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op36Get - GET /op36
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP36) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP36) => {
|
||||
let result = api_impl.op36_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1089,14 +1089,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op37Get - GET /op37
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP37) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP37) => {
|
||||
let result = api_impl.op37_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1118,14 +1118,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op3Get - GET /op3
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP3) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP3) => {
|
||||
let result = api_impl.op3_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1147,14 +1147,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op4Get - GET /op4
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP4) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP4) => {
|
||||
let result = api_impl.op4_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1176,14 +1176,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op5Get - GET /op5
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP5) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP5) => {
|
||||
let result = api_impl.op5_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1205,14 +1205,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op6Get - GET /op6
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP6) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP6) => {
|
||||
let result = api_impl.op6_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1234,14 +1234,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op7Get - GET /op7
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP7) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP7) => {
|
||||
let result = api_impl.op7_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1263,14 +1263,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op8Get - GET /op8
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP8) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP8) => {
|
||||
let result = api_impl.op8_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1292,14 +1292,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Op9Get - GET /op9
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP9) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_OP9) => {
|
||||
let result = api_impl.op9_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1369,81 +1369,81 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// Op10Get - GET /op10
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP10) => Some("Op10Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP10) => Some("Op10Get"),
|
||||
// Op11Get - GET /op11
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP11) => Some("Op11Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP11) => Some("Op11Get"),
|
||||
// Op12Get - GET /op12
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP12) => Some("Op12Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP12) => Some("Op12Get"),
|
||||
// Op13Get - GET /op13
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP13) => Some("Op13Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP13) => Some("Op13Get"),
|
||||
// Op14Get - GET /op14
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP14) => Some("Op14Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP14) => Some("Op14Get"),
|
||||
// Op15Get - GET /op15
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP15) => Some("Op15Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP15) => Some("Op15Get"),
|
||||
// Op16Get - GET /op16
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP16) => Some("Op16Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP16) => Some("Op16Get"),
|
||||
// Op17Get - GET /op17
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP17) => Some("Op17Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP17) => Some("Op17Get"),
|
||||
// Op18Get - GET /op18
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP18) => Some("Op18Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP18) => Some("Op18Get"),
|
||||
// Op19Get - GET /op19
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP19) => Some("Op19Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP19) => Some("Op19Get"),
|
||||
// Op1Get - GET /op1
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP1) => Some("Op1Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP1) => Some("Op1Get"),
|
||||
// Op20Get - GET /op20
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP20) => Some("Op20Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP20) => Some("Op20Get"),
|
||||
// Op21Get - GET /op21
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP21) => Some("Op21Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP21) => Some("Op21Get"),
|
||||
// Op22Get - GET /op22
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP22) => Some("Op22Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP22) => Some("Op22Get"),
|
||||
// Op23Get - GET /op23
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP23) => Some("Op23Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP23) => Some("Op23Get"),
|
||||
// Op24Get - GET /op24
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP24) => Some("Op24Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP24) => Some("Op24Get"),
|
||||
// Op25Get - GET /op25
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP25) => Some("Op25Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP25) => Some("Op25Get"),
|
||||
// Op26Get - GET /op26
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP26) => Some("Op26Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP26) => Some("Op26Get"),
|
||||
// Op27Get - GET /op27
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP27) => Some("Op27Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP27) => Some("Op27Get"),
|
||||
// Op28Get - GET /op28
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP28) => Some("Op28Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP28) => Some("Op28Get"),
|
||||
// Op29Get - GET /op29
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP29) => Some("Op29Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP29) => Some("Op29Get"),
|
||||
// Op2Get - GET /op2
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP2) => Some("Op2Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP2) => Some("Op2Get"),
|
||||
// Op30Get - GET /op30
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP30) => Some("Op30Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP30) => Some("Op30Get"),
|
||||
// Op31Get - GET /op31
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP31) => Some("Op31Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP31) => Some("Op31Get"),
|
||||
// Op32Get - GET /op32
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP32) => Some("Op32Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP32) => Some("Op32Get"),
|
||||
// Op33Get - GET /op33
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP33) => Some("Op33Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP33) => Some("Op33Get"),
|
||||
// Op34Get - GET /op34
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP34) => Some("Op34Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP34) => Some("Op34Get"),
|
||||
// Op35Get - GET /op35
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP35) => Some("Op35Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP35) => Some("Op35Get"),
|
||||
// Op36Get - GET /op36
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP36) => Some("Op36Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP36) => Some("Op36Get"),
|
||||
// Op37Get - GET /op37
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP37) => Some("Op37Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP37) => Some("Op37Get"),
|
||||
// Op3Get - GET /op3
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP3) => Some("Op3Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP3) => Some("Op3Get"),
|
||||
// Op4Get - GET /op4
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP4) => Some("Op4Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP4) => Some("Op4Get"),
|
||||
// Op5Get - GET /op5
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP5) => Some("Op5Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP5) => Some("Op5Get"),
|
||||
// Op6Get - GET /op6
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP6) => Some("Op6Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP6) => Some("Op6Get"),
|
||||
// Op7Get - GET /op7
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP7) => Some("Op7Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP7) => Some("Op7Get"),
|
||||
// Op8Get - GET /op8
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP8) => Some("Op8Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP8) => Some("Op8Get"),
|
||||
// Op9Get - GET /op9
|
||||
&hyper::Method::GET if path.matched(paths::ID_OP9) => Some("Op9Get"),
|
||||
hyper::Method::GET if path.matched(paths::ID_OP9) => Some("Op9Get"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
petstore_with_fake_endpoints_models_for_testing::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -1088,7 +1088,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
let query_string = {
|
||||
let mut query_string = form_urlencoded::Serializer::new("".to_owned());
|
||||
query_string.append_pair("query",
|
||||
¶m_query.to_string());
|
||||
¶m_query);
|
||||
query_string.finish()
|
||||
};
|
||||
if !query_string.is_empty() {
|
||||
@@ -1315,8 +1315,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Basic(ref basic_header) => {
|
||||
let auth = swagger::auth::Header(basic_header.clone());
|
||||
@@ -1392,7 +1394,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
}
|
||||
if let Some(param_enum_query_string) = param_enum_query_string {
|
||||
query_string.append_pair("enum_query_string",
|
||||
¶m_enum_query_string.to_string());
|
||||
¶m_enum_query_string);
|
||||
}
|
||||
if let Some(param_enum_query_integer) = param_enum_query_integer {
|
||||
query_string.append_pair("enum_query_integer",
|
||||
@@ -1444,6 +1446,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Some(param_enum_header_string_array) => {
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("enum_header_string_array"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_enum_header_string_array.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
@@ -1459,6 +1462,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Some(param_enum_header_string) => {
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("enum_header_string"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_enum_header_string.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
@@ -1677,10 +1681,8 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
// Query parameters
|
||||
let query_string = {
|
||||
let mut query_string = form_urlencoded::Serializer::new("".to_owned());
|
||||
if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
|
||||
if let AuthData::ApiKey(ref api_key) = *auth_data {
|
||||
query_string.append_pair("api_key_query", api_key);
|
||||
}
|
||||
if let Some(AuthData::ApiKey(ref api_key)) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
|
||||
query_string.append_pair("api_key_query", api_key);
|
||||
}
|
||||
query_string.finish()
|
||||
};
|
||||
@@ -1719,8 +1721,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
_ => {}
|
||||
}
|
||||
@@ -1799,7 +1803,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
};
|
||||
|
||||
// Body parameter
|
||||
let body = param_body.to_xml();
|
||||
let body = param_body.as_xml();
|
||||
*request.body_mut() = Body::from(body);
|
||||
|
||||
let header = "application/json";
|
||||
@@ -1813,8 +1817,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -1901,8 +1907,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -1923,6 +1931,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Some(param_api_key) => {
|
||||
request.headers_mut().append(
|
||||
HeaderName::from_static("api_key"),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
match header::IntoHeaderValue(param_api_key.clone()).try_into() {
|
||||
Ok(header) => header,
|
||||
Err(e) => {
|
||||
@@ -2005,8 +2014,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -2108,8 +2119,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -2210,8 +2223,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
_ => {}
|
||||
}
|
||||
@@ -2300,7 +2315,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create request: {}", e)))
|
||||
};
|
||||
|
||||
let body = param_body.to_xml();
|
||||
let body = param_body.as_xml();
|
||||
*request.body_mut() = Body::from(body);
|
||||
|
||||
let header = "application/json";
|
||||
@@ -2314,8 +2329,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -2425,8 +2442,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -2569,8 +2588,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
@@ -2738,8 +2759,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
_ => {}
|
||||
}
|
||||
@@ -3380,9 +3403,9 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
let query_string = {
|
||||
let mut query_string = form_urlencoded::Serializer::new("".to_owned());
|
||||
query_string.append_pair("username",
|
||||
¶m_username.to_string());
|
||||
¶m_username);
|
||||
query_string.append_pair("password",
|
||||
¶m_password.to_string());
|
||||
¶m_password);
|
||||
query_string.finish()
|
||||
};
|
||||
if !query_string.is_empty() {
|
||||
@@ -3423,8 +3446,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header X-Rate-Limit for response 200 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_x_rate_limit = response_x_rate_limit.0;
|
||||
Some(response_x_rate_limit)
|
||||
Some(response_x_rate_limit.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -3438,8 +3460,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
return Err(ApiError(format!("Invalid response header X-Expires-After for response 200 - {}", e)));
|
||||
},
|
||||
};
|
||||
let response_x_expires_after = response_x_expires_after.0;
|
||||
Some(response_x_expires_after)
|
||||
Some(response_x_expires_after.0)
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -3456,7 +3477,7 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?;
|
||||
Ok(LoginUserResponse::SuccessfulOperation
|
||||
{
|
||||
body: body,
|
||||
body,
|
||||
x_rate_limit: response_x_rate_limit,
|
||||
x_expires_after: response_x_expires_after,
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::api_key_from_header;
|
||||
|
||||
if let Some(header) = api_key_from_header(&headers, "api_key") {
|
||||
if let Some(header) = api_key_from_header(headers, "api_key") {
|
||||
let auth_data = AuthData::ApiKey(header);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -119,7 +119,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
let key = form_urlencoded::parse(request.uri().query().unwrap_or_default().as_bytes())
|
||||
.filter(|e| e.0 == "api_key_query")
|
||||
.map(|e| e.1.clone().into_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
if let Some(key) = key {
|
||||
let auth_data = AuthData::ApiKey(key);
|
||||
let context = context.push(Some(auth_data));
|
||||
@@ -131,7 +131,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Basic;
|
||||
use std::ops::Deref;
|
||||
if let Some(basic) = swagger::auth::from_headers::<Basic>(&headers) {
|
||||
if let Some(basic) = swagger::auth::from_headers::<Basic>(headers) {
|
||||
let auth_data = AuthData::Basic(basic);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
@@ -142,7 +142,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Bearer;
|
||||
use std::ops::Deref;
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) {
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) {
|
||||
let auth_data = AuthData::Bearer(bearer);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -316,6 +317,7 @@ pub enum UpdateUserResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -551,6 +553,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,6 +102,7 @@ mod paths {
|
||||
pub(crate) static ID_FAKE_HYPHENPARAM_HYPHEN_PARAM: usize = 3;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/v2/fake/hyphenParam/(?P<hyphen-param>[^/?#]*)$")
|
||||
.expect("Unable to create regex for FAKE_HYPHENPARAM_HYPHEN_PARAM");
|
||||
}
|
||||
@@ -120,12 +121,14 @@ mod paths {
|
||||
pub(crate) static ID_PET_PETID: usize = 16;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_PET_PETID: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)$")
|
||||
.expect("Unable to create regex for PET_PETID");
|
||||
}
|
||||
pub(crate) static ID_PET_PETID_UPLOADIMAGE: usize = 17;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_PET_PETID_UPLOADIMAGE: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)/uploadImage$")
|
||||
.expect("Unable to create regex for PET_PETID_UPLOADIMAGE");
|
||||
}
|
||||
@@ -134,6 +137,7 @@ mod paths {
|
||||
pub(crate) static ID_STORE_ORDER_ORDER_ID: usize = 20;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_STORE_ORDER_ORDER_ID: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/v2/store/order/(?P<order_id>[^/?#]*)$")
|
||||
.expect("Unable to create regex for STORE_ORDER_ORDER_ID");
|
||||
}
|
||||
@@ -145,6 +149,7 @@ mod paths {
|
||||
pub(crate) static ID_USER_USERNAME: usize = 26;
|
||||
lazy_static! {
|
||||
pub static ref REGEX_USER_USERNAME: regex::Regex =
|
||||
#[allow(clippy::invalid_regex)]
|
||||
regex::Regex::new(r"^/v2/user/(?P<username>[^/?#]*)$")
|
||||
.expect("Unable to create regex for USER_USERNAME");
|
||||
}
|
||||
@@ -211,7 +216,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -224,7 +229,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,10 +255,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// TestSpecialTags - PATCH /another-fake/dummy
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => {
|
||||
hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => {
|
||||
// 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.
|
||||
@@ -291,7 +296,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -333,14 +338,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// Call123example - GET /fake/operation-with-numeric-id
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => {
|
||||
let result = api_impl.call123example(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -362,7 +367,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FakeOuterBooleanSerialize - POST /fake/outer/boolean
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => {
|
||||
// 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.
|
||||
@@ -390,7 +395,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -432,7 +437,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FakeOuterCompositeSerialize - POST /fake/outer/composite
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => {
|
||||
// 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.
|
||||
@@ -460,7 +465,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -502,7 +507,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FakeOuterNumberSerialize - POST /fake/outer/number
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => {
|
||||
// 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.
|
||||
@@ -530,7 +535,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -572,7 +577,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FakeOuterStringSerialize - POST /fake/outer/string
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => {
|
||||
// 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.
|
||||
@@ -600,7 +605,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -642,14 +647,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => {
|
||||
let result = api_impl.fake_response_with_numerical_description(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -671,12 +676,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// HyphenParam - GET /fake/hyphenParam/{hyphen-param}
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE FAKE_HYPHENPARAM_HYPHEN_PARAM in set but failed match against \"{}\"", path, paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM.as_str())
|
||||
);
|
||||
@@ -702,7 +707,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -724,11 +729,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestBodyWithQueryParams - PUT /fake/body-with-query-params
|
||||
&hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => {
|
||||
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
|
||||
let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>();
|
||||
let param_query = query_params.iter().filter(|e| e.0 == "query").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_query = match param_query {
|
||||
Some(param_query) => {
|
||||
let param_query =
|
||||
@@ -790,7 +795,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -825,7 +830,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestClientModel - PATCH /fake
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_FAKE) => {
|
||||
hyper::Method::PATCH if path.matched(paths::ID_FAKE) => {
|
||||
// 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.
|
||||
@@ -863,7 +868,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -905,11 +910,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestEndpointParameters - POST /fake
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -952,7 +957,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -978,7 +983,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestEnumParameters - GET /fake
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE) => {
|
||||
// Header parameters
|
||||
let param_enum_header_string_array = headers.get(HeaderName::from_static("enum_header_string_array"));
|
||||
|
||||
@@ -1028,7 +1033,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
None
|
||||
};
|
||||
let param_enum_query_string = query_params.iter().filter(|e| e.0 == "enum_query_string").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_enum_query_string = match param_enum_query_string {
|
||||
Some(param_enum_query_string) => {
|
||||
let param_enum_query_string =
|
||||
@@ -1045,7 +1050,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
None => None,
|
||||
};
|
||||
let param_enum_query_integer = query_params.iter().filter(|e| e.0 == "enum_query_integer").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_enum_query_integer = match param_enum_query_integer {
|
||||
Some(param_enum_query_integer) => {
|
||||
let param_enum_query_integer =
|
||||
@@ -1062,7 +1067,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
None => None,
|
||||
};
|
||||
let param_enum_query_double = query_params.iter().filter(|e| e.0 == "enum_query_double").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_enum_query_double = match param_enum_query_double {
|
||||
Some(param_enum_query_double) => {
|
||||
let param_enum_query_double =
|
||||
@@ -1095,7 +1100,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1121,7 +1126,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestInlineAdditionalProperties - POST /fake/inline-additionalProperties
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => {
|
||||
// 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.
|
||||
@@ -1159,7 +1164,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1194,7 +1199,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestJsonFormData - GET /fake/jsonFormData
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => {
|
||||
// Form parameters
|
||||
let param_param = "param_example".to_string();
|
||||
let param_param2 = "param2_example".to_string();
|
||||
@@ -1207,7 +1212,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1229,11 +1234,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// TestClassname - PATCH /fake_classname_test
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => {
|
||||
hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1277,7 +1282,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1319,11 +1324,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// AddPet - POST /pet
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_PET) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1387,7 +1392,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1422,11 +1427,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// DeletePet - DELETE /pet/{petId}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => {
|
||||
hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1454,10 +1459,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
}
|
||||
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_PET_PETID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str())
|
||||
);
|
||||
@@ -1504,7 +1509,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1526,11 +1531,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FindPetsByStatus - GET /pet/findByStatus
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1570,7 +1575,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1603,11 +1608,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FindPetsByTags - GET /pet/findByTags
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1647,7 +1652,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1680,11 +1685,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetPetById - GET /pet/{petId}
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_PETID) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_PETID) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1692,10 +1697,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
}
|
||||
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_PET_PETID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str())
|
||||
);
|
||||
@@ -1721,7 +1726,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1758,11 +1763,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UpdatePet - PUT /pet
|
||||
&hyper::Method::PUT if path.matched(paths::ID_PET) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_PET) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1826,7 +1831,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -1869,11 +1874,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UpdatePetWithForm - POST /pet/{petId}
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET_PETID) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_PET_PETID) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1901,10 +1906,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
}
|
||||
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_PET_PETID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str())
|
||||
);
|
||||
@@ -1936,7 +1941,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -1958,11 +1963,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UploadFile - POST /pet/{petId}/uploadImage
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -1998,10 +2003,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
};
|
||||
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_PET_PETID_UPLOADIMAGE
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE PET_PETID_UPLOADIMAGE in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID_UPLOADIMAGE.as_str())
|
||||
);
|
||||
@@ -2036,7 +2041,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
_ => {
|
||||
return Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Unable to process all message parts")))
|
||||
.body(Body::from("Unable to process all message parts".to_string()))
|
||||
.expect("Unable to create Bad Request response due to failure to process all message"))
|
||||
},
|
||||
};
|
||||
@@ -2097,7 +2102,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2126,18 +2131,18 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
Err(e) => Ok(Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(format!("Couldn't read multipart body")))
|
||||
.body(Body::from("Couldn't read multipart body".to_string()))
|
||||
.expect("Unable to create Bad Request response due to unable read multipart body")),
|
||||
}
|
||||
},
|
||||
|
||||
// DeleteOrder - DELETE /store/order/{order_id}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => {
|
||||
hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_STORE_ORDER_ORDER_ID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str())
|
||||
);
|
||||
@@ -2163,7 +2168,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2189,11 +2194,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetInventory - GET /store/inventory
|
||||
&hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -2206,7 +2211,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2235,12 +2240,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetOrderById - GET /store/order/{order_id}
|
||||
&hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_STORE_ORDER_ORDER_ID
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str())
|
||||
);
|
||||
@@ -2266,7 +2271,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2303,7 +2308,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// PlaceOrder - POST /store/order
|
||||
&hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => {
|
||||
// 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.
|
||||
@@ -2341,7 +2346,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -2387,7 +2392,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CreateUser - POST /user
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_USER) => {
|
||||
// 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.
|
||||
@@ -2425,7 +2430,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -2460,7 +2465,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CreateUsersWithArrayInput - POST /user/createWithArray
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => {
|
||||
// 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.
|
||||
@@ -2498,7 +2503,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -2533,7 +2538,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// CreateUsersWithListInput - POST /user/createWithList
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => {
|
||||
// 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.
|
||||
@@ -2571,7 +2576,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -2606,12 +2611,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// DeleteUser - DELETE /user/{username}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => {
|
||||
hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_USER_USERNAME
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str())
|
||||
);
|
||||
@@ -2637,7 +2642,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2663,12 +2668,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetUserByName - GET /user/{username}
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_USER_USERNAME
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str())
|
||||
);
|
||||
@@ -2694,7 +2699,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2731,11 +2736,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// LoginUser - GET /user/login
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => {
|
||||
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
|
||||
let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>();
|
||||
let param_username = query_params.iter().filter(|e| e.0 == "username").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_username = match param_username {
|
||||
Some(param_username) => {
|
||||
let param_username =
|
||||
@@ -2759,7 +2764,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
.expect("Unable to create Bad Request response for missing query parameter username")),
|
||||
};
|
||||
let param_password = query_params.iter().filter(|e| e.0 == "password").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
.next();
|
||||
let param_password = match param_password {
|
||||
Some(param_password) => {
|
||||
let param_password =
|
||||
@@ -2791,7 +2796,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2860,14 +2865,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// LogoutUser - GET /user/logout
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => {
|
||||
let result = api_impl.logout_user(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -2889,12 +2894,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// UpdateUser - PUT /user/{username}
|
||||
&hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => {
|
||||
// Path parameters
|
||||
let path: &str = &uri.path().to_string();
|
||||
let path: &str = uri.path();
|
||||
let path_params =
|
||||
paths::REGEX_USER_USERNAME
|
||||
.captures(&path)
|
||||
.captures(path)
|
||||
.unwrap_or_else(||
|
||||
panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str())
|
||||
);
|
||||
@@ -2951,7 +2956,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -3028,77 +3033,77 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// TestSpecialTags - PATCH /another-fake/dummy
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => Some("TestSpecialTags"),
|
||||
hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => Some("TestSpecialTags"),
|
||||
// Call123example - GET /fake/operation-with-numeric-id
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => Some("Call123example"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => Some("Call123example"),
|
||||
// FakeOuterBooleanSerialize - POST /fake/outer/boolean
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => Some("FakeOuterBooleanSerialize"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => Some("FakeOuterBooleanSerialize"),
|
||||
// FakeOuterCompositeSerialize - POST /fake/outer/composite
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => Some("FakeOuterCompositeSerialize"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => Some("FakeOuterCompositeSerialize"),
|
||||
// FakeOuterNumberSerialize - POST /fake/outer/number
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => Some("FakeOuterNumberSerialize"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => Some("FakeOuterNumberSerialize"),
|
||||
// FakeOuterStringSerialize - POST /fake/outer/string
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => Some("FakeOuterStringSerialize"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => Some("FakeOuterStringSerialize"),
|
||||
// FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => Some("FakeResponseWithNumericalDescription"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => Some("FakeResponseWithNumericalDescription"),
|
||||
// HyphenParam - GET /fake/hyphenParam/{hyphen-param}
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"),
|
||||
// TestBodyWithQueryParams - PUT /fake/body-with-query-params
|
||||
&hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Some("TestBodyWithQueryParams"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Some("TestBodyWithQueryParams"),
|
||||
// TestClientModel - PATCH /fake
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_FAKE) => Some("TestClientModel"),
|
||||
hyper::Method::PATCH if path.matched(paths::ID_FAKE) => Some("TestClientModel"),
|
||||
// TestEndpointParameters - POST /fake
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE) => Some("TestEndpointParameters"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE) => Some("TestEndpointParameters"),
|
||||
// TestEnumParameters - GET /fake
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE) => Some("TestEnumParameters"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE) => Some("TestEnumParameters"),
|
||||
// TestInlineAdditionalProperties - POST /fake/inline-additionalProperties
|
||||
&hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Some("TestInlineAdditionalProperties"),
|
||||
hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Some("TestInlineAdditionalProperties"),
|
||||
// TestJsonFormData - GET /fake/jsonFormData
|
||||
&hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => Some("TestJsonFormData"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => Some("TestJsonFormData"),
|
||||
// TestClassname - PATCH /fake_classname_test
|
||||
&hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Some("TestClassname"),
|
||||
hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Some("TestClassname"),
|
||||
// AddPet - POST /pet
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET) => Some("AddPet"),
|
||||
hyper::Method::POST if path.matched(paths::ID_PET) => Some("AddPet"),
|
||||
// DeletePet - DELETE /pet/{petId}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"),
|
||||
hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"),
|
||||
// FindPetsByStatus - GET /pet/findByStatus
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => Some("FindPetsByStatus"),
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => Some("FindPetsByStatus"),
|
||||
// FindPetsByTags - GET /pet/findByTags
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => Some("FindPetsByTags"),
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => Some("FindPetsByTags"),
|
||||
// GetPetById - GET /pet/{petId}
|
||||
&hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"),
|
||||
hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"),
|
||||
// UpdatePet - PUT /pet
|
||||
&hyper::Method::PUT if path.matched(paths::ID_PET) => Some("UpdatePet"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_PET) => Some("UpdatePet"),
|
||||
// UpdatePetWithForm - POST /pet/{petId}
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET_PETID) => Some("UpdatePetWithForm"),
|
||||
hyper::Method::POST if path.matched(paths::ID_PET_PETID) => Some("UpdatePetWithForm"),
|
||||
// UploadFile - POST /pet/{petId}/uploadImage
|
||||
&hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Some("UploadFile"),
|
||||
hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Some("UploadFile"),
|
||||
// DeleteOrder - DELETE /store/order/{order_id}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"),
|
||||
hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"),
|
||||
// GetInventory - GET /store/inventory
|
||||
&hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => Some("GetInventory"),
|
||||
hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => Some("GetInventory"),
|
||||
// GetOrderById - GET /store/order/{order_id}
|
||||
&hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"),
|
||||
hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"),
|
||||
// PlaceOrder - POST /store/order
|
||||
&hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => Some("PlaceOrder"),
|
||||
hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => Some("PlaceOrder"),
|
||||
// CreateUser - POST /user
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER) => Some("CreateUser"),
|
||||
hyper::Method::POST if path.matched(paths::ID_USER) => Some("CreateUser"),
|
||||
// CreateUsersWithArrayInput - POST /user/createWithArray
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => Some("CreateUsersWithArrayInput"),
|
||||
hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => Some("CreateUsersWithArrayInput"),
|
||||
// CreateUsersWithListInput - POST /user/createWithList
|
||||
&hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => Some("CreateUsersWithListInput"),
|
||||
hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => Some("CreateUsersWithListInput"),
|
||||
// DeleteUser - DELETE /user/{username}
|
||||
&hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"),
|
||||
hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"),
|
||||
// GetUserByName - GET /user/{username}
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"),
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"),
|
||||
// LoginUser - GET /user/login
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => Some("LoginUser"),
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => Some("LoginUser"),
|
||||
// LogoutUser - GET /user/logout
|
||||
&hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => Some("LogoutUser"),
|
||||
hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => Some("LogoutUser"),
|
||||
// UpdateUser - PUT /user/{username}
|
||||
&hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => Some("UpdateUser"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => Some("UpdateUser"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
ping_bearer_auth::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -419,8 +419,10 @@ impl<S, C> Api<C> for Client<S, C> where
|
||||
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
|
||||
});
|
||||
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
|
||||
// Currently only authentication with Basic and Bearer are supported
|
||||
#[allow(clippy::single_match, clippy::match_single_binding)]
|
||||
match auth_data {
|
||||
&AuthData::Bearer(ref bearer_header) => {
|
||||
let auth = swagger::auth::Header(bearer_header.clone());
|
||||
|
||||
@@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C
|
||||
{
|
||||
use swagger::auth::Bearer;
|
||||
use std::ops::Deref;
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) {
|
||||
if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) {
|
||||
let auth_data = AuthData::Bearer(bearer);
|
||||
let context = context.push(Some(auth_data));
|
||||
let context = context.push(None::<Authorization>);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -21,6 +22,7 @@ pub enum PingGetResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -34,6 +36,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
@@ -98,7 +98,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,14 +137,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// PingGet - GET /ping
|
||||
&hyper::Method::GET if path.matched(paths::ID_PING) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_PING) => {
|
||||
{
|
||||
let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
|
||||
&Some(ref authorization) => authorization,
|
||||
&None => return Ok(Response::builder()
|
||||
let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() {
|
||||
Some(ref authorization) => authorization,
|
||||
None => return Ok(Response::builder()
|
||||
.status(StatusCode::FORBIDDEN)
|
||||
.body(Body::from("Unauthenticated"))
|
||||
.expect("Unable to create Authentication Forbidden response")),
|
||||
@@ -157,7 +157,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -191,9 +191,9 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// PingGet - GET /ping
|
||||
&hyper::Method::GET if path.matched(paths::ID_PING) => Some("PingGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_PING) => Some("PingGet"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) {
|
||||
|
||||
let service = MakeAllowAllAuthenticator::new(service, "cosmo");
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut service =
|
||||
rust_server_test::server::context::MakeAddContext::<_, EmptyContext>::new(
|
||||
service
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
@@ -74,6 +75,7 @@ pub enum SoloObjectPostResponse {
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait Api<C: Send + Sync> {
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
|
||||
Poll::Ready(Ok(()))
|
||||
@@ -128,6 +130,7 @@ pub trait Api<C: Send + Sync> {
|
||||
|
||||
/// API where `Context` isn't passed on every API call
|
||||
#[async_trait]
|
||||
#[allow(clippy::too_many_arguments, clippy::ptr_arg)]
|
||||
pub trait ApiNoContext<C: Send + Sync> {
|
||||
|
||||
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
|
||||
|
||||
@@ -19,10 +19,11 @@ pub struct ANullableContainer {
|
||||
}
|
||||
|
||||
impl ANullableContainer {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(required_nullable_thing: swagger::Nullable<String>, ) -> ANullableContainer {
|
||||
ANullableContainer {
|
||||
nullable_thing: None,
|
||||
required_nullable_thing: required_nullable_thing,
|
||||
required_nullable_thing,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,18 +33,22 @@ impl ANullableContainer {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for ANullableContainer {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
if let Some(ref nullable_thing) = self.nullable_thing {
|
||||
params.push("NullableThing".to_string());
|
||||
params.push(nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
}
|
||||
self.nullable_thing.as_ref().map(|nullable_thing| {
|
||||
vec![
|
||||
"NullableThing".to_string(),
|
||||
nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
|
||||
params.push("RequiredNullableThing".to_string());
|
||||
params.push(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
Some("RequiredNullableThing".to_string()),
|
||||
Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +59,9 @@ impl std::str::FromStr for ANullableContainer {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub nullable_thing: Vec<String>,
|
||||
pub required_nullable_thing: Vec<String>,
|
||||
@@ -64,7 +70,7 @@ impl std::str::FromStr for ANullableContainer {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -74,6 +80,7 @@ impl std::str::FromStr for ANullableContainer {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"NullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()),
|
||||
"RequiredNullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()),
|
||||
@@ -197,6 +204,7 @@ pub struct AllOfObject {
|
||||
}
|
||||
|
||||
impl AllOfObject {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> AllOfObject {
|
||||
AllOfObject {
|
||||
sample_property: None,
|
||||
@@ -210,20 +218,26 @@ impl AllOfObject {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for AllOfObject {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
if let Some(ref sample_property) = self.sample_property {
|
||||
params.push("sampleProperty".to_string());
|
||||
params.push(sample_property.to_string());
|
||||
}
|
||||
self.sample_property.as_ref().map(|sample_property| {
|
||||
vec![
|
||||
"sampleProperty".to_string(),
|
||||
sample_property.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
|
||||
if let Some(ref sample_base_propery) = self.sample_base_propery {
|
||||
params.push("sampleBasePropery".to_string());
|
||||
params.push(sample_base_propery.to_string());
|
||||
}
|
||||
self.sample_base_propery.as_ref().map(|sample_base_propery| {
|
||||
vec![
|
||||
"sampleBasePropery".to_string(),
|
||||
sample_base_propery.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,8 +248,9 @@ impl std::str::FromStr for AllOfObject {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub sample_property: Vec<String>,
|
||||
pub sample_base_propery: Vec<String>,
|
||||
@@ -244,7 +259,7 @@ impl std::str::FromStr for AllOfObject {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -254,9 +269,12 @@ impl std::str::FromStr for AllOfObject {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
"sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string())
|
||||
}
|
||||
}
|
||||
@@ -322,6 +340,7 @@ pub struct BaseAllOf {
|
||||
}
|
||||
|
||||
impl BaseAllOf {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> BaseAllOf {
|
||||
BaseAllOf {
|
||||
sample_base_propery: None,
|
||||
@@ -334,14 +353,18 @@ impl BaseAllOf {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for BaseAllOf {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
if let Some(ref sample_base_propery) = self.sample_base_propery {
|
||||
params.push("sampleBasePropery".to_string());
|
||||
params.push(sample_base_propery.to_string());
|
||||
}
|
||||
self.sample_base_propery.as_ref().map(|sample_base_propery| {
|
||||
vec![
|
||||
"sampleBasePropery".to_string(),
|
||||
sample_base_propery.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +375,9 @@ impl std::str::FromStr for BaseAllOf {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub sample_base_propery: Vec<String>,
|
||||
}
|
||||
@@ -361,7 +385,7 @@ impl std::str::FromStr for BaseAllOf {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -371,8 +395,10 @@ impl std::str::FromStr for BaseAllOf {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string())
|
||||
}
|
||||
}
|
||||
@@ -440,9 +466,10 @@ pub struct DummyPutRequest {
|
||||
}
|
||||
|
||||
impl DummyPutRequest {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(id: String, ) -> DummyPutRequest {
|
||||
DummyPutRequest {
|
||||
id: id,
|
||||
id,
|
||||
password: None,
|
||||
}
|
||||
}
|
||||
@@ -453,18 +480,22 @@ impl DummyPutRequest {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for DummyPutRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
params.push("id".to_string());
|
||||
params.push(self.id.to_string());
|
||||
Some("id".to_string()),
|
||||
Some(self.id.to_string()),
|
||||
|
||||
|
||||
if let Some(ref password) = self.password {
|
||||
params.push("password".to_string());
|
||||
params.push(password.to_string());
|
||||
}
|
||||
self.password.as_ref().map(|password| {
|
||||
vec![
|
||||
"password".to_string(),
|
||||
password.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,8 +506,9 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub id: Vec<String>,
|
||||
pub password: Vec<String>,
|
||||
@@ -485,7 +517,7 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -495,9 +527,12 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
"password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string())
|
||||
}
|
||||
}
|
||||
@@ -508,7 +543,7 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(DummyPutRequest {
|
||||
id: intermediate_rep.id.into_iter().next().ok_or("id missing in DummyPutRequest".to_string())?,
|
||||
id: intermediate_rep.id.into_iter().next().ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
|
||||
password: intermediate_rep.password.into_iter().next(),
|
||||
})
|
||||
}
|
||||
@@ -565,6 +600,7 @@ pub struct GetYamlResponse {
|
||||
}
|
||||
|
||||
impl GetYamlResponse {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> GetYamlResponse {
|
||||
GetYamlResponse {
|
||||
value: None,
|
||||
@@ -577,14 +613,18 @@ impl GetYamlResponse {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for GetYamlResponse {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
if let Some(ref value) = self.value {
|
||||
params.push("value".to_string());
|
||||
params.push(value.to_string());
|
||||
}
|
||||
self.value.as_ref().map(|value| {
|
||||
vec![
|
||||
"value".to_string(),
|
||||
value.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,8 +635,9 @@ impl std::str::FromStr for GetYamlResponse {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub value: Vec<String>,
|
||||
}
|
||||
@@ -604,7 +645,7 @@ impl std::str::FromStr for GetYamlResponse {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -614,8 +655,10 @@ impl std::str::FromStr for GetYamlResponse {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string())
|
||||
}
|
||||
}
|
||||
@@ -681,6 +724,7 @@ pub struct ObjectOfObjects {
|
||||
}
|
||||
|
||||
impl ObjectOfObjects {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> ObjectOfObjects {
|
||||
ObjectOfObjects {
|
||||
inner: None,
|
||||
@@ -693,10 +737,12 @@ impl ObjectOfObjects {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for ObjectOfObjects {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
// Skipping inner in query parameter serialization
|
||||
let params: Vec<Option<String>> = vec![
|
||||
// Skipping inner in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,8 +753,9 @@ impl std::str::FromStr for ObjectOfObjects {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub inner: Vec<models::ObjectOfObjectsInner>,
|
||||
}
|
||||
@@ -716,7 +763,7 @@ impl std::str::FromStr for ObjectOfObjects {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -726,8 +773,10 @@ impl std::str::FromStr for ObjectOfObjects {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string())
|
||||
}
|
||||
}
|
||||
@@ -795,9 +844,10 @@ pub struct ObjectOfObjectsInner {
|
||||
}
|
||||
|
||||
impl ObjectOfObjectsInner {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new(required_thing: String, ) -> ObjectOfObjectsInner {
|
||||
ObjectOfObjectsInner {
|
||||
required_thing: required_thing,
|
||||
required_thing,
|
||||
optional_thing: None,
|
||||
}
|
||||
}
|
||||
@@ -808,18 +858,22 @@ impl ObjectOfObjectsInner {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for ObjectOfObjectsInner {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
params.push("required_thing".to_string());
|
||||
params.push(self.required_thing.to_string());
|
||||
Some("required_thing".to_string()),
|
||||
Some(self.required_thing.to_string()),
|
||||
|
||||
|
||||
if let Some(ref optional_thing) = self.optional_thing {
|
||||
params.push("optional_thing".to_string());
|
||||
params.push(optional_thing.to_string());
|
||||
}
|
||||
self.optional_thing.as_ref().map(|optional_thing| {
|
||||
vec![
|
||||
"optional_thing".to_string(),
|
||||
optional_thing.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
params.join(",").to_string()
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,8 +884,9 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
/// An intermediate representation of the struct to use for parsing.
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
#[allow(dead_code)]
|
||||
struct IntermediateRep {
|
||||
pub required_thing: Vec<String>,
|
||||
pub optional_thing: Vec<isize>,
|
||||
@@ -840,7 +895,7 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut string_iter = s.split(',');
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
@@ -850,9 +905,12 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
"required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
"optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string())
|
||||
}
|
||||
}
|
||||
@@ -863,7 +921,7 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(ObjectOfObjectsInner {
|
||||
required_thing: intermediate_rep.required_thing.into_iter().next().ok_or("required_thing missing in ObjectOfObjectsInner".to_string())?,
|
||||
required_thing: intermediate_rep.required_thing.into_iter().next().ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
|
||||
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ impl<T, C> Service<T, C> where
|
||||
{
|
||||
pub fn new(api_impl: T) -> Self {
|
||||
Service {
|
||||
api_impl: api_impl,
|
||||
api_impl,
|
||||
marker: PhantomData
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ impl<T, C> Clone for Service<T, C> where
|
||||
fn clone(&self) -> Self {
|
||||
Service {
|
||||
api_impl: self.api_impl.clone(),
|
||||
marker: self.marker.clone(),
|
||||
marker: self.marker,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,17 +159,17 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
|
||||
|
||||
match &method {
|
||||
match method {
|
||||
|
||||
// AllOfGet - GET /allOf
|
||||
&hyper::Method::GET if path.matched(paths::ID_ALLOF) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_ALLOF) => {
|
||||
let result = api_impl.all_of_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -198,14 +198,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// DummyGet - GET /dummy
|
||||
&hyper::Method::GET if path.matched(paths::ID_DUMMY) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_DUMMY) => {
|
||||
let result = api_impl.dummy_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -227,7 +227,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// DummyPut - PUT /dummy
|
||||
&hyper::Method::PUT if path.matched(paths::ID_DUMMY) => {
|
||||
hyper::Method::PUT if path.matched(paths::ID_DUMMY) => {
|
||||
// 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.
|
||||
@@ -265,7 +265,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -300,14 +300,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// FileResponseGet - GET /file_response
|
||||
&hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => {
|
||||
let result = api_impl.file_response_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -336,14 +336,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// GetStructuredYaml - GET /get-structured-yaml
|
||||
&hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => {
|
||||
let result = api_impl.get_structured_yaml(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -372,7 +372,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// HtmlPost - POST /html
|
||||
&hyper::Method::POST if path.matched(paths::ID_HTML) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_HTML) => {
|
||||
// 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.
|
||||
@@ -405,7 +405,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -440,7 +440,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// PostYaml - POST /post-yaml
|
||||
&hyper::Method::POST if path.matched(paths::ID_POST_YAML) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_POST_YAML) => {
|
||||
// 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.
|
||||
@@ -473,7 +473,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -501,14 +501,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// RawJsonGet - GET /raw_json
|
||||
&hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => {
|
||||
hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => {
|
||||
let result = api_impl.raw_json_get(
|
||||
&context
|
||||
).await;
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
match result {
|
||||
@@ -537,7 +537,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
},
|
||||
|
||||
// SoloObjectPost - POST /solo-object
|
||||
&hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => {
|
||||
hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => {
|
||||
// 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.
|
||||
@@ -575,7 +575,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
if !unused_elements.is_empty() {
|
||||
@@ -629,25 +629,25 @@ pub struct ApiRequestParser;
|
||||
impl<T> RequestParser<T> for ApiRequestParser {
|
||||
fn parse_operation_id(request: &Request<T>) -> Option<&'static str> {
|
||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||
match request.method() {
|
||||
match *request.method() {
|
||||
// AllOfGet - GET /allOf
|
||||
&hyper::Method::GET if path.matched(paths::ID_ALLOF) => Some("AllOfGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_ALLOF) => Some("AllOfGet"),
|
||||
// DummyGet - GET /dummy
|
||||
&hyper::Method::GET if path.matched(paths::ID_DUMMY) => Some("DummyGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_DUMMY) => Some("DummyGet"),
|
||||
// DummyPut - PUT /dummy
|
||||
&hyper::Method::PUT if path.matched(paths::ID_DUMMY) => Some("DummyPut"),
|
||||
hyper::Method::PUT if path.matched(paths::ID_DUMMY) => Some("DummyPut"),
|
||||
// FileResponseGet - GET /file_response
|
||||
&hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => Some("FileResponseGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => Some("FileResponseGet"),
|
||||
// GetStructuredYaml - GET /get-structured-yaml
|
||||
&hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => Some("GetStructuredYaml"),
|
||||
hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => Some("GetStructuredYaml"),
|
||||
// HtmlPost - POST /html
|
||||
&hyper::Method::POST if path.matched(paths::ID_HTML) => Some("HtmlPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_HTML) => Some("HtmlPost"),
|
||||
// PostYaml - POST /post-yaml
|
||||
&hyper::Method::POST if path.matched(paths::ID_POST_YAML) => Some("PostYaml"),
|
||||
hyper::Method::POST if path.matched(paths::ID_POST_YAML) => Some("PostYaml"),
|
||||
// RawJsonGet - GET /raw_json
|
||||
&hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => Some("RawJsonGet"),
|
||||
hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => Some("RawJsonGet"),
|
||||
// SoloObjectPost - POST /solo-object
|
||||
&hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => Some("SoloObjectPost"),
|
||||
hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => Some("SoloObjectPost"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,19 @@
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>clippy</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>cargo</executable>
|
||||
<arguments>
|
||||
<argument>clippy</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
Reference in New Issue
Block a user