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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for flask_first-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f40e02ed02ef7c893d1f89141becd91cf39ea1caad5ae0406dc08d527b4462 |
|
MD5 | ee234448d70c5153da1bb604fe98e334 |
|
BLAKE2b-256 | 0e11a19118d53ff7cb41c8c67a896ac76a4de2d98f6fb4c2d06c4699e7501876 |