ruby-grape / grape-swagger-rails

Swagger UI as Rails Engine for grape-swagger gem.
MIT License
251 stars 197 forks source link

Customizing the CSS #103

Open jwigal opened 3 years ago

jwigal commented 3 years ago

Provide an easy way to add your own CSS file on top of the delivered CSS.

grape-bot commented 3 years ago
2 Warnings
:warning: There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code.
:warning: Unless you’re refactoring existing code, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#103](https://github.com/ruby-grape/grape-swagger-rails/pull/103): Customizing the css - [@jwigal](https://github.com/jwigal).

Generated by :no_entry_sign: danger

dblock commented 3 years ago

I have some questions.

Why would you rather do this than include the additional stylesheet in your app/assets/stylesheets/application.css?

Assuming we still want this feature, I think we should make it more generic and allow overriding all CSS, i.e. default it to the built-in CSS. I propose that we name this stylesheet_paths and make it an Array.

GrapeSwaggerRails.options.stylesheet_paths << 'some.css' # [ 'grape_swagger_rails/application.css', 'some.css' ]

Then

  <% GrapeSwaggerRails.options.stylesheet_paths.each do |stylesheet_path| %>
    <%= stylesheet_link_tag stylesheet_path %>
  <% end %> 

To be merged this needs tests, too, please.

If you really want to be ambitious, users should also be able to configure script_paths, i.e. all the JS.