Skip to content

Pixis is a flexible and lightweight Python 3 module that can generate server and client files for your REST API

License

Notifications You must be signed in to change notification settings

microservice-tools/pixis

Repository files navigation

Pixis   Build Status

Pixis is a flexible and lightweight Python 3 module that can generate server and client files for your REST API. You provide an OpenAPI3 Specification, we generate the skeleton code to get your API up and running.

Our system allows for simple and flexible customization. The default Jinja2 templates can be modifed and/or replaced, so you can generate exactly the code you want. Our build file lets you specify exactly how you want your project to look like, and with a little Python, you can add custom functionality to Pixis, and even generate code in a new language!

Currently supported server languages:

Currently supported client languages:


Table of Contents

Virtual Environment Setup

Linux & Mac Users:

  1. Install latest version of virtualenv using: sudo pip3 install virtualenv
  2. Create virtual environment: virtualenv venv
  • Activate virtual environment: source venv/bin/activate
  • Deactivate virtual environment: deactivate

Installation

  1. Clone this project
  2. Activate virtualenv
  3. Two options to install:
    • Using pip3:
      • pip3 install pixis/
    • Using setup.py:
      • cd pixis
      • python3 setup.py develop
  • Uninstall:
    • pip3 uninstall pixis

Note: If you are having issues installing on Mac OSX try - pip3 install pbr certifi

Usage

Pixis default behavior: Implementation is Flask, Output is build/, Templates is templates/, Specification file is swagger.yaml

$ pixis: Looks for build.py in the current directory.

OPTION LONG ARGUMENTS DESCRIPTION DEFAULT
-h --help N/A Displays Pixis information and commands N/A
-b --build build_file Set build file location "build.py"
-o --output output_dir Set output directory location "build"
-t --templates templates_dir Set local template directory "templates"
-w --overwrite N/A Enables Pixis to overwrite any files during generation False
-v --verbose N/A Displays additional information during generation False

Refer to BUILD.md for more information on the build file


Quick Start

We recommend using a virtual environment when generating and testing generated code.

Generating a server

This example will use our samples/python-flask-server/ directory, containing build.py and swagger.yaml

$ cd samples/python-flask-server/
$ pixis [-b build.py]
$ cd build
$ pip3 install -r requirements.txt
$ pip3 install .
$ my_flask_server
  • A server should be opened on your localhost
  • To test a route, append to the basepath: /pet/0
  • You should see the route printed onto the screen
  • Future versions will have more exciting examples!

To run in a docker container:

  • $ docker build -t your_tag .
  • $ docker run -p 8080:8080 your_tag .

Generating a client

To use the Angular2/TypeScript client, some prerequisites need to be installed. Earlier versions are untested.

  • node.js >= 8.6.0
  • npm >= 5.6.0
    • installed with node.js
    • get latest version with: [sudo] npm install npm -g
  • angular/cli >= 1.4.6
    • [sudo] npm install -g @angular/cli@latest

This example will use our ready to go Angular2 project sample-project in samples/typescript-angular-client. Our project contains edits (imports and API usage) that a newly generated Angular2 project will not have. Instruction for generating a new Angular2 project can be found here.

samples/typescript-angular-client includes build.py and swagger.yaml

$ cd sample/typescript-angular-client
$ pixis build.py
$ mv services/ sample-project/src/
$ cd sample-project
$ npm install

To run the client: npm start or ng serve

To run in a docker container:

  • $ docker build -t your_tag .
  • $ docker run -p 4200:4200 your_tag .

Specification File

Specification file according to OpenAPI 3.0 Specification guidelines https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md

Build File (build.py)

Refer to BUILD.md

About

Pixis is a flexible and lightweight Python 3 module that can generate server and client files for your REST API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published