richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.
MIT License
750 stars 150 forks source link

Custom headers? #95

Closed bennettl closed 10 years ago

bennettl commented 10 years ago

I need all swagger api actions to set a custom header to my server. How do I do this?

ldnunes commented 10 years ago

@bennettl : It's on the README. Have a look:

https://github.com/richhollis/swagger-docs#drying-up-common-documentation

richhollis commented 10 years ago

Hi Bennett

If you want to add a header and I've read the spec correctly then in theory you should be able to use the regular param with :header type (not tested):

swagger_api :index do param :header, :some_header, :integer, :optional, "Some header" end

Let me know if this works.

bennettl commented 10 years ago

I want to populate the header with a default value, but this doesn't seem to work:

param :header, :some_header, :integer, :optional, "Some header", "Default Value"

richhollis commented 10 years ago

What about this (untested):

param :header, :some_header, :integer, :optional, "Some header", {"defaultValue" => "some default"}

richhollis commented 10 years ago

@bennettl Did that work?

bennettl commented 10 years ago

Yes that did the trick. Thank you so much!