Skip to content

Cannot test Grape API (inside Rails 3) using online swagger UI. #19

Closed
@diarmuidoconnor

Description

@diarmuidoconnor

Hi,

I have a Rails 3 application with a REST API built using Grape. Some relevant code excerpts are as follows:

routes.rb

   require 'grape'
   Blog::Application.routes.draw do  
       mount Blog::API => "/"
   end

api.rb

  require 'grape'
  require 'grape-swagger'
  module Blog
      class API < Grape::API
       mount Blog::API1
      add_swagger_documentation
  end
  end

api1.rb

   require 'grape'
   module Blog
      class API1 < Grape::API
          format :json
          resource :weblogs do
               get do
                   Weblog.all
               end
          ……………………..

The API works fine when I test it with curl. I’ve deployed it to Cloud Foundry if you want to test it. The URL is http://blog-api.cloudfoundry.com and a sample curl request would be:
curl -i http://blog-api.cloudfoundry.com/weblogs

I’ve followed your instructions for adding grape-swagger and then try to explore it using the online swagger demo. Everything renders ok, however, when I test any part of my api using the demo, the response body is empty and the response code is 0; although the log file on the server-side shows the request being handled. Any thoughts as to what is wrong?

Many thanks, Diarmuid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions