[Rust Server] Rust 2018 Edition (#5942)

* [Rust Server] Rust 2018 Edition
* [Rust Server] Fix unused warning
* Update samples
This commit is contained in:
Richard Whitehouse 2020-04-26 12:00:46 +01:00 committed by GitHub
parent d911fd73bd
commit f36a319316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 512 additions and 1111 deletions

View File

@ -6,6 +6,7 @@ authors = [{{#infoEmail}}"{{{infoEmail}}}"{{/infoEmail}}]
description = "{{{appDescription}}}" description = "{{{appDescription}}}"
{{/appDescription}} {{/appDescription}}
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -25,6 +26,7 @@ client = [
{{#hasCallbacks}} {{#hasCallbacks}}
"serde_ignored", "regex", "percent-encoding", "lazy_static", "serde_ignored", "regex", "percent-encoding", "lazy_static",
{{/hasCallbacks}} {{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list below }}
"hyper", "hyper-openssl", "native-tls", "openssl", "url" "hyper", "hyper-openssl", "native-tls", "openssl", "url"
] ]
server = [ server = [
@ -57,11 +59,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,5 +1,5 @@
{{>server-imports}} {{>server-imports}}
use CallbackApi as Api; use crate::CallbackApi as Api;
{{#apiInfo}} {{#apiInfo}}
{{#apis}} {{#apis}}
{{#operations}} {{#operations}}
@ -7,7 +7,7 @@ use CallbackApi as Api;
{{#callbacks}} {{#callbacks}}
{{#urls}} {{#urls}}
{{#requests}} {{#requests}}
use {{{operationId}}}Response; use crate::{{{operationId}}}Response;
{{/requests}} {{/requests}}
{{/urls}} {{/urls}}
{{/callbacks}} {{/callbacks}}

View File

@ -27,7 +27,6 @@ use multipart::client::lazy::Multipart;
{{/apiUsesMultipartFormData}} {{/apiUsesMultipartFormData}}
{{#apiUsesMultipartRelated}} {{#apiUsesMultipartRelated}}
use hyper_0_10::header::{Headers, ContentType}; use hyper_0_10::header::{Headers, ContentType};
header! { (ContentId, "Content-ID") => [String] }
use mime_multipart::{Node, Part, generate_boundary, write_multipart}; use mime_multipart::{Node, Part, generate_boundary, write_multipart};
{{/apiUsesMultipartRelated}} {{/apiUsesMultipartRelated}}
{{#apiUsesUuid}} {{#apiUsesUuid}}
@ -37,10 +36,10 @@ use uuid;
use serde_xml_rs; use serde_xml_rs;
{{/usesXml}} {{/usesXml}}
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,

View File

@ -1,5 +1,5 @@
{{>client-imports}} {{>client-imports}}
use {Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}, use crate::{Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}},
{{{operationId}}}Response{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} {{{operationId}}}Response{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}; };
@ -38,7 +38,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -205,7 +205,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -179,7 +179,7 @@
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("{{{contentType}}}".parse().unwrap())); h.set(ContentType("{{{contentType}}}".parse().unwrap()));
h.set(ContentId("{{{baseName}}}".parse().unwrap())); h.set_raw("Content-ID", vec![b"{{{baseName}}}".to_vec()]);
h h
}, },
{{#isBinary}} {{#isBinary}}

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,30 +1,6 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate {{{externCrateName}}};
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
{{#hasCallbacks}} {{#hasCallbacks}}
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate hyper;
{{#apiUsesUuid}}
extern crate uuid;
{{/apiUsesUuid}}
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
mod server; mod server;
{{/hasCallbacks}} {{/hasCallbacks}}
@ -37,6 +13,9 @@ use {{{externCrateName}}}::{Api, ApiNoContext, Client, ContextWrapperExt, models
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -98,8 +77,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -2,33 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate {{{externCrateName}}};
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate {{{externCrateName}}};
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
{{#apiUsesUuid}}
extern crate uuid;
{{/apiUsesUuid}}
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -1,86 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
{{#hasCallbacks}}
#[cfg(any(feature = "client", feature = "server"))]
{{/hasCallbacks}}
{{^hasCallbacks}}
#[cfg(feature = "server")]
{{/hasCallbacks}}
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
{{#apiUsesMultipartRelated}}
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate hyper_0_10;
{{/apiUsesMultipartRelated}}
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
{{#hasCallbacks}}
#[cfg(any(feature = "client", feature = "server"))]
{{/hasCallbacks}}
{{^hasCallbacks}}
#[cfg(feature = "server")]
{{/hasCallbacks}}
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
{{#apiUsesMultipart}}
#[cfg(any(feature = "client", feature = "server"))]
extern crate mime_0_2;
{{/apiUsesMultipart}}
{{#apiUsesMultipartRelated}}
#[cfg(any(feature = "client", feature = "server"))]
extern crate mime_multipart;
{{/apiUsesMultipartRelated}}
{{#hasCallbacks}}
#[cfg(any(feature = "client", feature = "server"))]
{{/hasCallbacks}}
{{^hasCallbacks}}
#[cfg(feature = "server")]
{{/hasCallbacks}}
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
{{#apiUsesUuid}}extern crate uuid;{{/apiUsesUuid}}
{{#usesXml}}extern crate serde_xml_rs;{{/usesXml}}
{{#apiUsesMultipartFormData}}
#[cfg(any(feature = "client", feature = "server"))]
extern crate multipart;
{{/apiUsesMultipartFormData}}
#[cfg(any(feature = "client", feature = "server"))]
{{#usesUrlEncodedForm}}extern crate serde_urlencoded;{{/usesUrlEncodedForm}}
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
{{! Don't "use" structs here - they can conflict with the names of models, and mean that the code won't compile }} {{! Don't "use" structs here - they can conflict with the names of models, and mean that the code won't compile }}
{{#models}}{{#model}} {{#models}}{{#model}}
@ -12,8 +12,8 @@ use header;
/// which helps with FFI. /// which helps with FFI.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGenericEnum))]{{#xmlName}} #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]{{#xmlName}}
#[serde(rename = "{{{xmlName}}}")]{{/xmlName}} #[serde(rename = "{{{xmlName}}}")]{{/xmlName}}
pub enum {{{classname}}} { {{#allowableValues}}{{#enumVars}} pub enum {{{classname}}} { {{#allowableValues}}{{#enumVars}}
#[serde(rename = {{{value}}})] #[serde(rename = {{{value}}})]
@ -21,7 +21,7 @@ pub enum {{{classname}}} { {{#allowableValues}}{{#enumVars}}
} }
impl std::fmt::Display for {{{classname}}} { impl std::fmt::Display for {{{classname}}} {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { {{#allowableValues}}{{#enumVars}} match *self { {{#allowableValues}}{{#enumVars}}
{{{classname}}}::{{{name}}} => write!(f, "{}", {{{value}}}),{{/enumVars}}{{/allowableValues}} {{{classname}}}::{{{name}}} => write!(f, "{}", {{{value}}}),{{/enumVars}}{{/allowableValues}}
} }
@ -46,12 +46,12 @@ impl std::str::FromStr for {{{classname}}} {
{{^isEnum}} {{^isEnum}}
{{#dataType}} {{#dataType}}
{{#isMapModel}} {{#isMapModel}}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
{{/isMapModel}} {{/isMapModel}}
{{^isMapModel}} {{^isMapModel}}
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
{{/isMapModel}} {{/isMapModel}}
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
{{#xmlName}} {{#xmlName}}
#[serde(rename = "{{{xmlName}}}")] #[serde(rename = "{{{xmlName}}}")]
{{/xmlName}} {{/xmlName}}
@ -146,9 +146,19 @@ where
serde_xml_rs::wrap_primitives(item, serializer, "{{{itemXmlName}}}") serde_xml_rs::wrap_primitives(item, serializer, "{{{itemXmlName}}}")
} }
{{/itemXmlName}}{{/vendorExtensions}}{{! vec}}#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] {{/itemXmlName}}
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] {{/vendorExtensions}}
pub struct {{{classname}}}({{#vendorExtensions}}{{#itemXmlName}}#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]{{/itemXmlName}}{{/vendorExtensions}}Vec<{{{arrayModelType}}}>); {{! vec}}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct {{{classname}}}(
{{#vendorExtensions}}
{{#itemXmlName}}
#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]
{{/itemXmlName}}
{{/vendorExtensions}}
Vec<{{{arrayModelType}}}>
);
impl std::convert::From<Vec<{{{arrayModelType}}}>> for {{{classname}}} { impl std::convert::From<Vec<{{{arrayModelType}}}>> for {{{classname}}} {
fn from(x: Vec<{{{arrayModelType}}}>) -> Self { fn from(x: Vec<{{{arrayModelType}}}>) -> Self {
@ -234,20 +244,29 @@ impl std::str::FromStr for {{{classname}}} {
} }
{{/arrayModelType}}{{^arrayModelType}}{{! general struct}} {{/arrayModelType}}{{^arrayModelType}}{{! general struct}}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
{{#xmlName}} {{#xmlName}}
#[serde(rename = "{{{xmlName}}}")] #[serde(rename = "{{{xmlName}}}")]
{{/xmlName}} {{/xmlName}}
pub struct {{{classname}}} { pub struct {{{classname}}} {
{{#vars}}{{#description}} /// {{{description}}} {{#vars}}{{#description}} /// {{{description}}}
{{/description}}{{#isEnum}} // Note: inline enums are not fully supported by openapi-generator {{/description}}{{#isEnum}} // Note: inline enums are not fully supported by openapi-generator
{{/isEnum}} #[serde(rename = "{{{baseName}}}")]{{#vendorExtensions}}{{#itemXmlName}} {{/isEnum}}
#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]{{/itemXmlName}}{{/vendorExtensions}}{{#required}} #[serde(rename = "{{{baseName}}}")]
{{#vendorExtensions}}
{{#itemXmlName}}
#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]
{{/itemXmlName}}
{{/vendorExtensions}}
{{#required}}
pub {{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, pub {{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}},
{{/required}}{{^required}}{{#isNullable}} {{/required}}
{{^required}}
{{#isNullable}}
#[serde(deserialize_with = "swagger::nullable_format::deserialize_optional_nullable")] #[serde(deserialize_with = "swagger::nullable_format::deserialize_optional_nullable")]
#[serde(default = "swagger::nullable_format::default_optional_nullable")]{{/isNullable}} #[serde(default = "swagger::nullable_format::default_optional_nullable")]
{{/isNullable}}
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub {{{name}}}: Option<{{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}>, pub {{{name}}}: Option<{{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}>,
{{/required}} {{/required}}

View File

@ -1,5 +1,5 @@
{{>client-imports}} {{>client-imports}}
use CallbackApi; use crate::CallbackApi;
{{#apiInfo}} {{#apiInfo}}
{{#apis}} {{#apis}}
{{#operations}} {{#operations}}
@ -7,7 +7,7 @@ use CallbackApi;
{{#callbacks}} {{#callbacks}}
{{#urls}} {{#urls}}
{{#requests}} {{#requests}}
use {{{operationId}}}Response; use crate::{{{operationId}}}Response;
{{/requests}} {{/requests}}
{{/urls}} {{/urls}}
{{/callbacks}} {{/callbacks}}
@ -25,7 +25,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Client") write!(f, "Client")
} }
} }

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -14,7 +15,6 @@ use swagger::auth::Scopes;
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
{{#apiUsesMultipartRelated}} {{#apiUsesMultipartRelated}}
use hyper_0_10::header::{Headers, ContentType}; use hyper_0_10::header::{Headers, ContentType};
header! { (ContentId, "Content-ID") => [String] }
use mime_0_2::{TopLevel, SubLevel, Mime as Mime2}; use mime_0_2::{TopLevel, SubLevel, Mime as Mime2};
use mime_multipart::{read_multipart_body, Node, Part}; use mime_multipart::{read_multipart_body, Node, Part};
{{/apiUsesMultipartRelated}} {{/apiUsesMultipartRelated}}
@ -30,7 +30,7 @@ use serde_xml_rs;
{{/usesXml}} {{/usesXml}}
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;

View File

@ -1,5 +1,5 @@
{{>server-imports}} {{>server-imports}}
use {Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}, use crate::{Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}},
{{{operationId}}}Response{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} {{{operationId}}}Response{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}; };

View File

@ -1,5 +1,5 @@
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -10,7 +10,7 @@ mod paths {
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
{{#pathSet}} {{#pathSet}}
pub static ID_{{{PATH_ID}}}: usize = {{{index}}}; pub(crate) static ID_{{{PATH_ID}}}: usize = {{{index}}};
{{#hasPathParams}} {{#hasPathParams}}
lazy_static! { lazy_static! {
pub static ref REGEX_{{{PATH_ID}}}: regex::Regex = pub static ref REGEX_{{{PATH_ID}}}: regex::Regex =

View File

@ -4,6 +4,7 @@ version = "1.0.7"
authors = [] authors = []
description = "API under test" description = "API under test"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -33,11 +34,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,16 +1,5 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate multipart_v3;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
#[allow(unused_imports)] #[allow(unused_imports)]
use futures::{Future, future, Stream, stream}; use futures::{Future, future, Stream, stream};
@ -23,6 +12,9 @@ use multipart_v3::{Api, ApiNoContext, Client, ContextWrapperExt, models,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -74,8 +66,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -2,30 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate multipart_v3;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate multipart_v3;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -24,13 +24,12 @@ use mime::Mime;
use std::io::Cursor; use std::io::Cursor;
use multipart::client::lazy::Multipart; use multipart::client::lazy::Multipart;
use hyper_0_10::header::{Headers, ContentType}; use hyper_0_10::header::{Headers, ContentType};
header! { (ContentId, "Content-ID") => [String] }
use mime_multipart::{Node, Part, generate_boundary, write_multipart}; use mime_multipart::{Node, Part, generate_boundary, write_multipart};
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -38,7 +37,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
MultipartRelatedRequestPostResponse, MultipartRelatedRequestPostResponse,
MultipartRequestPostResponse, MultipartRequestPostResponse,
MultipleIdenticalMimeTypesPostResponse MultipleIdenticalMimeTypesPostResponse
@ -75,7 +74,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -242,7 +241,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }
@ -309,7 +308,7 @@ impl<C, F> Api<C> for Client<F> where
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("application/json".parse().unwrap())); h.set(ContentType("application/json".parse().unwrap()));
h.set(ContentId("object_field".parse().unwrap())); h.set_raw("Content-ID", vec![b"object_field".to_vec()]);
h h
}, },
body: serde_json::to_string(&object_field) body: serde_json::to_string(&object_field)
@ -324,7 +323,7 @@ impl<C, F> Api<C> for Client<F> where
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("application/zip".parse().unwrap())); h.set(ContentType("application/zip".parse().unwrap()));
h.set(ContentId("optional_binary_field".parse().unwrap())); h.set_raw("Content-ID", vec![b"optional_binary_field".to_vec()]);
h h
}, },
body: optional_binary_field.0, body: optional_binary_field.0,
@ -337,7 +336,7 @@ impl<C, F> Api<C> for Client<F> where
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("image/png".parse().unwrap())); h.set(ContentType("image/png".parse().unwrap()));
h.set(ContentId("required_binary_field".parse().unwrap())); h.set_raw("Content-ID", vec![b"required_binary_field".to_vec()]);
h h
}, },
body: param_required_binary_field.0, body: param_required_binary_field.0,
@ -602,7 +601,7 @@ impl<C, F> Api<C> for Client<F> where
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("application/octet-stream".parse().unwrap())); h.set(ContentType("application/octet-stream".parse().unwrap()));
h.set(ContentId("binary1".parse().unwrap())); h.set_raw("Content-ID", vec![b"binary1".to_vec()]);
h h
}, },
body: binary1.0, body: binary1.0,
@ -615,7 +614,7 @@ impl<C, F> Api<C> for Client<F> where
headers: { headers: {
let mut h = Headers::new(); let mut h = Headers::new();
h.set(ContentType("application/octet-stream".parse().unwrap())); h.set(ContentType("application/octet-stream".parse().unwrap()));
h.set(ContentId("binary2".parse().unwrap())); h.set_raw("Content-ID", vec![b"binary2".to_vec()]);
h h
}, },
body: binary2.0, body: binary2.0,

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,63 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "server")]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate hyper_0_10;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(feature = "server")]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(any(feature = "client", feature = "server"))]
extern crate mime_0_2;
#[cfg(any(feature = "client", feature = "server"))]
extern crate mime_multipart;
#[cfg(feature = "server")]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
#[cfg(any(feature = "client", feature = "server"))]
extern crate multipart;
#[cfg(any(feature = "client", feature = "server"))]
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
// Methods for converting between header::IntoHeaderValue<InlineObject> and hyper::header::HeaderValue // Methods for converting between header::IntoHeaderValue<InlineObject> and hyper::header::HeaderValue
@ -22,8 +22,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineObject>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineObject { pub struct InlineObject {
#[serde(rename = "binary1")] #[serde(rename = "binary1")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -125,8 +125,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MultipartRelat
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRelatedRequest { pub struct MultipartRelatedRequest {
#[serde(rename = "object_field")] #[serde(rename = "object_field")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -237,8 +237,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MultipartReque
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRequest { pub struct MultipartRequest {
#[serde(rename = "string_field")] #[serde(rename = "string_field")]
pub string_field: String, pub string_field: String,
@ -363,8 +363,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MultipartReque
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRequestObjectField { pub struct MultipartRequestObjectField {
#[serde(rename = "field_a")] #[serde(rename = "field_a")]
pub field_a: String, pub field_a: String,

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -13,26 +14,25 @@ pub use swagger::auth::Authorization;
use swagger::auth::Scopes; use swagger::auth::Scopes;
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use hyper_0_10::header::{Headers, ContentType}; use hyper_0_10::header::{Headers, ContentType};
header! { (ContentId, "Content-ID") => [String] }
use mime_0_2::{TopLevel, SubLevel, Mime as Mime2}; use mime_0_2::{TopLevel, SubLevel, Mime as Mime2};
use mime_multipart::{read_multipart_body, Node, Part}; use mime_multipart::{read_multipart_body, Node, Part};
use multipart::server::Multipart; use multipart::server::Multipart;
use multipart::server::save::SaveResult; use multipart::server::save::SaveResult;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
MultipartRelatedRequestPostResponse, MultipartRelatedRequestPostResponse,
MultipartRequestPostResponse, MultipartRequestPostResponse,
MultipleIdenticalMimeTypesPostResponse MultipleIdenticalMimeTypesPostResponse
}; };
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -42,9 +42,9 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_MULTIPART_RELATED_REQUEST: usize = 0; pub(crate) static ID_MULTIPART_RELATED_REQUEST: usize = 0;
pub static ID_MULTIPART_REQUEST: usize = 1; pub(crate) static ID_MULTIPART_REQUEST: usize = 1;
pub static ID_MULTIPLE_IDENTICAL_MIME_TYPES: usize = 2; pub(crate) static ID_MULTIPLE_IDENTICAL_MIME_TYPES: usize = 2;
} }
pub struct MakeService<T, RC> { pub struct MakeService<T, RC> {

View File

@ -4,6 +4,7 @@ version = "0.0.1"
authors = [] authors = []
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)" description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -27,11 +28,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,16 +1,5 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate no_example_v3;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
#[allow(unused_imports)] #[allow(unused_imports)]
use futures::{Future, future, Stream, stream}; use futures::{Future, future, Stream, stream};
@ -21,6 +10,9 @@ use no_example_v3::{Api, ApiNoContext, Client, ContextWrapperExt, models,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -69,8 +61,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -2,30 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate no_example_v3;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate no_example_v3;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -21,10 +21,10 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded; use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -32,7 +32,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
OpGetResponse OpGetResponse
}; };
@ -67,7 +67,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -234,7 +234,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,54 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "server")]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(feature = "server")]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(feature = "server")]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
#[cfg(any(feature = "client", feature = "server"))]
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
// Methods for converting between header::IntoHeaderValue<InlineObject> and hyper::header::HeaderValue // Methods for converting between header::IntoHeaderValue<InlineObject> and hyper::header::HeaderValue
@ -22,8 +22,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineObject>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineObject { pub struct InlineObject {
#[serde(rename = "propery")] #[serde(rename = "propery")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -14,17 +15,17 @@ use swagger::auth::Scopes;
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
OpGetResponse OpGetResponse
}; };
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -32,7 +33,7 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_OP: usize = 0; pub(crate) static ID_OP: usize = 0;
} }
pub struct MakeService<T, RC> { pub struct MakeService<T, RC> {

View File

@ -4,6 +4,7 @@ version = "1.0.7"
authors = [] authors = []
description = "API under test" description = "API under test"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -29,11 +30,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,26 +1,4 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate openapi_v3;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate hyper;
extern crate uuid;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
mod server; mod server;
@ -55,6 +33,9 @@ use openapi_v3::{Api, ApiNoContext, Client, ContextWrapperExt, models,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -125,8 +106,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -2,31 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate openapi_v3;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate openapi_v3;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
extern crate uuid;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -16,17 +17,17 @@ use uuid;
use serde_xml_rs; use serde_xml_rs;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use CallbackApi as Api; use crate::CallbackApi as Api;
use CallbackCallbackWithHeaderPostResponse; use crate::CallbackCallbackWithHeaderPostResponse;
use CallbackCallbackPostResponse; use crate::CallbackCallbackPostResponse;
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -35,13 +36,13 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_REQUEST_QUERY_URL_CALLBACK: usize = 0; pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK: usize = 0;
lazy_static! { lazy_static! {
pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK: regex::Regex = pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK: regex::Regex =
regex::Regex::new(r"^/(?P<request_query_url>.*)/callback$") regex::Regex::new(r"^/(?P<request_query_url>.*)/callback$")
.expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK"); .expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK");
} }
pub static ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: usize = 1; pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: usize = 1;
lazy_static! { lazy_static! {
pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: regex::Regex = pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: regex::Regex =
regex::Regex::new(r"^/(?P<request_query_url>.*)/callback-with-header$") regex::Regex::new(r"^/(?P<request_query_url>.*)/callback-with-header$")

View File

@ -23,10 +23,10 @@ use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_
use uuid; use uuid;
use serde_xml_rs; use serde_xml_rs;
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -34,7 +34,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
CallbackWithHeaderPostResponse, CallbackWithHeaderPostResponse,
ComplexQueryParamGetResponse, ComplexQueryParamGetResponse,
EnumInPathPathParamGetResponse, EnumInPathPathParamGetResponse,
@ -93,7 +93,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -260,7 +260,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,54 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(any(feature = "client", feature = "server"))]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(any(feature = "client", feature = "server"))]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
extern crate uuid;
extern crate serde_xml_rs;
#[cfg(any(feature = "client", feature = "server"))]
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
// Methods for converting between header::IntoHeaderValue<AnotherXmlArray> and hyper::header::HeaderValue // Methods for converting between header::IntoHeaderValue<AnotherXmlArray> and hyper::header::HeaderValue
@ -30,9 +30,12 @@ where
serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner") serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner")
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnotherXmlArray(#[serde(serialize_with = "wrap_in_snake_another_xml_inner")]Vec<String>); pub struct AnotherXmlArray(
#[serde(serialize_with = "wrap_in_snake_another_xml_inner")]
Vec<String>
);
impl std::convert::From<Vec<String>> for AnotherXmlArray { impl std::convert::From<Vec<String>> for AnotherXmlArray {
fn from(x: Vec<String>) -> Self { fn from(x: Vec<String>) -> Self {
@ -127,8 +130,8 @@ impl AnotherXmlArray {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "snake_another_xml_inner")] #[serde(rename = "snake_another_xml_inner")]
pub struct AnotherXmlInner(String); pub struct AnotherXmlInner(String);
@ -198,8 +201,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<AnotherXmlObje
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "snake_another_xml_object")] #[serde(rename = "snake_another_xml_object")]
pub struct AnotherXmlObject { pub struct AnotherXmlObject {
#[serde(rename = "inner_string")] #[serde(rename = "inner_string")]
@ -312,8 +315,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<DuplicateXmlOb
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "camelDuplicateXmlObject")] #[serde(rename = "camelDuplicateXmlObject")]
pub struct DuplicateXmlObject { pub struct DuplicateXmlObject {
#[serde(rename = "inner_string")] #[serde(rename = "inner_string")]
@ -424,8 +427,8 @@ impl DuplicateXmlObject {
/// which helps with FFI. /// which helps with FFI.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGenericEnum))] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
pub enum EnumWithStarObject { pub enum EnumWithStarObject {
#[serde(rename = "FOO")] #[serde(rename = "FOO")]
FOO, FOO,
@ -436,7 +439,7 @@ pub enum EnumWithStarObject {
} }
impl std::fmt::Display for EnumWithStarObject { impl std::fmt::Display for EnumWithStarObject {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { match *self {
EnumWithStarObject::FOO => write!(f, "{}", "FOO"), EnumWithStarObject::FOO => write!(f, "{}", "FOO"),
EnumWithStarObject::BAR => write!(f, "{}", "BAR"), EnumWithStarObject::BAR => write!(f, "{}", "BAR"),
@ -467,8 +470,8 @@ impl EnumWithStarObject {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Err(String); pub struct Err(String);
impl std::convert::From<String> for Err { impl std::convert::From<String> for Err {
@ -519,8 +522,8 @@ impl Err {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Error(String); pub struct Error(String);
impl std::convert::From<String> for Error { impl std::convert::From<String> for Error {
@ -588,8 +591,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineResponse
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineResponse201 { pub struct InlineResponse201 {
#[serde(rename = "foo")] #[serde(rename = "foo")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -674,8 +677,8 @@ impl InlineResponse201 {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MyId(i32); pub struct MyId(i32);
impl std::convert::From<i32> for MyId { impl std::convert::From<i32> for MyId {
@ -730,9 +733,11 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MyIdList> {
} }
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MyIdList(Vec<i32>); pub struct MyIdList(
Vec<i32>
);
impl std::convert::From<Vec<i32>> for MyIdList { impl std::convert::From<Vec<i32>> for MyIdList {
fn from(x: Vec<i32>) -> Self { fn from(x: Vec<i32>) -> Self {
@ -844,8 +849,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<NullableTest>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct NullableTest { pub struct NullableTest {
#[serde(rename = "nullable")] #[serde(rename = "nullable")]
pub nullable: swagger::Nullable<String>, pub nullable: swagger::Nullable<String>,
@ -1008,8 +1013,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectHeader>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectHeader { pub struct ObjectHeader {
#[serde(rename = "requiredObjectHeader")] #[serde(rename = "requiredObjectHeader")]
pub required_object_header: bool, pub required_object_header: bool,
@ -1122,8 +1127,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectParam> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectParam { pub struct ObjectParam {
#[serde(rename = "requiredParam")] #[serde(rename = "requiredParam")]
pub required_param: bool, pub required_param: bool,
@ -1236,8 +1241,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectUntypedP
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectUntypedProps { pub struct ObjectUntypedProps {
#[serde(rename = "required_untyped")] #[serde(rename = "required_untyped")]
pub required_untyped: serde_json::Value, pub required_untyped: serde_json::Value,
@ -1363,8 +1368,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectWithArra
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectWithArrayOfObjects { pub struct ObjectWithArrayOfObjects {
#[serde(rename = "objectArray")] #[serde(rename = "objectArray")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1449,8 +1454,8 @@ impl ObjectWithArrayOfObjects {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Ok(String); pub struct Ok(String);
impl std::convert::From<String> for Ok { impl std::convert::From<String> for Ok {
@ -1501,8 +1506,8 @@ impl Ok {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OptionalObjectHeader(i32); pub struct OptionalObjectHeader(i32);
impl std::convert::From<i32> for OptionalObjectHeader { impl std::convert::From<i32> for OptionalObjectHeader {
@ -1541,8 +1546,8 @@ impl OptionalObjectHeader {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct RequiredObjectHeader(bool); pub struct RequiredObjectHeader(bool);
impl std::convert::From<bool> for RequiredObjectHeader { impl std::convert::From<bool> for RequiredObjectHeader {
@ -1581,8 +1586,8 @@ impl RequiredObjectHeader {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Result(String); pub struct Result(String);
impl std::convert::From<String> for Result { impl std::convert::From<String> for Result {
@ -1638,8 +1643,8 @@ impl Result {
/// which helps with FFI. /// which helps with FFI.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGenericEnum))] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
pub enum StringEnum { pub enum StringEnum {
#[serde(rename = "FOO")] #[serde(rename = "FOO")]
FOO, FOO,
@ -1648,7 +1653,7 @@ pub enum StringEnum {
} }
impl std::fmt::Display for StringEnum { impl std::fmt::Display for StringEnum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { match *self {
StringEnum::FOO => write!(f, "{}", "FOO"), StringEnum::FOO => write!(f, "{}", "FOO"),
StringEnum::BAR => write!(f, "{}", "BAR"), StringEnum::BAR => write!(f, "{}", "BAR"),
@ -1677,8 +1682,8 @@ impl StringEnum {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct StringObject(String); pub struct StringObject(String);
impl std::convert::From<String> for StringObject { impl std::convert::From<String> for StringObject {
@ -1730,8 +1735,8 @@ impl StringObject {
} }
/// Test a model containing a UUID /// Test a model containing a UUID
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct UuidObject(uuid::Uuid); pub struct UuidObject(uuid::Uuid);
impl std::convert::From<uuid::Uuid> for UuidObject { impl std::convert::From<uuid::Uuid> for UuidObject {
@ -1795,9 +1800,12 @@ where
serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner") serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner")
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct XmlArray(#[serde(serialize_with = "wrap_in_camelXmlInner")]Vec<String>); pub struct XmlArray(
#[serde(serialize_with = "wrap_in_camelXmlInner")]
Vec<String>
);
impl std::convert::From<Vec<String>> for XmlArray { impl std::convert::From<Vec<String>> for XmlArray {
fn from(x: Vec<String>) -> Self { fn from(x: Vec<String>) -> Self {
@ -1892,8 +1900,8 @@ impl XmlArray {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "camelXmlInner")] #[serde(rename = "camelXmlInner")]
pub struct XmlInner(String); pub struct XmlInner(String);
@ -1963,8 +1971,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<XmlObject> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "camelXmlObject")] #[serde(rename = "camelXmlObject")]
pub struct XmlObject { pub struct XmlObject {
#[serde(rename = "innerString")] #[serde(rename = "innerString")]

View File

@ -23,10 +23,10 @@ use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_
use uuid; use uuid;
use serde_xml_rs; use serde_xml_rs;
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -34,9 +34,9 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use CallbackApi; use crate::CallbackApi;
use CallbackCallbackWithHeaderPostResponse; use crate::CallbackCallbackWithHeaderPostResponse;
use CallbackCallbackPostResponse; use crate::CallbackCallbackPostResponse;
/// 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.
pub struct Client<F> pub struct Client<F>
@ -47,7 +47,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Client") write!(f, "Client")
} }
} }

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -16,12 +17,12 @@ use uuid;
use serde_xml_rs; use serde_xml_rs;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
CallbackWithHeaderPostResponse, CallbackWithHeaderPostResponse,
ComplexQueryParamGetResponse, ComplexQueryParamGetResponse,
EnumInPathPathParamGetResponse, EnumInPathPathParamGetResponse,
@ -50,7 +51,7 @@ use {Api,
pub mod callbacks; pub mod callbacks;
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -78,37 +79,37 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_CALLBACK_WITH_HEADER: usize = 0; pub(crate) static ID_CALLBACK_WITH_HEADER: usize = 0;
pub static ID_COMPLEX_QUERY_PARAM: usize = 1; pub(crate) static ID_COMPLEX_QUERY_PARAM: usize = 1;
pub static ID_ENUM_IN_PATH_PATH_PARAM: usize = 2; pub(crate) static ID_ENUM_IN_PATH_PATH_PARAM: usize = 2;
lazy_static! { lazy_static! {
pub static ref REGEX_ENUM_IN_PATH_PATH_PARAM: regex::Regex = pub static ref REGEX_ENUM_IN_PATH_PATH_PARAM: regex::Regex =
regex::Regex::new(r"^/enum_in_path/(?P<path_param>[^/?#]*)$") regex::Regex::new(r"^/enum_in_path/(?P<path_param>[^/?#]*)$")
.expect("Unable to create regex for ENUM_IN_PATH_PATH_PARAM"); .expect("Unable to create regex for ENUM_IN_PATH_PATH_PARAM");
} }
pub static ID_MANDATORY_REQUEST_HEADER: usize = 3; pub(crate) static ID_MANDATORY_REQUEST_HEADER: usize = 3;
pub static ID_MERGE_PATCH_JSON: usize = 4; pub(crate) static ID_MERGE_PATCH_JSON: usize = 4;
pub static ID_MULTIGET: usize = 5; pub(crate) static ID_MULTIGET: usize = 5;
pub static ID_MULTIPLE_AUTH_SCHEME: usize = 6; pub(crate) static ID_MULTIPLE_AUTH_SCHEME: usize = 6;
pub static ID_OVERRIDE_SERVER: usize = 7; pub(crate) static ID_OVERRIDE_SERVER: usize = 7;
pub static ID_PARAMGET: usize = 8; pub(crate) static ID_PARAMGET: usize = 8;
pub static ID_READONLY_AUTH_SCHEME: usize = 9; pub(crate) static ID_READONLY_AUTH_SCHEME: usize = 9;
pub static ID_REGISTER_CALLBACK: usize = 10; pub(crate) static ID_REGISTER_CALLBACK: usize = 10;
pub static ID_REPOS: usize = 11; pub(crate) static ID_REPOS: usize = 11;
pub static ID_REPOS_REPOID: usize = 12; pub(crate) static ID_REPOS_REPOID: usize = 12;
lazy_static! { lazy_static! {
pub static ref REGEX_REPOS_REPOID: regex::Regex = pub static ref REGEX_REPOS_REPOID: regex::Regex =
regex::Regex::new(r"^/repos/(?P<repoId>[^/?#]*)$") regex::Regex::new(r"^/repos/(?P<repoId>[^/?#]*)$")
.expect("Unable to create regex for REPOS_REPOID"); .expect("Unable to create regex for REPOS_REPOID");
} }
pub static ID_REQUIRED_OCTET_STREAM: usize = 13; pub(crate) static ID_REQUIRED_OCTET_STREAM: usize = 13;
pub static ID_RESPONSES_WITH_HEADERS: usize = 14; pub(crate) static ID_RESPONSES_WITH_HEADERS: usize = 14;
pub static ID_RFC7807: usize = 15; pub(crate) static ID_RFC7807: usize = 15;
pub static ID_UNTYPED_PROPERTY: usize = 16; pub(crate) static ID_UNTYPED_PROPERTY: usize = 16;
pub static ID_UUID: usize = 17; pub(crate) static ID_UUID: usize = 17;
pub static ID_XML: usize = 18; pub(crate) static ID_XML: usize = 18;
pub static ID_XML_EXTRA: usize = 19; pub(crate) static ID_XML_EXTRA: usize = 19;
pub static ID_XML_OTHER: usize = 20; pub(crate) static ID_XML_OTHER: usize = 20;
} }
pub struct MakeService<T, RC> { pub struct MakeService<T, RC> {

View File

@ -4,6 +4,7 @@ version = "0.0.1"
authors = [] authors = []
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)" description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -27,11 +28,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,16 +1,5 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate ops_v3;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
#[allow(unused_imports)] #[allow(unused_imports)]
use futures::{Future, future, Stream, stream}; use futures::{Future, future, Stream, stream};
@ -57,6 +46,9 @@ use ops_v3::{Api, ApiNoContext, Client, ContextWrapperExt, models,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -142,8 +134,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -2,30 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate ops_v3;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate ops_v3;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -21,10 +21,10 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded; use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -32,7 +32,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
Op10GetResponse, Op10GetResponse,
Op11GetResponse, Op11GetResponse,
Op12GetResponse, Op12GetResponse,
@ -103,7 +103,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -270,7 +270,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,54 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "server")]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(feature = "server")]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(feature = "server")]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
#[cfg(any(feature = "client", feature = "server"))]
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,6 +1,6 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -14,12 +15,12 @@ use swagger::auth::Scopes;
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
Op10GetResponse, Op10GetResponse,
Op11GetResponse, Op11GetResponse,
Op12GetResponse, Op12GetResponse,
@ -60,7 +61,7 @@ use {Api,
}; };
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -104,43 +105,43 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_OP1: usize = 0; pub(crate) static ID_OP1: usize = 0;
pub static ID_OP10: usize = 1; pub(crate) static ID_OP10: usize = 1;
pub static ID_OP11: usize = 2; pub(crate) static ID_OP11: usize = 2;
pub static ID_OP12: usize = 3; pub(crate) static ID_OP12: usize = 3;
pub static ID_OP13: usize = 4; pub(crate) static ID_OP13: usize = 4;
pub static ID_OP14: usize = 5; pub(crate) static ID_OP14: usize = 5;
pub static ID_OP15: usize = 6; pub(crate) static ID_OP15: usize = 6;
pub static ID_OP16: usize = 7; pub(crate) static ID_OP16: usize = 7;
pub static ID_OP17: usize = 8; pub(crate) static ID_OP17: usize = 8;
pub static ID_OP18: usize = 9; pub(crate) static ID_OP18: usize = 9;
pub static ID_OP19: usize = 10; pub(crate) static ID_OP19: usize = 10;
pub static ID_OP2: usize = 11; pub(crate) static ID_OP2: usize = 11;
pub static ID_OP20: usize = 12; pub(crate) static ID_OP20: usize = 12;
pub static ID_OP21: usize = 13; pub(crate) static ID_OP21: usize = 13;
pub static ID_OP22: usize = 14; pub(crate) static ID_OP22: usize = 14;
pub static ID_OP23: usize = 15; pub(crate) static ID_OP23: usize = 15;
pub static ID_OP24: usize = 16; pub(crate) static ID_OP24: usize = 16;
pub static ID_OP25: usize = 17; pub(crate) static ID_OP25: usize = 17;
pub static ID_OP26: usize = 18; pub(crate) static ID_OP26: usize = 18;
pub static ID_OP27: usize = 19; pub(crate) static ID_OP27: usize = 19;
pub static ID_OP28: usize = 20; pub(crate) static ID_OP28: usize = 20;
pub static ID_OP29: usize = 21; pub(crate) static ID_OP29: usize = 21;
pub static ID_OP3: usize = 22; pub(crate) static ID_OP3: usize = 22;
pub static ID_OP30: usize = 23; pub(crate) static ID_OP30: usize = 23;
pub static ID_OP31: usize = 24; pub(crate) static ID_OP31: usize = 24;
pub static ID_OP32: usize = 25; pub(crate) static ID_OP32: usize = 25;
pub static ID_OP33: usize = 26; pub(crate) static ID_OP33: usize = 26;
pub static ID_OP34: usize = 27; pub(crate) static ID_OP34: usize = 27;
pub static ID_OP35: usize = 28; pub(crate) static ID_OP35: usize = 28;
pub static ID_OP36: usize = 29; pub(crate) static ID_OP36: usize = 29;
pub static ID_OP37: usize = 30; pub(crate) static ID_OP37: usize = 30;
pub static ID_OP4: usize = 31; pub(crate) static ID_OP4: usize = 31;
pub static ID_OP5: usize = 32; pub(crate) static ID_OP5: usize = 32;
pub static ID_OP6: usize = 33; pub(crate) static ID_OP6: usize = 33;
pub static ID_OP7: usize = 34; pub(crate) static ID_OP7: usize = 34;
pub static ID_OP8: usize = 35; pub(crate) static ID_OP8: usize = 35;
pub static ID_OP9: usize = 36; pub(crate) static ID_OP9: usize = 36;
} }
pub struct MakeService<T, RC> { pub struct MakeService<T, RC> {

View File

@ -4,6 +4,7 @@ version = "1.0.0"
authors = [] authors = []
description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\" description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -32,11 +33,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,16 +1,5 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate petstore_with_fake_endpoints_models_for_testing;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
#[allow(unused_imports)] #[allow(unused_imports)]
use futures::{Future, future, Stream, stream}; use futures::{Future, future, Stream, stream};
@ -55,6 +44,9 @@ use petstore_with_fake_endpoints_models_for_testing::{Api, ApiNoContext, Client,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -128,8 +120,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -2,31 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate petstore_with_fake_endpoints_models_for_testing;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate petstore_with_fake_endpoints_models_for_testing;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
extern crate uuid;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -26,10 +26,10 @@ use multipart::client::lazy::Multipart;
use uuid; use uuid;
use serde_xml_rs; use serde_xml_rs;
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -37,7 +37,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
TestSpecialTagsResponse, TestSpecialTagsResponse,
Call123exampleResponse, Call123exampleResponse,
FakeOuterBooleanSerializeResponse, FakeOuterBooleanSerializeResponse,
@ -106,7 +106,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -273,7 +273,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,58 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "server")]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(feature = "server")]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(any(feature = "client", feature = "server"))]
extern crate mime_0_2;
#[cfg(feature = "server")]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
extern crate uuid;
extern crate serde_xml_rs;
#[cfg(any(feature = "client", feature = "server"))]
extern crate multipart;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_urlencoded;
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
// Methods for converting between header::IntoHeaderValue<AdditionalPropertiesClass> and hyper::header::HeaderValue // Methods for converting between header::IntoHeaderValue<AdditionalPropertiesClass> and hyper::header::HeaderValue
@ -22,8 +22,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<AdditionalProp
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AdditionalPropertiesClass { pub struct AdditionalPropertiesClass {
#[serde(rename = "map_property")] #[serde(rename = "map_property")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -132,8 +132,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Animal> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Animal { pub struct Animal {
#[serde(rename = "className")] #[serde(rename = "className")]
pub class_name: String, pub class_name: String,
@ -245,9 +245,11 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<AnimalFarm> {
} }
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnimalFarm(Vec<Animal>); pub struct AnimalFarm(
Vec<Animal>
);
impl std::convert::From<Vec<Animal>> for AnimalFarm { impl std::convert::From<Vec<Animal>> for AnimalFarm {
fn from(x: Vec<Animal>) -> Self { fn from(x: Vec<Animal>) -> Self {
@ -359,8 +361,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ApiResponse> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ApiResponse { pub struct ApiResponse {
#[serde(rename = "code")] #[serde(rename = "code")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -490,8 +492,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ArrayOfArrayOf
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayOfArrayOfNumberOnly { pub struct ArrayOfArrayOfNumberOnly {
#[serde(rename = "ArrayArrayNumber")] #[serde(rename = "ArrayArrayNumber")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -589,8 +591,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ArrayOfNumberO
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayOfNumberOnly { pub struct ArrayOfNumberOnly {
#[serde(rename = "ArrayNumber")] #[serde(rename = "ArrayNumber")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -692,8 +694,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ArrayTest> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayTest { pub struct ArrayTest {
#[serde(rename = "array_of_string")] #[serde(rename = "array_of_string")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -830,8 +832,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Capitalization
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Capitalization { pub struct Capitalization {
#[serde(rename = "smallCamel")] #[serde(rename = "smallCamel")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1004,8 +1006,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Cat> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Cat { pub struct Cat {
#[serde(rename = "className")] #[serde(rename = "className")]
pub class_name: String, pub class_name: String,
@ -1132,8 +1134,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<CatAllOf> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct CatAllOf { pub struct CatAllOf {
#[serde(rename = "declawed")] #[serde(rename = "declawed")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1235,8 +1237,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Category> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Category")] #[serde(rename = "Category")]
pub struct Category { pub struct Category {
#[serde(rename = "id")] #[serde(rename = "id")]
@ -1354,8 +1356,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ClassModel> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ClassModel { pub struct ClassModel {
#[serde(rename = "_class")] #[serde(rename = "_class")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1457,8 +1459,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Client> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Client { pub struct Client {
#[serde(rename = "client")] #[serde(rename = "client")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1560,8 +1562,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Dog> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Dog { pub struct Dog {
#[serde(rename = "className")] #[serde(rename = "className")]
pub class_name: String, pub class_name: String,
@ -1688,8 +1690,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<DogAllOf> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct DogAllOf { pub struct DogAllOf {
#[serde(rename = "breed")] #[serde(rename = "breed")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -1791,8 +1793,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<EnumArrays> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EnumArrays { pub struct EnumArrays {
// Note: inline enums are not fully supported by openapi-generator // Note: inline enums are not fully supported by openapi-generator
#[serde(rename = "just_symbol")] #[serde(rename = "just_symbol")]
@ -1909,8 +1911,8 @@ impl EnumArrays {
/// which helps with FFI. /// which helps with FFI.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGenericEnum))] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
pub enum EnumClass { pub enum EnumClass {
#[serde(rename = "_abc")] #[serde(rename = "_abc")]
_ABC, _ABC,
@ -1921,7 +1923,7 @@ pub enum EnumClass {
} }
impl std::fmt::Display for EnumClass { impl std::fmt::Display for EnumClass {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { match *self {
EnumClass::_ABC => write!(f, "{}", "_abc"), EnumClass::_ABC => write!(f, "{}", "_abc"),
EnumClass::_EFG => write!(f, "{}", "-efg"), EnumClass::_EFG => write!(f, "{}", "-efg"),
@ -1969,8 +1971,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<EnumTest> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EnumTest { pub struct EnumTest {
// Note: inline enums are not fully supported by openapi-generator // Note: inline enums are not fully supported by openapi-generator
#[serde(rename = "enum_string")] #[serde(rename = "enum_string")]
@ -2125,8 +2127,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<FormatTest> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FormatTest { pub struct FormatTest {
#[serde(rename = "integer")] #[serde(rename = "integer")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -2370,8 +2372,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<HasOnlyReadOnl
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct HasOnlyReadOnly { pub struct HasOnlyReadOnly {
#[serde(rename = "bar")] #[serde(rename = "bar")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -2487,8 +2489,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<List> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct List { pub struct List {
#[serde(rename = "123-list")] #[serde(rename = "123-list")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -2590,8 +2592,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MapTest> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MapTest { pub struct MapTest {
#[serde(rename = "map_map_of_string")] #[serde(rename = "map_map_of_string")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -2713,8 +2715,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<MixedPropertie
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MixedPropertiesAndAdditionalPropertiesClass { pub struct MixedPropertiesAndAdditionalPropertiesClass {
#[serde(rename = "uuid")] #[serde(rename = "uuid")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -2834,8 +2836,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Model200Respon
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Name")] #[serde(rename = "Name")]
pub struct Model200Response { pub struct Model200Response {
#[serde(rename = "name")] #[serde(rename = "name")]
@ -2953,8 +2955,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ModelReturn> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Return")] #[serde(rename = "Return")]
pub struct ModelReturn { pub struct ModelReturn {
#[serde(rename = "return")] #[serde(rename = "return")]
@ -3058,8 +3060,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Name> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Name")] #[serde(rename = "Name")]
pub struct Name { pub struct Name {
#[serde(rename = "name")] #[serde(rename = "name")]
@ -3201,8 +3203,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<NumberOnly> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct NumberOnly { pub struct NumberOnly {
#[serde(rename = "JustNumber")] #[serde(rename = "JustNumber")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -3304,8 +3306,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectContaini
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectContainingObjectWithOnlyAdditionalProperties { pub struct ObjectContainingObjectWithOnlyAdditionalProperties {
#[serde(rename = "inner")] #[serde(rename = "inner")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -3386,8 +3388,8 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties {
} }
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectWithOnlyAdditionalProperties(std::collections::HashMap<String, String>); pub struct ObjectWithOnlyAdditionalProperties(std::collections::HashMap<String, String>);
impl std::convert::From<std::collections::HashMap<String, String>> for ObjectWithOnlyAdditionalProperties { impl std::convert::From<std::collections::HashMap<String, String>> for ObjectWithOnlyAdditionalProperties {
@ -3463,8 +3465,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Order> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Order")] #[serde(rename = "Order")]
pub struct Order { pub struct Order {
#[serde(rename = "id")] #[serde(rename = "id")]
@ -3618,8 +3620,8 @@ impl Order {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OuterBoolean(bool); pub struct OuterBoolean(bool);
impl std::convert::From<bool> for OuterBoolean { impl std::convert::From<bool> for OuterBoolean {
@ -3675,8 +3677,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<OuterComposite
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OuterComposite { pub struct OuterComposite {
#[serde(rename = "my_number")] #[serde(rename = "my_number")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -3794,8 +3796,8 @@ impl OuterComposite {
/// which helps with FFI. /// which helps with FFI.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGenericEnum))] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
pub enum OuterEnum { pub enum OuterEnum {
#[serde(rename = "placed")] #[serde(rename = "placed")]
PLACED, PLACED,
@ -3806,7 +3808,7 @@ pub enum OuterEnum {
} }
impl std::fmt::Display for OuterEnum { impl std::fmt::Display for OuterEnum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { match *self {
OuterEnum::PLACED => write!(f, "{}", "placed"), OuterEnum::PLACED => write!(f, "{}", "placed"),
OuterEnum::APPROVED => write!(f, "{}", "approved"), OuterEnum::APPROVED => write!(f, "{}", "approved"),
@ -3837,8 +3839,8 @@ impl OuterEnum {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OuterNumber(f64); pub struct OuterNumber(f64);
impl std::convert::From<f64> for OuterNumber { impl std::convert::From<f64> for OuterNumber {
@ -3877,8 +3879,8 @@ impl OuterNumber {
} }
} }
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OuterString(String); pub struct OuterString(String);
impl std::convert::From<String> for OuterString { impl std::convert::From<String> for OuterString {
@ -3946,8 +3948,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Pet> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Pet")] #[serde(rename = "Pet")]
pub struct Pet { pub struct Pet {
#[serde(rename = "id")] #[serde(rename = "id")]
@ -4108,8 +4110,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ReadOnlyFirst>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReadOnlyFirst { pub struct ReadOnlyFirst {
#[serde(rename = "bar")] #[serde(rename = "bar")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -4225,8 +4227,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<SpecialModelNa
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "$special[model.name]")] #[serde(rename = "$special[model.name]")]
pub struct SpecialModelName { pub struct SpecialModelName {
#[serde(rename = "$special[property.name]")] #[serde(rename = "$special[property.name]")]
@ -4329,8 +4331,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<Tag> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Tag")] #[serde(rename = "Tag")]
pub struct Tag { pub struct Tag {
#[serde(rename = "id")] #[serde(rename = "id")]
@ -4447,8 +4449,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<User> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "User")] #[serde(rename = "User")]
pub struct User { pub struct User {
#[serde(rename = "id")] #[serde(rename = "id")]

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -18,12 +19,12 @@ use multipart::server::save::SaveResult;
use serde_xml_rs; use serde_xml_rs;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
TestSpecialTagsResponse, TestSpecialTagsResponse,
Call123exampleResponse, Call123exampleResponse,
FakeOuterBooleanSerializeResponse, FakeOuterBooleanSerializeResponse,
@ -62,7 +63,7 @@ use {Api,
}; };
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -96,53 +97,53 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_ANOTHER_FAKE_DUMMY: usize = 0; pub(crate) static ID_ANOTHER_FAKE_DUMMY: usize = 0;
pub static ID_FAKE: usize = 1; pub(crate) static ID_FAKE: usize = 1;
pub static ID_FAKE_BODY_WITH_QUERY_PARAMS: usize = 2; pub(crate) static ID_FAKE_BODY_WITH_QUERY_PARAMS: usize = 2;
pub static ID_FAKE_HYPHENPARAM_HYPHEN_PARAM: usize = 3; pub(crate) static ID_FAKE_HYPHENPARAM_HYPHEN_PARAM: usize = 3;
lazy_static! { lazy_static! {
pub static ref REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM: regex::Regex = pub static ref REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM: regex::Regex =
regex::Regex::new(r"^/v2/fake/hyphenParam/(?P<hyphen-param>[^/?#]*)$") regex::Regex::new(r"^/v2/fake/hyphenParam/(?P<hyphen-param>[^/?#]*)$")
.expect("Unable to create regex for FAKE_HYPHENPARAM_HYPHEN_PARAM"); .expect("Unable to create regex for FAKE_HYPHENPARAM_HYPHEN_PARAM");
} }
pub static ID_FAKE_INLINE_ADDITIONALPROPERTIES: usize = 4; pub(crate) static ID_FAKE_INLINE_ADDITIONALPROPERTIES: usize = 4;
pub static ID_FAKE_JSONFORMDATA: usize = 5; pub(crate) static ID_FAKE_JSONFORMDATA: usize = 5;
pub static ID_FAKE_OPERATION_WITH_NUMERIC_ID: usize = 6; pub(crate) static ID_FAKE_OPERATION_WITH_NUMERIC_ID: usize = 6;
pub static ID_FAKE_OUTER_BOOLEAN: usize = 7; pub(crate) static ID_FAKE_OUTER_BOOLEAN: usize = 7;
pub static ID_FAKE_OUTER_COMPOSITE: usize = 8; pub(crate) static ID_FAKE_OUTER_COMPOSITE: usize = 8;
pub static ID_FAKE_OUTER_NUMBER: usize = 9; pub(crate) static ID_FAKE_OUTER_NUMBER: usize = 9;
pub static ID_FAKE_OUTER_STRING: usize = 10; pub(crate) static ID_FAKE_OUTER_STRING: usize = 10;
pub static ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION: usize = 11; pub(crate) static ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION: usize = 11;
pub static ID_FAKE_CLASSNAME_TEST: usize = 12; pub(crate) static ID_FAKE_CLASSNAME_TEST: usize = 12;
pub static ID_PET: usize = 13; pub(crate) static ID_PET: usize = 13;
pub static ID_PET_FINDBYSTATUS: usize = 14; pub(crate) static ID_PET_FINDBYSTATUS: usize = 14;
pub static ID_PET_FINDBYTAGS: usize = 15; pub(crate) static ID_PET_FINDBYTAGS: usize = 15;
pub static ID_PET_PETID: usize = 16; pub(crate) static ID_PET_PETID: usize = 16;
lazy_static! { lazy_static! {
pub static ref REGEX_PET_PETID: regex::Regex = pub static ref REGEX_PET_PETID: regex::Regex =
regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)$") regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)$")
.expect("Unable to create regex for PET_PETID"); .expect("Unable to create regex for PET_PETID");
} }
pub static ID_PET_PETID_UPLOADIMAGE: usize = 17; pub(crate) static ID_PET_PETID_UPLOADIMAGE: usize = 17;
lazy_static! { lazy_static! {
pub static ref REGEX_PET_PETID_UPLOADIMAGE: regex::Regex = pub static ref REGEX_PET_PETID_UPLOADIMAGE: regex::Regex =
regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)/uploadImage$") regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)/uploadImage$")
.expect("Unable to create regex for PET_PETID_UPLOADIMAGE"); .expect("Unable to create regex for PET_PETID_UPLOADIMAGE");
} }
pub static ID_STORE_INVENTORY: usize = 18; pub(crate) static ID_STORE_INVENTORY: usize = 18;
pub static ID_STORE_ORDER: usize = 19; pub(crate) static ID_STORE_ORDER: usize = 19;
pub static ID_STORE_ORDER_ORDER_ID: usize = 20; pub(crate) static ID_STORE_ORDER_ORDER_ID: usize = 20;
lazy_static! { lazy_static! {
pub static ref REGEX_STORE_ORDER_ORDER_ID: regex::Regex = pub static ref REGEX_STORE_ORDER_ORDER_ID: regex::Regex =
regex::Regex::new(r"^/v2/store/order/(?P<order_id>[^/?#]*)$") regex::Regex::new(r"^/v2/store/order/(?P<order_id>[^/?#]*)$")
.expect("Unable to create regex for STORE_ORDER_ORDER_ID"); .expect("Unable to create regex for STORE_ORDER_ORDER_ID");
} }
pub static ID_USER: usize = 21; pub(crate) static ID_USER: usize = 21;
pub static ID_USER_CREATEWITHARRAY: usize = 22; pub(crate) static ID_USER_CREATEWITHARRAY: usize = 22;
pub static ID_USER_CREATEWITHLIST: usize = 23; pub(crate) static ID_USER_CREATEWITHLIST: usize = 23;
pub static ID_USER_LOGIN: usize = 24; pub(crate) static ID_USER_LOGIN: usize = 24;
pub static ID_USER_LOGOUT: usize = 25; pub(crate) static ID_USER_LOGOUT: usize = 25;
pub static ID_USER_USERNAME: usize = 26; pub(crate) static ID_USER_USERNAME: usize = 26;
lazy_static! { lazy_static! {
pub static ref REGEX_USER_USERNAME: regex::Regex = pub static ref REGEX_USER_USERNAME: regex::Regex =
regex::Regex::new(r"^/v2/user/(?P<username>[^/?#]*)$") regex::Regex::new(r"^/v2/user/(?P<username>[^/?#]*)$")

View File

@ -4,6 +4,7 @@ version = "2.3.4"
authors = [] authors = []
description = "This spec is for testing rust-server-specific things" description = "This spec is for testing rust-server-specific things"
license = "Unlicense" license = "Unlicense"
edition = "2018"
[features] [features]
default = ["client", "server"] default = ["client", "server"]
@ -27,11 +28,10 @@ openssl = {version = "0.10", optional = true }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
futures = "0.1" futures = "0.1"
swagger = "4.0" swagger = "4.0"
log = "0.3.0" log = "0.4.0"
mime = "0.3" mime = "0.3"
serde = "1.0" serde = { version = "1.0", features = ["derive"]}
serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
# Crates included if required by the API definition # Crates included if required by the API definition

View File

@ -1,16 +1,5 @@
#![allow(missing_docs, unused_variables, trivial_casts)] #![allow(missing_docs, unused_variables, trivial_casts)]
extern crate rust_server_test;
extern crate clap;
extern crate env_logger;
extern crate futures;
// log may be unused if there are no examples
#[allow(unused_imports)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate swagger;
extern crate tokio;
#[allow(unused_imports)] #[allow(unused_imports)]
use futures::{Future, future, Stream, stream}; use futures::{Future, future, Stream, stream};
@ -29,6 +18,9 @@ use rust_server_test::{Api, ApiNoContext, Client, ContextWrapperExt, models,
}; };
use clap::{App, Arg}; use clap::{App, Arg};
#[allow(unused_imports)]
use log::info;
// swagger::Has may be unused if there are no examples // swagger::Has may be unused if there are no examples
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData};
@ -84,8 +76,8 @@ fn main() {
.expect("Failed to create HTTP client") .expect("Failed to create HTTP client")
}; };
let context: make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) = let context: swagger::make_context_ty!(ContextBuilder, EmptyContext, Option<AuthData>, XSpanIdString) =
make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default()); swagger::make_context!(ContextBuilder, EmptyContext, None as Option<AuthData>, XSpanIdString::default());
let client = client.with_context(context); let client = client.with_context(context);

View File

@ -2,30 +2,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
// Imports required by this file.
// extern crate <name of this crate>;
extern crate rust_server_test;
extern crate clap;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate swagger;
// Imports required by server library.
// extern crate rust_server_test;
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate futures;
// extern crate swagger;
extern crate tokio;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate openssl;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate tokio_openssl;
use clap::{App, Arg}; use clap::{App, Arg};
mod server; mod server;

View File

@ -3,7 +3,7 @@
#![allow(unused_imports)] #![allow(unused_imports)]
mod errors { mod errors {
error_chain!{} error_chain::error_chain!{}
} }
pub use self::errors::*; pub use self::errors::*;
@ -12,6 +12,7 @@ use chrono;
use futures::{future, Future, Stream}; use futures::{future, Future, Stream};
use hyper::server::conn::Http; use hyper::server::conn::Http;
use hyper::service::MakeService as _; use hyper::service::MakeService as _;
use log::info;
use openssl::ssl::SslAcceptorBuilder; use openssl::ssl::SslAcceptorBuilder;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr; use std::net::SocketAddr;

View File

@ -21,10 +21,10 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded; use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use models; use crate::models;
use header; use crate::header;
define_encode_set! { url::define_encode_set! {
/// This encode set is used for object IDs /// This encode set is used for object IDs
/// ///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
@ -32,7 +32,7 @@ define_encode_set! {
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
} }
use {Api, use crate::{Api,
AllOfGetResponse, AllOfGetResponse,
DummyGetResponse, DummyGetResponse,
DummyPutResponse, DummyPutResponse,
@ -75,7 +75,7 @@ pub struct Client<F>
impl<F> fmt::Debug for Client<F> impl<F> fmt::Debug for Client<F>
{ {
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)
} }
} }
@ -242,7 +242,7 @@ impl From<hyper::http::uri::InvalidUri> for ClientInitError {
} }
impl fmt::Display for ClientInitError { impl fmt::Display for ClientInitError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &dyn fmt::Debug = self; let s: &dyn fmt::Debug = self;
s.fmt(f) s.fmt(f)
} }

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use swagger::auth::{AuthData, Authorization, Bearer, Scopes}; use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString}; use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
use Api; use crate::Api;
pub struct MakeAddContext<T, A> { pub struct MakeAddContext<T, A> {
inner: T, inner: T,

View File

@ -1,54 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
// Crates with macros
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "server")]
#[macro_use]
extern crate lazy_static;
#[cfg(any(feature = "client", feature = "server"))]
#[macro_use]
extern crate url;
#[macro_use]
extern crate log;
// Crates for conversion support
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_derives;
#[cfg(feature = "conversion")]
#[macro_use]
extern crate frunk_enum_derive;
#[cfg(feature = "conversion")]
extern crate frunk_core;
extern crate mime;
extern crate serde;
extern crate futures;
extern crate chrono;
extern crate swagger;
extern crate serde_json;
#[cfg(any(feature = "client", feature = "server"))]
extern crate hyper;
#[cfg(feature = "server")]
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
extern crate hyper_openssl;
#[cfg(feature = "server")]
extern crate percent_encoding;
#[cfg(any(feature = "client", feature = "server"))]
extern crate serde_ignored;
#[cfg(any(feature = "client", feature = "server"))]
#[cfg(any(feature = "client", feature = "server"))]
use futures::Stream; use futures::Stream;
use std::io::Error; use std::io::Error;

View File

@ -1,8 +1,8 @@
#![allow(unused_qualifications)] #![allow(unused_qualifications)]
use models; use crate::models;
#[cfg(any(feature = "client", feature = "server"))] #[cfg(any(feature = "client", feature = "server"))]
use header; use crate::header;
// Methods for converting between header::IntoHeaderValue<ANullableContainer> and hyper::header::HeaderValue // Methods for converting between header::IntoHeaderValue<ANullableContainer> and hyper::header::HeaderValue
@ -22,8 +22,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ANullableConta
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ANullableContainer { pub struct ANullableContainer {
#[serde(rename = "NullableThing")] #[serde(rename = "NullableThing")]
#[serde(deserialize_with = "swagger::nullable_format::deserialize_optional_nullable")] #[serde(deserialize_with = "swagger::nullable_format::deserialize_optional_nullable")]
@ -114,8 +114,8 @@ impl std::str::FromStr for ANullableContainer {
/// An additionalPropertiesObject /// An additionalPropertiesObject
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AdditionalPropertiesObject(std::collections::HashMap<String, String>); pub struct AdditionalPropertiesObject(std::collections::HashMap<String, String>);
impl std::convert::From<std::collections::HashMap<String, String>> for AdditionalPropertiesObject { impl std::convert::From<std::collections::HashMap<String, String>> for AdditionalPropertiesObject {
@ -183,8 +183,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<AllOfObject> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AllOfObject { pub struct AllOfObject {
#[serde(rename = "sampleProperty")] #[serde(rename = "sampleProperty")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -292,8 +292,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct BaseAllOf { pub struct BaseAllOf {
#[serde(rename = "sampleBasePropery")] #[serde(rename = "sampleBasePropery")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -388,8 +388,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<GetYamlRespons
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct GetYamlResponse { pub struct GetYamlResponse {
/// Inner string /// Inner string
#[serde(rename = "value")] #[serde(rename = "value")]
@ -484,8 +484,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineObject>
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineObject { pub struct InlineObject {
#[serde(rename = "id")] #[serde(rename = "id")]
pub id: String, pub id: String,
@ -591,8 +591,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectOfObject
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjects { pub struct ObjectOfObjects {
#[serde(rename = "inner")] #[serde(rename = "inner")]
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
@ -682,8 +682,8 @@ impl From<hyper::header::HeaderValue> for header::IntoHeaderValue<ObjectOfObject
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjectsInner { pub struct ObjectOfObjectsInner {
#[serde(rename = "required_thing")] #[serde(rename = "required_thing")]
pub required_thing: String, pub required_thing: String,

View File

@ -3,9 +3,10 @@ use futures::{Future, future, Stream, stream};
use hyper; use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap}; use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded; use log::warn;
use serde_json; use serde_json;
use std::io; use std::io;
use url::form_urlencoded;
#[allow(unused_imports)] #[allow(unused_imports)]
use swagger; use swagger;
use swagger::{ApiError, XSpanIdString, Has, RequestParser}; use swagger::{ApiError, XSpanIdString, Has, RequestParser};
@ -14,12 +15,12 @@ use swagger::auth::Scopes;
use swagger::context::ContextualPayload; use swagger::context::ContextualPayload;
#[allow(unused_imports)] #[allow(unused_imports)]
use models; use crate::models;
use header; use crate::header;
pub use crate::context; pub use crate::context;
use {Api, use crate::{Api,
AllOfGetResponse, AllOfGetResponse,
DummyGetResponse, DummyGetResponse,
DummyPutResponse, DummyPutResponse,
@ -32,7 +33,7 @@ use {Api,
}; };
mod paths { mod paths {
extern crate regex; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
@ -47,14 +48,14 @@ mod paths {
]) ])
.expect("Unable to create global regex set"); .expect("Unable to create global regex set");
} }
pub static ID_ALLOF: usize = 0; pub(crate) static ID_ALLOF: usize = 0;
pub static ID_DUMMY: usize = 1; pub(crate) static ID_DUMMY: usize = 1;
pub static ID_FILE_RESPONSE: usize = 2; pub(crate) static ID_FILE_RESPONSE: usize = 2;
pub static ID_GET_STRUCTURED_YAML: usize = 3; pub(crate) static ID_GET_STRUCTURED_YAML: usize = 3;
pub static ID_HTML: usize = 4; pub(crate) static ID_HTML: usize = 4;
pub static ID_POST_YAML: usize = 5; pub(crate) static ID_POST_YAML: usize = 5;
pub static ID_RAW_JSON: usize = 6; pub(crate) static ID_RAW_JSON: usize = 6;
pub static ID_SOLO_OBJECT: usize = 7; pub(crate) static ID_SOLO_OBJECT: usize = 7;
} }
pub struct MakeService<T, RC> { pub struct MakeService<T, RC> {