swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
3.73k stars 269 forks source link

does swaggo support defining cookie in the header? #135

Open gzhhong opened 3 years ago

gzhhong commented 3 years ago

Hello all,

I can't find in the docs if I can define a parameter in this way:

// @Param some_id cookie string true "Some ID"

Can anyone confirm there are some way to do so?

Thanks,

James

AntonDzyk commented 3 years ago

I think that cookie type is only support OAS 3.0, but swag support only OAS 2.0 - https://github.com/swaggo/swag/issues/237 swagg Support types - https://github.com/swaggo/swag#param-type

renchili commented 2 years ago

? no update?
i manually changed the json in docs.go parameters.in to "cookie" which works

boindil commented 2 years ago

@ubogdan

any update on this? Would be very nice to have support on this!

ahuigo commented 1 year ago

You could use @Param:

// @Param        Cookie header string  false "token"     default(token=xxx)
ballcoach12 commented 7 months ago

You could use @Param:

// @Param          Cookie header string  false "token"     default(token=xxx)

I might be wrong, but I don't think this will yield the intended result. If you want to place a JWT token in a Cookie, then the swagger document that is generated by swag init will have to be manually edited to include the specification of the cookie since swag only supports the Swagger 2.0 specification and cookie authentication is a Swagger 3.0 feature.