README
Flask API Generator using Flask-RESTful and Flask Blueprints
Contents
Getting Started
What is Yeoman?
To get started you must first install Yeoman. Yeoman is available from the npm package repository.
npm install -g yo
npm is needed to do this. If you don't have npm then install it, npm is usually installed with node, best to install nodejs also.
Yeoman Generators
Yeoman generators are like plug-ins and are designed to build particular applications.
To install generator-schlesinger from npm, run:
npm install -g generator-schlesinger
Finally, initiate the generator:
It is best to setup and activate a virtualenv before initializing.
yo schlesinger
Getting Started
Usage
Create and activate a Python virtual environment if you haven't already:
virtualenv venv
. venv/bin/activate
(You don't HAVE to create a venv, but it's a good idea.)
Make a new directory, and cd
into it:
mkdir my-cool-api && cd $_
Run yo schlesinger
with your API's name:
yo schlesinger my-cool-api
(API name defaults to app
)
Set some environment variables, like your config and database URI:
export MY_COOL_API_CONFIG=development
export MY_COOL_API_DEVELOPMENT_DATABASE_URI=postgres://localhost/mydb
(Prefixed with your app's name, for your convenience.)
Generators
Available generators:
App
Your starting point. You can pass the application name as an argument.
You can choose your database flavor, versioning scheme, and URL structure. It will install your Python dependencies with Pip.
yo schlesinger pretty-fly-for-an-api
Endpoint
Creates a URL endpoint and respective tests, containing the routes for a resource. You get to specify what HTTP methods it supports. You should import it into your API blueprint after creation.
yo schlesinger:endpoint myendpoint
Endpoint URLs are automatically pluralized. Or close to it, at any rate. Sorry in advance, wild goose web services.
Model
Creates a SQLAlchemy model, containing the data about a resource. You should import it into any associated endpoints or schemas.
yo schlesinger:model mymodel
Version
Bumps your API's version, creating a new package and blueprint for it. If you're on a major versioning scheme, it'll bump your major version. If you're on a minor versioning scheme, you'll need to specify which version to bump. If you're not using a versioning scheme, you might be confused.
yo schlesinger:version
Options
--help
View documentation from the comfort of your terminal.--skip-install
Skips installing dependencies viapip
and creating requirements file.