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

Error opening a file after update to 1.5.0 #865

Open
cbisio opened this issue Aug 2, 2022 · 3 comments
Open

Error opening a file after update to 1.5.0 #865

cbisio opened this issue Aug 2, 2022 · 3 comments

Comments

@cbisio
Copy link

cbisio commented Aug 2, 2022

After updating to 1.5.0, it started throwing this error:

Error: Error opening file "/home/runner/work/api/api/swagger_doc.json" 
ENOENT: no such file or directory, open '/home/runner/work/api/api/swagger_doc.json'

Rolling back to previous version

@LeFnord
Copy link
Member

LeFnord commented Aug 3, 2022

please can you describe a bit more what happens, so one can reprocude it, ideally writing a spec with the bad behaviour, thanks

@cbisio
Copy link
Author

cbisio commented Aug 9, 2022

I simply can't run any spec because it throws the error above

@irashlapak
Copy link

Had a similar problem related to swagger doc generation https://github.com/ruby-grape/grape-swagger#openapiswagger-documentation

Due to the changes https://github.com/ruby-grape/grape-swagger/pull/846/files#diff-858484a86a433201a2b47c90554864d3b2a97ceb23e28fe5d80662231a3ac9afR118 now all the generated files are appended with the version for their names.

def file(url)
  api_version = url.split('/').last

  name = if ENV['store'] == 'true' || ENV['store'].blank?
     "swagger_doc_#{api_version}.json"
  else
    ENV['store'].sub('.json', "_#{api_version}.json")
  end

  File.join(Dir.getwd, name)
end

Then:

store=true => "swagger_doc.json"
store=custom_file_name.json => "custom_file_name.json"

Now:

store=true => "swagger_doc_swagger_doc.json"
store=custom_file_name.json => "custom_file_name_swagger_doc.json"

For our setup, the api_version is evaluated as "swagger_doc". But I believe we should have had an empty line instead, cause we don't have an API versioning.

# url = "/swagger_doc" (by default)
#
api_version = url.split('/').last 
=> "swagger_doc"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants