Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Small helper lib to work with openapi specs

License

Notifications You must be signed in to change notification settings

ausecocloud/pyramid_openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

No longer maintained use pyramid_openapi3 instead

pyramid_openapi

Provides small helpers to handle OpenAPI specs and request validation/parsing.

YAML render

This package adds an additional renderer to output contents as yaml.

OpenAPI specs

This package adds some small helper views to download an OpenAPI specification as yaml or json. Additionally, there are two templates which render the OpenAPI specs with Swagger-UI and ReDOC.

It also extends the request object with an attribute `oas` to parse and verify requests according to the given OpenAPI spec.

Pyramid route patterns are used to find the correct API path in the OpenAPI spec.

Configuration

All configuration options are prefixed with `openapi.` .

# this can either be a pyramid asset specification or an absolute path.
openapi.spec = mypackage:path/to/openapi.yaml

Usage

Include the package in your configuration

config.include('pyramid_openapi')

Use the provided utility in your view code

@view_config(....)
def myview(request):
    # validate and get url parameters
    params = request.oas.validate_params().parameters
    # pull out params from location (query, header, path)
    params = params.get('query')
    # validate and get requestBody
    body = request.oas.validate_params().body

    ...

    return {}

About

Small helper lib to work with openapi specs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages