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