Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing the CSS #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ NOTE: This action should be run part of this gem (not your application). In case
make it up-to-date, clone the repo, run the rake task, examine the diff, fix any bugs, make sure
tests pass and then send PR here.

### Customizing the CSS

To customize the CSS for your application, use the `extra_css_path` configuration option.

```ruby
GrapeSwaggerRails.options.extra_css_path = 'my-swagger-customizations.css'
```

Then you'll need to add a matching .css file in the `app/assets/stylesheets` directory
for your application. This file should contain any customizations you want to make over the delivered CSS.

You may also need to reference this CSS file in your `config/initializers/assets.rb` file, in order for Sprockets to include it when your
CSS files are compiled:

```ruby
Rails.application.config.assets.precompile += %w( my-swagger-customizations.css )
```

### Enabling in a Rails-API Project

The grape-swagger-rails gem uses the Rails asset pipeline for its Javascript and CSS. Enable the asset pipeline with [rails-api](https://github.com/rails-api/rails-api).
Expand Down
3 changes: 3 additions & 0 deletions app/views/grape_swagger_rails/application/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<%= stylesheet_link_tag 'grape_swagger_rails/application.css' %>
<% if GrapeSwaggerRails.options.extra_css_path %>
<%= stylesheet_link_tag GrapeSwaggerRails.options.extra_css_path %>
<% end %>
<%= javascript_include_tag 'grape_swagger_rails/application.js' %>
<script type="text/javascript">
$(function () {
Expand Down
3 changes: 2 additions & 1 deletion lib/grape-swagger-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def before_action(&block)
before_action_proc: nil, # Proc used as a controller before action

hide_url_input: false,
hide_api_key_input: false
hide_api_key_input: false,
extra_css_path: nil
)
end