An open API service indexing awesome lists of open source software.

https://github.com/outscale/osc-openapi-framework

Build and parse OpenAPI data using its own structured python object.
https://github.com/outscale/osc-openapi-framework

maturity-graduated

Last synced: 8 months ago
JSON representation

Build and parse OpenAPI data using its own structured python object.

Awesome Lists containing this project

README

          

# OSC OpenAPI Framework
[![Project Graduated](https://docs.outscale.com/fr/userguide/_images/Project-Graduated-green.svg)](https://docs.outscale.com/en/userguide/Open-Source-Projects.html)

Build and parse OpenAPI data using its own structured python object.

## Features
- Build OpenAPI data from structured object
- Parse OpenAPI data to structured object

## Installation

You can install the pre-built python package through this command:

```bash
$ pip install osc-openapi-framework
```

## Building

To build the package yourself:

```bash
$ make package
```

You can then install it with:
```bash
$ pip install dist/osc_openapi_framework-*.whl
```

## Usage
### Parsing OpenAPI Data
```python
from osc_openapi_framework.openapi.parser import parse as openapi_parse

openapi_data = '''
openapi: 3.0.0
info:
title: Sample API
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version: 0.1.9
security:
- ApiKeyAuth: []
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
description: Optional server description, e.g. Internal staging server for testing
paths:
/users:
get:
summary: Returns a list of users.
description: Optional extended description in CommonMark or HTML.
responses:
'200': # status code
description: A JSON array of user names
content:
application/json:
schema:
type: array
items:
type: string
'''
with open('/tmp/openapi_test', 'w') as fd:
fd.write(openapi_data)
oapi = openapi_parse('/tmp/openapi_test')
```

## License

> Copyright Outscale SAS
>
> BSD-3-Clause

This project is compliant with [REUSE](https://reuse.software/).