• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

technekes/grape-slate: Allows for generating a Slate (https://github.com/tripit/ ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

technekes/grape-slate

开源软件地址:

https://github.com/technekes/grape-slate

开源编程语言:

Ruby 88.8%

开源软件介绍:

GrapeSlate

Code Climate Build Status Coverage Status Dependency Status Gem Version

Auto generates an Slate Document from the docuementation that is created by your Grape API.

NOTE

This is an early implementation that makes some assumptions about your API (follows a standard REST pattern) that works with our implementation of Grape API's. There is a new an unreleased feature in Grape that allows for appending additional documentation. This project is dependent on this feature in order to create example JSON requests and responses.

Installation

Add this line to your application's Gemfile:

gem 'grape', github: 'intridea/grape' # see note above
gem 'grape-slate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install grape-slate

Usage

Add some metadata about your API and then execute the generate method on the GrapeSlate::Blueprint class.

Configuration

Configure details about your api in an initializers or similar:

GrapeSlate.config do |config|
  # the name of your api
  config.name               = 'Awesome API'
  # a description for your api
  config.description        = 'The awesome description'
  # the type to use for generated sample id's (`integer` or `uuid`)
  config.example_id_type    = :uuid
  # resources you do not want documented
  config.resource_exclusion = [:admin, :swagger_doc]
  # whether or not examples should include a root element (default: false)
  config.include_root       = true
end

# request headers you want documented
GrapeSlate.config.request_headers = [
  { 'Accept-Charset' => 'utf-8' },
  { 'Connection'     => 'keep-alive' }
]

# response headers you want documented
GrapeSlate.config.response_headers = [
  { 'Content-Length' => '21685' },
  { 'Connection'     => 'keep-alive' }
]

Generation

# supply the class you'd like to document and generate your blueprint
GrapeSlate::Document.new(AwesomeAPI).generate

TODO

  • Add a rake task to simplify generation
  • Add support for listing all of a resources attributes at the resource level as a markdown table
  • Handle ever changing sample id's (don't want git diff's after every generation)
  • Add option to change or remove the sample id field (eg. _id vs id)
  • What if someone does not use JSON?!?
  • Create sample response for list endpoints (array)
  • Add support for writing the blueprint to disk
  • Add an option to include root in json

Contributing

  1. Fork it ( http://github.com/connexio-labs/grape-slate/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap