Rails concern to implement CRUD API controllers for Mongoid models using Open API (Swagger) specification.
Automatic generate powerful representation of your RESTful API.
Setup:
- Add to you Controller
include SwaggerGenerator
- Add to the end of controller:
generate_swagger
to generate swagger description of current controller's actions - To integrate these description with Swagger UI - Add routes and create Swagger Controller
- Check Swagger UI at
localhost:3000/docs/api/swaggers
swagger_options:
json_requests: true
- make all call in json formatscopes: [ { name: :selects, type: :boolean } ]
- add sope to swaggerresource_class_name: 'UserProfessional'
- customize resource/model name. For case, when you have ProfileController, but working/using UserProfessional model hereignore_custom_actions: true
- don't generate custom/not CRUD actionscollection_name: 'Bootstrap'
- For Customize tags and OperationId postfixbase_path: '/api/admin'
- if you usingkey :basePath
in Swagger Controller write it hererelative_path: 'professional/projects'
(Will be depricated and using onlybase_path
) - use relative path without basePath for actions.Might be helpfull whenkey :basePath, '/api'
present in Swagger Controller, to prevent generating paths:'api/api/professional/projects'