Closed tuexss closed 8 years ago
Hi @tuexss, Thanks for getting in touch and reporting your issue!
From the error message it looks like Apivore is unable to successfully perform the GET request on the swagger file at http://localhost:8000/api.json
I don't think it has to do with the content of the file at this stage.
The Apivore method that gave this error is https://github.com/westfieldlabs/apivore/blob/2c111c2e9ab632c36ad9c542a4ae7b8ee5459ce7/lib/apivore/swagger_checker.rb#L65 :
def fetch_swagger!
session = ActionDispatch::Integration::Session.new(Rails.application)
begin
session.get(swagger_path)
rescue
fail "Unable to perform GET request for swagger json: #{swagger_path} - #{$!}."
end
JSON.parse(session.response.body)
end
I haven't looked into this too deeply yet, the code above is more for my reference to dig deeper, it might help point you in the right direction too. My initial thought is that it may be something to do with whether your application is recognised as a Rails.application
by the tests, or whether ActionDispatch::Integration::Session
is available/makes sense in your context.
Could you please let me know what version of Rails and rspec you are using, and if there are any line numbers on the undefined method
call' for nil:NilClass.? I suspect that error is from
ActionDispatch`, but am not sure. Also, is there anything obviously "non-standard" about your application, (yeah, sorry, I know that's a bit vague!) we have had issues in the past caused by Apivore's assumptions about what rails and rspec helpers and methods might be available, we have tightened a lot of them, but it's possible some have been missed.
Ah, thanks. Now I understand my mistake. It's a sinatra app after all :) Please close this issue.
Heh, that does explain the issues :D I'll close the issue as requested, but I'll also, if I get the time, have a think about how to make Apivore less dependant on Rails so it can be used with Sinatra too, because that would be nice and make sense for lighter APIs. Thanks @tuexss for getting me thinking about Sinatra too!
Yeah, that would be nice. And I learned, to better read the requirements section. :)
I always get this: {code} Failure/Error: subject { Apivore::SwaggerChecker.instance_for('http://localhost:8000/api.json') } RuntimeError: Unable to perform GET request for swagger json: http://localhost:8000/api.json - undefined method `call' for nil:NilClass. {code}
I'm not sure what is the problem. According to the readme I did everything correctly. My only guess is, that the .json-file does not fully comply with swagger specification in some way? As the error message is not really helping, can someone tell me where to look for my mistake?