Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:55:58+00:00 2026-06-13T09:55:58+00:00

I am re-writing (yeah I know!) a Rails app which is largely API driven,

  • 0

I am re-writing (yeah I know!) a Rails app which is largely API driven, using Grape by Intridea and grape-swagger gem to enable Swagger UI for documentation.

So I have a simple hello world app running. Seems discoverable from the swagger test, though it’s giving JSON parse errors at the moment (I’ll look into that next). I want to put the swagger UI into the Rails app, pointed at the /swagger_doc.json so as I build I can make sure the documentation is building properly right along side.

Where do I put the Swagger UI in the rails app? Public directory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:55:59+00:00Added an answer on June 13, 2026 at 9:55 am

    Okay so I found a couple of snafus that were causing nothing to show when I tried just putting it all in the public directory previously.

    myapp/public/swagger-ui-1.1.1/files
    

    1) I don’t know if this SHOULD make a difference but the order in which I loaded the rails app and the grape app in the config.ru seemed to make a difference how the routing was handled …I need to understand more how that works. But now the mounted grape app inside routes does what I’d expect. As a result with the swagger-ui unzipped into public then just going to

    http://appurl/swagger-ui-1.1.1/ 
    

    gives me the swagger UI. I’ll add more detail to this if there’s an more to it.

    EDIT: As there will be other users out there like me who need a helping hand here, I’ll outline it below. It’s pretty easy:

    Create /swagger subdirectories in the asset pipeline – I did it under vendor. Copy the lib files over from the swagger UI to these subdirectories. Create a basic docs_controller with an index action (can be empty). Create a views/docs directory and copy the swagger-ui index.html to it. Change the stylesheet and javascript calls to asset-tags in index.html. Add resource route for docs. Change the discoveryURL in the javascript function calling window.swaggerUI to “http://my.root.url/swagger_doc.json” (ideally from ENV variable).

    That’s it. It now just works. One gotcha I ran into, using my Grape API under an api subdomain was CORS when Swagger was running on docs subdomain. Easily fixed in Grape by adding something like:

    before do
      header "Access-Control-Allow-Origin", "http://#{ENV["BASE_URL"]}"
      header "Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT"
      header "Access-Control-Max-Age", "1728000"
    end
    

    to your Grape api.rb. Hope that all helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a C++ plugin in Mac OS X using the Carbon framework (yeah,
Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using
Writing an iPhone app in which I want to save the user the grief
Writing an app which takes the preview frames from camera does some transformation to
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing a python program, and I came up with this error while using the
I'm learning Rails by writing simple TODO tasks aplication. Two models are: class List
Something like $('.mydiv' :eq(n) 'img') but yeah that is a terrible way of writing
My Android app is reading and writing to a local SQLite DB from a
//Writing a letter #include <iostream> using namespace std; int main() { string first_name; //Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.