GithubHelp home page GithubHelp logo

openapi3's Introduction

openapi3

python

A Python OpenAPI 3 Specification client and validator for Python 3.

image

NOTE

This is a work in progress, and may change significantly in the future. Many features are presently absent, and many common cases may not be implemented.

Validation Mode

This module can be run against a spec file to validate it like so:

python3 -m openapi /path/to/spec

Usage as a Client

This library also functions as an interactive client for arbitrary OpenAPI 3 specs. For example, using Linode's OpenAPI 3 Specification for reference:

from openapi3 import OpenAPI

# load the spec file and read the yaml
with open('openapi.yaml') as f:
    spec = yaml.safe_load(f.read())

# parse the spec into python - this will raise if the spec is invalid
api = OpenAPI(spec)

# call operations and receive result models
regions = api.call_getRegions()

# authenticate using a securityScheme defined in the spec's components.securtiySchemes
api.authenticate('personalAccessToken', my_token)

# call an operation that requires authentication
linodes  = api.call_getLinodeInstances()

# call an opertaion with parameters
linode = api.call_getLinodeInstance(parameters={"linodeId": 123})

# the models returns are all of the same (generated) type
print(type(linode))                      # openapi.schemas.Linode
type(linode) == type(linodes.data[0])    # True

# call an operation with a request body
new_linode = api.call_createLinodeInstance(data={"region":"us-east","type":"g6-standard-2"})

# the returned models is still of the correct type
type(new_linode) == type(linode)     # True

Roadmap

The following still needs to be done:

  • Request body models, creation, and validation.
  • Parameters interface with validation and explicit typing.
  • Support for more authentication types.
  • Support for non-json request/response content.
  • Full support for all objects defined in the specification.

openapi3's People

Contributors

dorthu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.