No release in over 3 years
Low commit activity in last 3 years
Grape REST-like API application generator based on Thor.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 5.11
~> 13.0
~> 0.16

Runtime

~> 1.0.1
 Project Readme

Gem Version Build Status Maintainability Test Coverage

GrapeThor

Grape REST-like API generator based on Thor.

Installation

Install it yourself as:

$ gem install grapethor

Usage

Get some help

$ grapethor help

Commands:
  grapethor api VERSION               # Creates new API within application
  grapethor endpoint RESOURCE [NAME]  # Creates new Endpoint within API
  grapethor help [COMMAND]            # Describe available commands or one specific command
  grapethor new NAME                  # Creates new Grape application
  grapethor resource NAME             # Creates new Resource within API
  grapethor version                   # Displays Grapethor version

Create application

$ grapethor help new

Usage:
  grapethor new NAME

Options:
  -p, [--path=PATH]                # Relative path to place application directory
                                   # Default: .
  -x, [--prefix=PREFIX]            # Add Application URL prefix
                                   # Default: api
  -d, [--db=DB]                    # Use specific database
                                   # Default: sqlite
                                   # Possible values: sqlite, postgresql, mysql
  -o, [--orm=ORM]                  # Use specific ORM
                                   # Default: activerecord
                                   # Possible values: activerecord
  -s, [--server=SERVER]            # Preconfigure web server
                                   # Default: thin
                                   # Possible values: thin, puma
  -t, [--test=TEST]                # Use specific test framework
                                   # Default: minitest
                                   # Possible values: minitest, rspec
      [--docker], [--no-docker]    # Use docker
                                   # Default: true
  -l, [--license=LICENSE]          # Add software license information
                                   # Default: mit
                                   # Possible values: mit, apache2, freebsd, newbsd, gpl2, gpl3, mpl2, cddl1, epl1
  -c, [--copyright=COPYRIGHT]      # Add copyright information within license file
  -r, [--ruby=RUBY]                # Ruby version for application
                                   # Default: 2.5.3 (current ruby version)
      [--swagger], [--no-swagger]  # Generate swagger documentation and install swagger-ui
                                   # Default: true

License types available for --license option:

Create API

$ grapethor help api

Usage:
  grapethor api VERSION

Options:
  -p, [--path=PATH]            # Relative path to application directory
                               # Default: .

Creates new API within application

Do not forget to cd into application directory before run this command. Otherwise use --path option.

Multiple API versions may be created for single application.

Create Resource

$ grapethor help resource

Usage:
  grapethor resource NAME

Options:
  -p, [--path=PATH]             # Relative path to application directory
                                # Default: .
  -v, [--version=VERSION]       # API version tag
                                # Default: v1
  -a, [--attrs=ATTRIBUTE:TYPE]  # Model attributes (use proper types or specific ORM)

Creates new Resource within API

Multiple RESOURCES may be created for single API version

Note: ':id' request path parameter is implicitly used as primary key. There is no need to include it with '-a' option.

Model attribute types available for specific ORM:

  • activerecord: bigint, binary, boolean, date, datetime, decimal, float, integer, numeric, string, text, time

Create Endpoint

$ grapethor help endpoint

Usage:
  grapethor endpoint RESOURCE [NAME]

Options:
  -p, [--path=PATH]         # Relative path to application directory
                            # Default: .
  -v, [--version=VERSION]   # API version tag
                            # Default: v1
  -m, [--method=METHOD]     # HTTP request method
                            # Default: GET
                            # Possible values: GET, POST, PUT, DELETE
  -d, [--desc=DESC]         # Endpoint description
  -a, [--params=key:value]  # Request resource (path) param
  -q, [--query=key:value]   # Request query params

Creates new Endpoint within API

Multiple ENDPOINTS may be created for single API version.

This command may be also used for an addition into existing RESOURCE CRUD.

How-To

Sample Workflow

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rawongithub/grapethor.

License

The software is available as open source under the terms of the MIT License.