Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim trailing '/' from basePathWithoutHost #967

Merged
merged 2 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,9 @@ private void configureGeneratorProperties() {
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<F, C> Api<C> for Client<F> where


let uri = format!(
"{}//dummy",
"{}/dummy",
self.base_path
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down