forked from loafle/openapi-generator-original
Trim trailing '/' from basePathWithoutHost (#967)
* Trim trailing '/' from basePathWithoutHost
Given that the normal use is {{{basePathWithoutHost}}}{{{path}}}.
* Trim trailing '/' from contextPath
This commit is contained in:
committed by
William Cheng
parent
29e9f5bda0
commit
c0a6eaab85
@@ -193,15 +193,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
contextPath = config.escapeText(url.getPath());
|
||||
basePathWithoutHost = contextPath; // for backward compatibility
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI));
|
||||
if ("/".equals(basePath.substring(basePath.length() - 1))) {
|
||||
// remove trailing "/"
|
||||
// https://host.example.com/ => https://host.example.com
|
||||
basePath = basePath.substring(0, basePath.length() - 1);
|
||||
}
|
||||
|
||||
contextPath = config.escapeText(url.getPath()).replaceAll("/$", ""); // for backward compatibility
|
||||
basePathWithoutHost = contextPath;
|
||||
basePath = config.escapeText(URLPathUtils.getHost(openAPI)).replaceAll("/$", "");
|
||||
}
|
||||
|
||||
private void configureOpenAPIInfo() {
|
||||
|
||||
@@ -249,7 +249,7 @@ impl<F, C> Api<C> for Client<F> where
|
||||
|
||||
|
||||
let uri = format!(
|
||||
"{}//dummy",
|
||||
"{}/dummy",
|
||||
self.base_path
|
||||
);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ mod mimetypes;
|
||||
|
||||
pub use swagger::{ApiError, ContextWrapper};
|
||||
|
||||
pub const BASE_PATH: &'static str = "/";
|
||||
pub const BASE_PATH: &'static str = "";
|
||||
pub const API_VERSION: &'static str = "1.0.0";
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ mod paths {
|
||||
|
||||
lazy_static! {
|
||||
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(&[
|
||||
r"^//dummy$"
|
||||
r"^/dummy$"
|
||||
]).unwrap();
|
||||
}
|
||||
pub static ID_DUMMY: usize = 0;
|
||||
|
||||
Reference in New Issue
Block a user