-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
If the host is defined without defining schema in OpenAPI Spec 2 then Server.url shoud be //{hostname}/{basePath} but it is {hostname}/{basepath}
The same is explained in swagger documentation under Server URL format ( RFC 3986 )
https://swagger.io/docs/specification/api-host-and-base-path/
It is a minor bug fix in the SwaggerConvert.convert(List schemes, String host, String basePath) by changing to below lines
private List convert(List schemes, String host, String basePath) {
List servers = new ArrayList<>();
String baseUrl;
if (StringUtils.isNotEmpty(basePath)) {
baseUrl = basePath;
} else {
baseUrl = "/";
}
if (StringUtils.isNotEmpty(host)) {
baseUrl = "//" + host + baseUrl;
}
if (!StringUtils.startsWith(baseUrl, "/") && schemes != null && !schemes.isEmpty()) {
for (Scheme scheme : schemes) {
Server server = new Server();
server.setUrl(scheme.toValue() + ":" + baseUrl);
servers.add(server);
}
} else {
if (!"/".equals(baseUrl)) {
Server server = new Server();
server.setUrl(baseUrl);
servers.add(server);
} else {
return null;
}
}
return servers;
}
Metadata
Metadata
Assignees
Labels
No labels