fix base path when it's not defined in the spec (#678)

This commit is contained in:
William Cheng 2018-07-30 15:09:56 +08:00 committed by GitHub
parent 68d80ab67d
commit 01dbb8b693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,8 +193,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
URL url = URLPathUtils.getServerURL(openAPI);
contextPath = config.escapeText(url.getPath());
basePath = config.escapeText(URLPathUtils.getHost(openAPI));
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);
}
}
private void configureOpenAPIInfo() {