generator-schlesinger v1.0.5
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 yonpm 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-schlesingerFinally, initiate the generator:
It is best to setup and activate a virtualenv before initializing.
yo schlesingerGetting 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-apiEndpoint
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 myendpointEndpoint 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 mymodelVersion
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:versionOptions
--helpView documentation from the comfort of your terminal.--skip-installSkips installing dependencies viapipand creating requirements file.