https://github.com/fernandes/trailblazer-doc
https://github.com/fernandes/trailblazer-doc
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/fernandes/trailblazer-doc
- Owner: fernandes
- License: mit
- Created: 2019-02-27T15:51:53.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T16:57:05.000Z (about 6 years ago)
- Last Synced: 2025-01-29T11:44:40.405Z (3 months ago)
- Language: Ruby
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Trailblazer Doc
This gem provides an (ultra) this layer that wraps the forms and representable data into something ready to be consumed.
What I mean? Imagine (yeah, this was the real case that inspired the gem) that you wanna document your API, you already has all your contracts and representers extremely defined, why do we need to redeclare everything on swagger.
And worse, how to keep that in sync? This is completely insane!!1
How to use it?
For Reform, just require the reform (it's not autoloaded because you can use just for reform/representable)
```ruby
require 'trailblazer/doc/reform'class AlbumForm < Reform::Form
include Reform::Docproperty :title
validates :title, presence: true
end
``````ruby
require 'trailblazer/doc/representable'class AlbumRepresenter < Representable::Decorator
include Representable::JSON
include Representable::Docproperty :id
property :title
end
```Then after that you can access some data like:
```ruby
AlbumForm.doc.properties
# [:title]AlbumForm.doc.validations
# {
# :title=>[ {:presence=>true} ],
# :year=>[ {:presence=>true, :numericality=>true} ]
# }
```This is just the first step, the next (aka Roadmap) are:
- [ ] Provide a configurator so we only allocate data in development / testing, never in production
- [ ] Maybe provide some better API to access all the [Reform API](http://trailblazer.to/gems/reform/api.html) and [Representable API](http://trailblazer.to/gems/representable/3.0/api.html)## Installation
Add this line to your application's Gemfile:
```ruby
gem 'trailblazer-doc'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install trailblazer-doc
## Development
That usual red-green-refactor
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/fernandes/trailblazer-doc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
TL;DR As human beings, living in the same world, respect everyone that participates in this project, not in your own definition of respect, but in other's definition; If in doubt ask the other part. **Spread kindness.**
Everyone interacting in the Trailblazer::Doc project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fernandes/trailblazer-doc/blob/master/CODE_OF_CONDUCT.md).