Skip to main content

Flask extension for using “specification first” principle.

Project description

Flask extension for using “specification first” principle.

Features:

  • Decorator for mapping routes from OpenAPI specification on Python’s functions via Flask.

  • Building Flask routes with path-parameters. Flask converters are available:

    • string - accepts any text without a slash (the default)

    • int - accepts integers

    • float - like int but for floating point values

Installing

Install and update using pip:

$ pip install -U Flask-First

A Simple Example

OpenAPI 3 specification file example.yaml:

openapi: 3.0.3
info:
  title: Simple API for Flask-First
  version: 1.0.0
paths:
  /index/{name}:
    get:
      operationId: index
      summary: Returns a list of items
      responses:
        '200':
          description: OK

File with application initialization main.py:

from flask import Flask
from flask_first import First

basedir = os.path.abspath(os.path.dirname(__file__))
path_to_spec=os.path.join(basedir, "specs", "example.yaml")

app = Flask(__name__)
app.config["FIRST_RESPONSE_VALIDATION"] = True
First(app, path_to_spec=path_to_spec)


@app.specification
def index(name):
    return f'Hello, {name}!'

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

flask_first-0.1.1.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

flask_first-0.1.1-py2.py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 2 Python 3

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