API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. A lightweight alternative to postman/insomnia.
[x] I have updated my branch and synced it with project main branch before making this PR
[x] I have run the tests (flutter test) and all tests are passing
Added/updated tests?
[x] Yes, I have added and tested all the test cases and the generated code behaves as expected.
Instructions to run the generated code in local computer
Install ruby and setup path so that ruby and gem executable are available.
Run
gem install bundler
to install bundle as a command line tool.
Inside a directory create one GemFile and main.rb file.
Add faraday as mentioned in the Documentation and Faraday Multipart for sending multipart form requests. Add them inside the GemFile along with one source attribute at the top of the GemFile. Then run
bundle install
to install the dependencies.
Copy the generated code inside main.rb file.
Run ruby ./main.rb to run the generated code.
Note: For HEAD 2 test case, the initial response has status code 301 but faraday_middleware gem, which was previously required for following redirections, is deprecated and a curated list has been published under awesome-faraday by the maintainers. The redirection middleware is now bundled as it's own gem faraday-follow-redirects which is an external dependency which I have not included in code generator.
I wish to add that after discussing that with maintainers. Integrating redirection following is mentioned in the documentation as
and can be achieved by adding the faraday.response :follow_redirects statement above adapter setup.
Along with that, we need to add the require statement with the existing require statements so that the respective code is imported.
Thus currently running generated code for HEAD 2 returns 301 whereas API Dash returns 405, which can be modified by the above way and changed to whichever output is desired by the user. If required, I am willing to add the support for redirection and modify the required code.
PR Description
This PR adds automated code generation for Ruby's Faraday library and also tests the generated code.
Related Issues
Checklist
main
branch before making this PRflutter test
) and all tests are passingAdded/updated tests?
Instructions to run the generated code in local computer
ruby
andgem
executable are available.to install
bundle
as a command line tool.GemFile
andmain.rb
file.GemFile
along with onesource
attribute at the top of theGemFile
. Then runto install the dependencies.
main.rb
file.ruby ./main.rb
to run the generated code.Note: For
HEAD 2
test case, the initial response has status code 301 but faraday_middleware gem, which was previously required for following redirections, is deprecated and a curated list has been published under awesome-faraday by the maintainers. The redirection middleware is now bundled as it's own gem faraday-follow-redirects which is an external dependency which I have not included in code generator.I wish to add that after discussing that with maintainers. Integrating redirection following is mentioned in the documentation as
and can be achieved by adding the
faraday.response :follow_redirects
statement above adapter setup.Along with that, we need to add the require statement with the existing require statements so that the respective code is imported.
Thus currently running generated code for
HEAD 2
returns 301 whereas API Dash returns 405, which can be modified by the above way and changed to whichever output is desired by the user. If required, I am willing to add the support for redirection and modify the required code.