跳转到主要内容

用于访问Swagger启用API的库

项目描述

https://img.shields.io/travis/Yelp/bravado.svg https://img.shields.io/coveralls/Yelp/bravado.svg PyPi version Supported Python versions

Bravado

关于

Bravado 是 Yelp 维护的 digium/swagger-py 的分支,用于与 OpenAPI 规范版本 2.0(之前称为 Swagger)一起使用。

OpenAPI 规范项目

OpenAPI 规范的目的是定义一个标准、语言无关的接口,用于 REST API,该接口允许人类和计算机在无需访问源代码、文档或通过网络流量检查的情况下发现和理解服务的功能。

可以从 OpenAPI 规范自动生成客户端库,但是 Bravado 旨在完全替代代码生成(swagger-codegen)。

示例用法

from bravado.client import SwaggerClient
client = SwaggerClient.from_url('http://petstore.swagger.io/v2/swagger.json')
pet = client.pet.getPetById(petId=1).response().result

基本身份验证示例

from bravado.requests_client import RequestsClient
from bravado.client import SwaggerClient

http_client = RequestsClient()
http_client.set_basic_auth(
    'api.yourhost.com',
    'username', 'password'
)
client = SwaggerClient.from_url(
    'http://petstore.swagger.io/v2/swagger.json',
    http_client=http_client,
)
pet = client.pet.getPetById(petId=1).response().result

头部身份验证示例

from bravado.requests_client import RequestsClient
from bravado.client import SwaggerClient

http_client = RequestsClient()
http_client.set_api_key(
    'api.yourhost.com', 'token',
    param_name='api_key', param_in='header'
)
client = SwaggerClient.from_url(
    'http://petstore.swagger.io/v2/swagger.json',
    http_client=http_client,
)
pet = client.pet.getPetById(petId=1).response().result

Fido客户端(异步 Http客户端)示例

# Install bravado with fido extra (``pip install bravado[fido]``)
from bravado.fido_client import FidoClient
from bravado.client import SwaggerClient

http_client = FidoClient()
client = SwaggerClient.from_url(
    'http://petstore.swagger.io/v2/swagger.json',
    http_client=http_client,
)
pet = client.pet.getPetById(petId=1).response().result

文档

更多文档可在 http://bravado.readthedocs.org 查找

安装

# To install bravado with Synchronous Http Client only.
$ pip install bravado

# To install bravado with Synchronous and Asynchronous Http Client (RequestsClient and FidoClient).
$ pip install bravado[fido]

开发

代码使用 Sphinx 进行文档说明。

建议使用 virtualenv 来保持依赖项和库的隔离。

设置

# Run tests
tox

# Install git pre-commit hooks
tox -e pre-commit install

贡献

  1. 分叉它( http://github.com/Yelp/bravado/fork

  2. 创建您的功能分支(git checkout -b my-new-feature

  3. 添加您的修改

  4. 提交您的更改(git commit -m "添加一些功能"

  5. 将更改推送到分支(git push origin my-new-feature

  6. 创建新的拉取请求

发布新版本(仅限于工具包)

查看https://yelpwiki.yelpcorp.com/pages/viewpage.action?pageId=19022447

许可协议

版权(c)2013,Digium,Inc。保留所有权利。版权(c)2014-2021,Yelp,Inc。保留所有权利。

Bravado以BSD 3-Clause License授权。

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

bravado-11.0.3.tar.gz (34.6 kB 查看散列)

上传时间

构建分发

bravado-11.0.3-py2.py3-none-any.whl (38.8 kB 查看散列)

上传时间 Python 2 Python 3

支持者