swagger
swagger copied to clipboard
@BasePath appears to be non-optional
This commit: https://github.com/yvasiyarov/swagger/commit/3430d5b14cbeac355b58e11231eac3f702793af6 introduced adding @BasePath as a requirement for the swagger page to work properly, or at least that's the only thing that unbreaks my workflow.
Despite not seeing the benefit in this, I don't mind it, but I haven't seen it documented anywhere.
Is this intended behavior?, and if so, can it get a mention in the wiki? Thanks.
Yeah I'm wondering the same thing about the documentation :D @boonep Could you add something to the wiki :)
Ah, I think I see the issue. I was under the impression that basePath defaulted to "{{.}}" for both General API info and Sub API Definitions, but it looks like it actually defaulted to not including a basePath for General API info and "{{.}}" for Sub API Definitions only.
/*****************************************
* i.e. old default (go format):
*****************************************/
var resourceListingJson = `{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"apis": [...]
}`
var apiDescriptionsJson = map[string]string{"user":`{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "{{.}}",
"resourcePath": "/user",
"apis": [...]
}`
/*****************************************
* i.e. new default (go format):
*****************************************/
var resourceListingJson = `{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "{{.}}",
"apis": [...]
}`
var apiDescriptionsJson = map[string]string{"user":`{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "{{.}}",
"resourcePath": "/user",
"apis": [...]
}`
Is it preferred for the General API info basePath to default to not being included or default to "{{.}}"? I don't have a strong preference either way. If nothing else, we can return to it defaulting to not being listed, so as to not break existing functionality in some cases. Thanks!
Submitted pull request https://github.com/yvasiyarov/swagger/pull/96 to default to old behavior. Let me know if it fixes your issue. Thanks!
Doesn't fix it unfortunately. Error is still the same:
Unable to read api 'clientes' from path {{.}}/clientes (server returned undefined)
@boonep @mixedCase Does #96 really works ? Should I merge it ?
It sounds like it's not working for @mixedCase. I'm not exactly sure the expected functionality, or where the error is arising, so I'm not sure I can be much more help. Might make sense to just revert 3430d5b since it appears to be breaking some use cases, and isn't providing critical functionality.
#96 did not fix it for me. At the moment I'm just working around the issue by specifying @BasePath.
@mixedCase if you pull commit 20e8232783704b9a9f1a1e1a223f3d28f55f8064 is the error gone? Thanks!
Yes, indeed that commit does fix it!. Sorry for replying 5 days late.
I think the best course of action would be to revert 3430d5b, and not to commit pull request #96. We can then fix the test, and make sure we're not breaking any backwards compatibility.
I agree with this hugely @boonep :+1:
Today I updated swagger and this is still not working without specifying @BasePath I'm afraid.