mirror of
https://github.com/ditkrg/jsonapi-swagger.git
synced 2026-01-22 22:06:50 +00:00
72 lines
1.5 KiB
Markdown
72 lines
1.5 KiB
Markdown
# JSONAPI Swagger
|
|
|
|
Generate JSONAPI Swagger Doc.
|
|
|
|
[](https://rubygems.org/gems/jsonapi-swagger)
|
|
[](https://github.com/superiorlu/jsonapi-swagger/blob/master/LICENSE)
|
|
|
|
[](https://i.loli.net/2019/05/05/5ccebf5e782b7.gif)
|
|
|
|
## Installation
|
|
|
|
Add this line to your application's Gemfile:
|
|
|
|
```ruby
|
|
gem 'jsonapi-swagger'
|
|
```
|
|
|
|
And then execute:
|
|
|
|
$ bundle
|
|
|
|
Or install it yourself as:
|
|
|
|
$ gem install jsonapi-swagger
|
|
|
|
## Usage
|
|
|
|
1. config jsonapi swagger
|
|
```rb
|
|
# config/initializers/swagger.rb
|
|
Jsonapi::Swagger.config do |config|
|
|
config.use_rswag = false
|
|
config.version = '2.0'
|
|
config.info = { title: 'API V1', version: 'V1'}
|
|
config.file_path = 'v1/swagger.json'
|
|
end
|
|
```
|
|
|
|
2. generate swagger.json
|
|
|
|
```sh
|
|
# gen swagger/v1/swagger.json
|
|
bundle exec rails generate jsonapi:swagger User # UserResource < JSONAPI::Resource
|
|
```
|
|
|
|
3. additional
|
|
|
|
use `rswag`, have to run
|
|
|
|
```sh
|
|
# gen swagger/v1/swagger.json
|
|
bundle exec rails rswag:specs:swaggerize
|
|
```
|
|
|
|
## RoadMap
|
|
|
|
- [x] immutable resources
|
|
- [x] filter/sort resources
|
|
- [x] mutable resources
|
|
- [x] generate swagger.json without rswag
|
|
|
|
## Resource
|
|
|
|
- [JSONAPI](https://jsonapi.org/)
|
|
- [JSONAPI::Resources](http://jsonapi-resources.com/)
|
|
- [Rswag](https://github.com/domaindrivendev/rswag)
|
|
|
|
## Contributing
|
|
|
|
Bug reports and pull requests are welcome on GitHub at
|
|
https://github.com/superiorlu/jsonapi-swagger.
|