Skip to main content

A Falcon Framework extension featuring Swagger, SQLAlchemy and Redis

Project description

[![Build Status](https://travis-ci.org/dutradda/falcon-swagger.svg?branch=master)](https://travis-ci.org/dutradda/falcon-swagger)
[![Coverage Status](https://coveralls.io/repos/github/dutradda/falcon-swagger/badge.svg?branch=master)](https://coveralls.io/github/dutradda/falcon-swagger?branch=master)

# falcon-swagger
A Falcon Framework (http://falconframework.org) Extension.

Features:
- Supports Swagger Schema 2.0 (OpenAPI 2.0);
- Provides SQLAlchemy models base classes (with Redis integration, if you want);
- Provides Redis models base classes (without SQLAlchemy).

Usage Example:

```python
from falconswagger import SwaggerAPI, ModelHttpMeta

class HelloModelMeta(ModelHttpMeta):
__schema__ = {
'/hello/you/{name}': {
'get': {
'parameters': [{
'name': 'name',
'in': 'path',
'required': True,
'type': 'string'
}],
'operationId': 'get_hello_you',
'responses': {'200': {'description': 'Got you'}}
}
},
'/hello/world': {
'get': {
'operationId': 'get_hello_world',
'responses': {'200': {'description': 'Got hello'}}
}
}
}

def get_hello_you(cls, req, resp):
you = req.context['parameters']['path']['name']
resp.body = 'Hello {}!\n'.format(you)

def get_hello_world(cls, req, resp):
resp.body = 'Hello World!\n'

class HelloModel(metaclass=HelloModelMeta):
pass

api = SwaggerAPI([HelloModel], title='Hello API')
```

```bash
gunicorn hello_word_api:api
```

```bash
curl -i localhost:8000/hello/world
```

```text
HTTP/1.1 200 OK
Server: gunicorn/19.6.0
Connection: close
content-length: 13
content-type: application/json; charset=UTF-8

Hello World!
```

```bash
curl -i localhost:8000/hello/you/Diogo
```

```text
HTTP/1.1 200 OK
Server: gunicorn/19.6.0
Connection: close
content-length: 13
content-type: application/json; charset=UTF-8

Hello Diogo!
```


```bash
curl -i localhost:8000/swagger.json
```

```json
HTTP/1.1 200 OK
Server: gunicorn/19.6.0
Connection: close
content-length: 672
content-type: application/json; charset=UTF-8

{
"swagger": "2.0",
"paths": {
"/hello/world": {
"get": {
"operationId": "HelloModel.get_hello_world",
"responses": {
"200": {
"description": "Got hello"
}
}
}
},
"/hello/you/{name}": {
"get": {
"operationId": "HelloModel.get_hello_you",
"responses": {
"200": {
"description": "Got you"
}
},
"parameters": [
{
"in": "path",
"type": "string",
"required": true,
"name": "name"
}
]
}
}
},
"info": {
"title": "Hello API",
"version": "1.0.0"
}
}
```

Project details


Release history Release notifications

This version
History Node

0.14.4

History Node

0.14.3

History Node

0.14.2

History Node

0.14.1

History Node

0.14.0

History Node

0.13.0

History Node

0.12.7

History Node

0.12.6

History Node

0.12.5

History Node

0.12.4

History Node

0.12.3

History Node

0.12.2

History Node

0.12.1

History Node

0.12.0

History Node

0.11.1

History Node

0.11.0

History Node

0.10.0

History Node

0.9.4

History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.8.4

History Node

0.8.3

History Node

0.8.2

History Node

0.8.1

History Node

0.8.0

History Node

0.7.0

History Node

0.6.0

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.0

History Node

0.2.0

History Node

0.1.1

History Node

0.1.0

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
falcon-swagger-0.14.4.tar.gz (25.4 kB) Copy SHA256 hash SHA256 Source None Dec 20, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page