This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# openapi

Python OpenAPI 2.0 (Swagger) object model

There are any number of good libraries for using OpenAPI/Swagger in specific ways or
with specific frameworks. This isn't one of them.

Rather, this library provides a simple object model for producing and consuming
Swagger specifications.


## Models

Model types extend Python `dict`, `list`, or `string` to support reading from JSON,
writing to JSON, and validation against (the relevant portion of) the Swagger schema.

As a result, models are interchangeable with their primitive counterparts and can
be used as much (or as little) as desired to enhange readability or perform validation.

Models convert contained primitive types to models when accessed using keys or attributes
(for `dict`-based types) and when using indexing (for `list`-based access). Access to
model internals via iteration bypasses conversion.


## Usage

1. Either load a schema from json:

from openapi import load

with open("/path/to/swagger.json") as fileobj:
swagger = load(fileobj)

Or construct one explicitly from the model:

from openapi.model import Swagger, Info, Operation, PathItem, Paths, Response, Responses

swagger = Swagger(
swagger="2.0",
info=Info(
title="Example",
version="1.0.0",
),
basePath="/api",
paths=Paths({
"/hello": PathItem(
get=Operation(
responses=Responses({
"200": Response(
description="Returns hello",
)
})
),
),
}),
)

2. Access model internals using attributes:

print swagger.info
print swagger.basePath

Pythonic names are automically converted when using attribute access:

print swagger.base_path

Naturally, attribute names that are illegel or that shadow existing attributes
must be accessed using key syntax:

print swagger.paths["/hello"]["get"].responses["200"].description

3. Validate the model:

swagger.validate()

Internal models can be validated independently:

swagger.info.validate()

4. Dump the result to JSON:

print swagger.dumps()
Release History

Release History

0.5.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
openapi-0.5.0.tar.gz (12.1 kB) Copy SHA256 Checksum SHA256 Source Apr 26, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting