Is there something missing in supporting OAS3 servers?
fulviodenza opened this issue ยท 9 comments
From this line we deduce that is still something missing in the OAS3 servers support:
Line 134 in 9463136
Although it looks it already has been added support to it:
https://github.com/swagger-api/swagger-js/tree/96d261987700297a472db5587c0a8c769095d73e/src/execute
I found it a bit confusing, is it to delete?
Hi @fulviodenza,
Good question. Investigating....
Maybe slightly related: #2967
We are already using the feature with no issues, opening a PR to remove the stale comment.
@fulviodenza yes I can confirm as well. Probably the intention was to make server URLs absolute using the spec url when they are represented as relative URI Reference, but that is already handled in baseUrl
function.
On the other hand, the following code is fully OpenAPI 2.0 specific:
if (specUrl && specUrl.startsWith('http')) {
const parsed = new URL(specUrl);
if (!spec.host) {
spec.host = parsed.host;
}
if (!spec.schemes) {
spec.schemes = [parsed.protocol.replace(':', '')];
}
if (!spec.basePath) {
spec.basePath = '/';
}
}
I think what the // TODO: OAS3: support servers here
comment is trying to relay to us that we should do the same for OpenAPI 3.x.y Server Object. Interpolating here probable intention for OpenAPI 3.x.y:
if (specUrl && specUrl.startsWith('http') && spec is OpenAPI 3.x.y) {
if (!spec.servers) {
spec.servers = [{ url: specUrl }];
}
}
@fulviodenza what do you think?
I've issued #3219 to align the code with #3143 (comment)
Closed by #3219. @fulviodenza thanks for pointing this TODO
comment out. It lead to adding missing piece of functionality!
Closed by #3220 which introduces spec compliant default for OpenAPI.servers
field in OpenAPI 3.x.y definitions.
Sorry for not answering before didn't read, I'm happy this led to a fix!