forked from loafle/openapi-generator-original
[rust-server] add support for '|' in path segments (#667)
* Added encoding for vertical bar character in object IDs for client requests * Updated sample
This commit is contained in:
parent
036fa6918c
commit
b0909ade6f
@ -43,6 +43,14 @@ use {Api{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}},
|
||||
};
|
||||
use models;
|
||||
|
||||
define_encode_set! {
|
||||
/// This encode set is used for object IDs
|
||||
///
|
||||
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
|
||||
/// the vertical bar (|) is encoded.
|
||||
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
|
||||
}
|
||||
|
||||
/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes.
|
||||
fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> {
|
||||
// First convert to Uri, since a base path is a subset of Uri.
|
||||
@ -246,7 +254,7 @@ impl<F, C> Api<C> for Client<F> where
|
||||
|
||||
let uri = format!(
|
||||
"{}{{{basePathWithoutHost}}}{{path}}{{#queryParams}}{{#-first}}?{{/-first}}{{=<% %>=}}{<% paramName %>}<%={{ }}=%>{{/queryParams}}",
|
||||
self.base_path{{#pathParams}}, {{{baseName}}}=utf8_percent_encode(¶m_{{{paramName}}}.to_string(), PATH_SEGMENT_ENCODE_SET){{/pathParams}}{{#queryParams}},
|
||||
self.base_path{{#pathParams}}, {{{baseName}}}=utf8_percent_encode(¶m_{{{paramName}}}.to_string(), ID_ENCODE_SET){{/pathParams}}{{#queryParams}},
|
||||
{{{paramName}}}=utf8_percent_encode(&query_{{{paramName}}}, QUERY_ENCODE_SET){{/queryParams}}
|
||||
);
|
||||
|
||||
|
@ -19,6 +19,9 @@ extern crate hyper;
|
||||
|
||||
extern crate swagger;
|
||||
|
||||
#[macro_use]
|
||||
extern crate url;
|
||||
|
||||
use futures::Stream;
|
||||
use std::io::Error;
|
||||
|
||||
|
@ -74,6 +74,14 @@ use {Api,
|
||||
};
|
||||
use models;
|
||||
|
||||
define_encode_set! {
|
||||
/// This encode set is used for object IDs
|
||||
///
|
||||
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
|
||||
/// the vertical bar (|) is encoded.
|
||||
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
|
||||
}
|
||||
|
||||
/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes.
|
||||
fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> {
|
||||
// First convert to Uri, since a base path is a subset of Uri.
|
||||
@ -1236,7 +1244,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/pet/{petId}",
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -1461,7 +1469,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/pet/{petId}",
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -1629,7 +1637,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/pet/{petId}",
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -1693,7 +1701,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/pet/{petId}/uploadImage",
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, petId=utf8_percent_encode(¶m_pet_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -1767,7 +1775,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/store/order/{order_id}",
|
||||
self.base_path, order_id=utf8_percent_encode(¶m_order_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -1900,7 +1908,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/store/order/{order_id}",
|
||||
self.base_path, order_id=utf8_percent_encode(¶m_order_id.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, order_id=utf8_percent_encode(¶m_order_id.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -2262,7 +2270,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/user/{username}",
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -2328,7 +2336,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/user/{username}",
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
@ -2566,7 +2574,7 @@ if let Some(body) = body {
|
||||
|
||||
let uri = format!(
|
||||
"{}/v2/user/{username}",
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), PATH_SEGMENT_ENCODE_SET)
|
||||
self.base_path, username=utf8_percent_encode(¶m_username.to_string(), ID_ENCODE_SET)
|
||||
);
|
||||
|
||||
let uri = match Uri::from_str(&uri) {
|
||||
|
@ -19,6 +19,9 @@ extern crate hyper;
|
||||
|
||||
extern crate swagger;
|
||||
|
||||
#[macro_use]
|
||||
extern crate url;
|
||||
|
||||
use futures::Stream;
|
||||
use std::io::Error;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user