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

Resource bug #860

Closed
dlanileonardo opened this issue Dec 20, 2014 · 3 comments
Closed

Resource bug #860

dlanileonardo opened this issue Dec 20, 2014 · 3 comments
Labels

Comments

@dlanileonardo
Copy link

I think that have a bug in 0.10.0 version, because i use the same code in two versions and the endpoints get Not Found in 0.10.0:

Using 0.10.0:

$ curl -X GET http://msmm-api.azk.dev/v1/company.json
Not Found%

Using 0.9.0:

$ curl -X GET http://msmm-api.azk.dev/v1/company.json
[{"cid":7,"name":"acme","description":"Acme"},{"cid":8,"name":"teste","description":"teste"}]

My class:

class API::Status < API::Base
  desc "Returns the status of the API"
  get '/status' do
    { status: 'ok' }
  end
end

class API::Company < API::Base
  resource :company do
    desc 'Returns list Companies', entity: Company::Entity
    get '/' do
      companies = Company.all
      present companies
    end
  end
end

The endpoints in resource method dont work, but in root this works in both versions.

$ curl -X GET http://msmm-api.azk.dev/v1/status.json
{"status":"ok"}
@dblock
Copy link
Member

dblock commented Dec 20, 2014

I don't see any references to v1 here.

Does the API work without the .json extension in the request?

@dblock dblock added the bug? label Dec 22, 2014
@dlanileonardo
Copy link
Author

I use Root class:

class API::Root < Grape::API
  version: 'v1', :using => :path
  format :json
  default_format :json
  ...
  mount API::Status
  mount API::Company
end

Yes without .json extesions works on 0.10.0!

But in rspec, i use:

get "/v1/user.json"

And Works.

@dblock
Copy link
Member

dblock commented Dec 22, 2014

This was documented in https://github.com/intridea/grape/blob/master/UPGRADING.md and is by design. See #809 for more information. I am happy to reopen a discussion whether this is the right thing to do, but I sided with the argument that yes when it was brought up.

@dblock dblock closed this as completed Dec 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants