All Projects → alysivji → falcon-apispec

alysivji / falcon-apispec

Licence: MIT license
apispec plugin that generates OpenAPI specification (aka Swagger Docs) for Falcon web applications.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to falcon-apispec

spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+331.82%)
Mutual labels:  openapi, falcon, apispec
Pix Api
API Pix: a API do Arranjo de Pagamentos Instantâneos Brasileiro.
Stars: ✭ 832 (+1790.91%)
Mutual labels:  spec, openapi
ntast
Notion Abstract Syntax Tree specification.
Stars: ✭ 101 (+129.55%)
Mutual labels:  spec, specification
specifications-ITS-REST
openEHR REST API Specifications
Stars: ✭ 20 (-54.55%)
Mutual labels:  openapi, specification
L5 Swagger
OpenApi or Swagger integration to Laravel
Stars: ✭ 1,781 (+3947.73%)
Mutual labels:  openapi, specification
Openapi Spec Validator
OpenAPI Spec validator
Stars: ✭ 161 (+265.91%)
Mutual labels:  openapi, specification
Specs
The Filecoin protocol specification
Stars: ✭ 249 (+465.91%)
Mutual labels:  spec, specification
openapi
GitHub's official OpenAPI spec with Octokit extensions
Stars: ✭ 24 (-45.45%)
Mutual labels:  openapi, specification
tinyspec
Simple syntax for describing REST APIs
Stars: ✭ 95 (+115.91%)
Mutual labels:  openapi, specification
openapi-types.ts
Generated TypeScript definitions based on GitHub's OpenAPI spec
Stars: ✭ 30 (-31.82%)
Mutual labels:  openapi, specification
openapi
OpenAPI 3 Specification for golang
Stars: ✭ 18 (-59.09%)
Mutual labels:  openapi, specification
box-openapi
OpenAPI 3.0 Specification for the Box APIs
Stars: ✭ 71 (+61.36%)
Mutual labels:  openapi, specification
apispec-webframeworks
Web framework plugins for apispec (formally in apispec.ext).
Stars: ✭ 25 (-43.18%)
Mutual labels:  openapi, apispec
eggplant
A behaviour driven development (BDD) library for Clojure. Simplicity is key.
Stars: ✭ 16 (-63.64%)
Mutual labels:  spec, specification
ApiCenter
A repository for all your API specifications
Stars: ✭ 26 (-40.91%)
Mutual labels:  openapi, specification
Proposals
Tracking ECMAScript Proposals
Stars: ✭ 14,444 (+32727.27%)
Mutual labels:  spec, specification
spec-pattern
Specification design pattern for JavaScript and TypeScript with bonus classes
Stars: ✭ 43 (-2.27%)
Mutual labels:  spec, specification
framework
Lightweight, open source and magic-free framework for testing solidity smart contracts.
Stars: ✭ 36 (-18.18%)
Mutual labels:  spec, specification
es-abstract
ECMAScript spec abstract operations.
Stars: ✭ 86 (+95.45%)
Mutual labels:  spec, specification
security-policy-specification-standard
This document proposes a way of standardising the structure, language, and grammar used in security policies.
Stars: ✭ 24 (-45.45%)
Mutual labels:  specification

falcon-apispec

Build Status codecov PyPI License: MIT

apispec plugin that generates OpenAPI specification (aka Swagger) for Falcon web applications.

Apispec uses three sources of information. Basic information is directly given to APISpec(). The plugin reads information about paths from the Falcon app. Information about an object could be given by marshmallow specification

Installation

pip install falcon-apispec

Optionaly:

pip install marshmallow

Works with apispec v1.0+.

Example Application

from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
import falcon
from falcon_apispec import FalconPlugin
from marshmallow import Schema, fields


# Optional marshmallow support
class CategorySchema(Schema):
    id = fields.Int()
    name = fields.Str(required=True)

class PetSchema(Schema):
    category = fields.Nested(CategorySchema, many=True)
    name = fields.Str()


# Create Falcon web app
app = falcon.API()

class RandomPetResource:
    def on_get(self, req, resp):
        """A cute furry animal endpoint.
        ---
        description: Get a random pet
        responses:
            200:
                description: A pet to be returned
                schema: PetSchema
        """
        pet = get_random_pet()  # returns JSON
        resp.media = pet

# create instance of resource
random_pet_resource = RandomPetResource()
# pass into `add_route` for Falcon
app.add_route("/random", random_pet_resource)


# Create an APISpec
spec = APISpec(
    title='Swagger Petstore',
    version='1.0.0',
    openapi_version='2.0',
    plugins=[
        FalconPlugin(app),
        MarshmallowPlugin(),
    ],
)

# Register entities and paths
spec.components.schema('Category', schema=CategorySchema)
spec.components.schema('Pet', schema=PetSchema)
# pass created resource into `path` for APISpec
spec.path(resource=random_pet_resource)

Generated OpenAPI Spec

spec.to_dict()
# {
#   "info": {
#     "title": "Swagger Petstore",
#     "version": "1.0.0"
#   },
#   "swagger": "2.0",
#   "paths": {
#     "/random": {
#       "get": {
#         "description": "A cute furry animal endpoint.",
#         "responses": {
#           "200": {
#             "schema": {
#               "$ref": "#/definitions/Pet"
#             },
#             "description": "A pet to be returned"
#           }
#         },
#       }
#     }
#   },
#   "definitions": {
#     "Pet": {
#       "properties": {
#         "category": {
#           "type": "array",
#           "items": {
#             "$ref": "#/definitions/Category"
#           }
#         },
#         "name": {
#           "type": "string"
#         }
#       }
#     },
#     "Category": {
#       "required": [
#         "name"
#       ],
#       "properties": {
#         "name": {
#           "type": "string"
#         },
#         "id": {
#           "type": "integer",
#           "format": "int32"
#         }
#       }
#     }
#   },
# }

spec.to_yaml()
# definitions:
#   Pet:
#     enum: [name, photoUrls]
#     properties:
#       id: {format: int64, type: integer}
#       name: {example: doggie, type: string}
# info: {description: 'This is a sample Petstore server.  You can find out more ', title: Swagger Petstore, version: 1.0.0}
# parameters: {}
# paths: {}
# security:
# - apiKey: []
# swagger: '2.0'
# tags: []

Contributing

Setting Up for Local Development

  1. Fork falcon-apispec on Github
  2. Install development requirements. Virtual environments are highly recommended
pip install -r requirements.txt

Running Tests

pytest
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].