Generated spec servers
url has trailing slash - this causes problems with tooling
#1716
Open
2 of 4 tasks
Labels
I discovered this issue while using
swift-openapi-generator
with the generated openapi json document. The resulting swift code fails to work since an extra slash is added into the path. This is becauseservers[idx].url
has a trailing slash.As far as I could find the openapi spec doesn't explicitly disallow this, however I found several resources/tools that disallow it for the exact reason that it doesn't work well with other tooling.
E.g.:
/users and /users/ are considered to be separate paths but it is bad practice for them to differ based only on a trailing slash. This can cause confusion among users of your API. It is usually preferred to not have a trailing slash."
Seems like there's a lot of agreement that there should not be a trailing slash.
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
No trailing slash:
Current Behavior
Has a trailing slash:
Possible Solution
Remove the trailing slash
Steps to Reproduce
Not really necessary, if you include
spec.host
in thetsoa.json
then you'll get theservers
urls with trailing slashes.Context (Environment)
Version of the library: 6.5.1
Version of NodeJS: 23.1.0
Detailed Description
There's not really any more detail I can offer.
Breaking change?
Since this changes the output it might be reasonable to include an opt-out mechanism. This would just be a `includeTrailingSlashForHosts config property.
The text was updated successfully, but these errors were encountered: