Skip to main content

aubergine: create REST APIs using API-first approach.

Project description

License: MIT

aubergine is a library that helps you effortlessly create REST API using API-first approach.

Creating an API in aubergine is simple and requires only the following steps:

  1. Create your OpenAPI 3 specification file, with operationId set to the callable of your choice.

openapi: "3.0.0"
servers:
  - url: /v1/rest
info:
  version: 1.0.0
  title: Hello World
  description: My first api.
paths:
  /hello:
    get:
      operationId: hello_world.hello
      parameters:
        - who: who
          in: query
          description: who to great
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Greeting dedicated to given name.
          content:
            application/json:
              schema:
                  $ref: '#/components/schemas/Greeting'
components:
  schemas:
    Greeting:
      required:
        - message
      properties:
        message:
          type: string
  1. Implement operations that you declared in your specification. Place hello_world module with the following content in an importable directory.

def hello(who):
    """Handles v1/rest/hello"""
    return {'message': 'Hello {}!'.format(who)}
  1. Tell aubergine to create an app for you. Create a hello_app.py with the following contents:

from aubergine import Aubergine

app = Aubergine.from_file('hello_world.yml')
api = app.build_api()
  1. Your app is ready to go. You can run it with any WSGI server like so:

gunicorn hello_app:api

Test it by navigating to http://localhost:8000/v1/rest/hello?who=World

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aubergine-0.1.2.tar.gz (18.4 kB view details)

Uploaded Source

File details

Details for the file aubergine-0.1.2.tar.gz.

File metadata

  • Download URL: aubergine-0.1.2.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aubergine-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ea9a6dceb85c26da1131c5022dfa98eed07eef9a8e6392af550b6277ba600ce3
MD5 4d7089386bd7f28eda0f9bd36ae1fc43
BLAKE2b-256 4e1bcf6d7634cd5e642eac96bca4876ee9ad0353035c75620acda148fc2cc826

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page