swagger icon indicating copy to clipboard operation
swagger copied to clipboard

@BasePath appears to be non-optional

Open mixedCase opened this issue 10 years ago • 12 comments

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.

mixedCase avatar Sep 16 '15 02:09 mixedCase

Yeah I'm wondering the same thing about the documentation :D @boonep Could you add something to the wiki :)

RobertJGabriel avatar Sep 17 '15 10:09 RobertJGabriel

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!

boonep avatar Sep 17 '15 14:09 boonep

Submitted pull request https://github.com/yvasiyarov/swagger/pull/96 to default to old behavior. Let me know if it fixes your issue. Thanks!

boonep avatar Sep 17 '15 15:09 boonep

Doesn't fix it unfortunately. Error is still the same:

Unable to read api 'clientes' from path {{.}}/clientes (server returned undefined)

mixedCase avatar Sep 17 '15 15:09 mixedCase

@boonep @mixedCase Does #96 really works ? Should I merge it ?

yvasiyarov avatar Sep 23 '15 06:09 yvasiyarov

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.

boonep avatar Sep 23 '15 13:09 boonep

#96 did not fix it for me. At the moment I'm just working around the issue by specifying @BasePath.

mixedCase avatar Sep 23 '15 18:09 mixedCase

@mixedCase if you pull commit 20e8232783704b9a9f1a1e1a223f3d28f55f8064 is the error gone? Thanks!

boonep avatar Sep 23 '15 18:09 boonep

Yes, indeed that commit does fix it!. Sorry for replying 5 days late.

mixedCase avatar Sep 28 '15 23:09 mixedCase

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.

boonep avatar Oct 05 '15 14:10 boonep

I agree with this hugely @boonep :+1:

RobertJGabriel avatar Oct 05 '15 14:10 RobertJGabriel

Today I updated swagger and this is still not working without specifying @BasePath I'm afraid.

mixedCase avatar Dec 17 '15 09:12 mixedCase