@@ -28,14 +28,19 @@ Add this line to `./config/routes.rb`:
2828mount GrapeSwaggerRails ::Engine => ' /swagger'
2929```
3030
31- Create an initializer (e.g. ` ./config/initializers/swagger.rb ` ) and specify the URL to your Swagger API schema:
31+ Create an initializer (e.g. ` ./config/initializers/swagger.rb ` ) and specify the URL to your Swagger API schema and app :
3232
3333``` ruby
3434GrapeSwaggerRails .options.url = ' /swagger_doc.json'
35- GrapeSwaggerRails .options.app_name = ' Swagger'
3635GrapeSwaggerRails .options.app_url = ' http://swagger.wordnik.com'
3736```
3837
38+ You can set the app name, default is "Swagger".
39+
40+ ``` ruby
41+ GrapeSwaggerRails .options.app_name = ' Swagger'
42+ ```
43+
3944You can specify additional headers to add to each request:
4045
4146``` ruby
@@ -75,22 +80,16 @@ You can use the ```api_key``` input box to fill in your API token.
7580### Swagger UI Authorization
7681
7782You may want to authenticate users before displaying the Swagger UI, particularly when the API is protected by Basic Authentication.
78- Use the ` authenticate_with ` option to inspect the request to the Swagger UI:
83+ Use the ` before ` option to inspect the request before Swagger UI:
7984
8085``` ruby
81- GrapeSwaggerRails .options.authenticate_with do |request |
82- # 1. Inspect the `request` or access the Swagger UI controller via `self`
83- # 2. Check `current_user` or `can? :access, :api`, etc....
84- # 3. return a boolean value
86+ GrapeSwaggerRails .options.before_filter do |request |
87+ # 1. Inspect the `request` or access the Swagger UI controller via `self`.
88+ # 2. Check `current_user` or `can? :access, :api`, etc.
89+ # 3. Redirect or error in case of failure.
8590end
8691```
8792
88- The block above is stored in the ` authentication_proc ` option:
89-
90- ``` ruby
91- GrapeSwaggerRails .options.authentication_proc: Proc .new {|request | # return a boolean value}
92- ```
93-
9493## Contributing
9594
96951 . Fork it
0 commit comments