switchdreams / rest-api-generator Goto Github PK
View Code? Open in Web Editor NEWBuild a Ruby on Rails REST API faster
Home Page: https://rest-api-generator.switchdreams.com.br/
License: MIT License
Build a Ruby on Rails REST API faster
Home Page: https://rest-api-generator.switchdreams.com.br/
License: MIT License
Readme.md docs is hard to read and understand, normally in SwitchDreams we use vitepress
Support pagination
Support serialization by default
When creating a rswag spec for a resource with rails g rest_api_generator:spec:rswag Car name:string color:string year:integer
, it currently ignores fields types and sets everything as string on params (for post and patch requests).
Setup for testing
When we generate a nested or scoped resources this message shows in terminal:
You need to manually setup routes files for nested or scoped resource
But is possible to setup this automatic.
The goals is to reduce when use filter resource function:
Project.filter_resource(params.slice(*Project.filter_scopes)
Most of the time the filter resource argument is params.slice(*Project.filter_scopes)
, we can setup the default value of filter resource to that
Filter some resource by parameters
/projects?archived=true
# From https://hspazio.github.io/2018/rails-filterable-concern/
module Filterable
extend ActiveSupport::Concern
included do
@search_scopes ||= []
end
module ClassMethods
attr_reader :search_scopes
def search_scope(name, *args)
scope name, *args
@search_scopes << name.to_s.gsub('filter_by_', '').to_sym
end
def filter(params)
results = where(nil)
params.each do |key, value|
results = results.public_send("filter_by_#{key}", value) if value.present?
end
results
end
end
end
This feature wants to achieve sorting for any field from the resource, example:
http://example.com/articles?sort=+author
Add option to generate rswag specs with bearer token authentication syntax configured
This actual error handler module does not handle well forms attributes. This approach seens better: https://driggl.com/blog/a/handling-exceptions-in-rails-applications
When we are trying to setup authorization, regularly we need to run a method with the resource as params.
Example with action policy
before_action -> { authorize! @power_plant, with: PowerPlantChildrenPolicy }
i think a good API is:
after_set_resource ->(resource) { authorize! resource, with: PowerPlantChildrenPolicy }
and
after_set_parent_resource ->(resource) { authorize! resource, with: PowerPlantChildrenPolicy }
Improves pagination docs with the pagination headers and cors configuration
Write in README.md the step for this gems
When generating a new resource, I want to generate automatic documentation too
Using this gem: https://github.com/rswag/rswag
When we run:
rails g rest_api_generator:resource Task student:references
The generated controller params is;
def task_params
params.require(:task).permit(:student)
end
its is expected to be:
def task_params
params.require(:task).permit(:student_id)
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.