是的,SwaggerHub有一个API:
https://api.swaggerhub.com
Integrating with the SwaggerHub API
以及一些官方API客户端。
cURL命令创建或更新API(注意
--data-binary
而不是
-d/--data
curl -X POST "https://api.swaggerhub.com/apis/OWNER/API_NAME" \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/yaml" \
--data-binary @myapi.yaml
引用的原始HTTP请求:
POST https://api.swaggerhub.com/apis/OWNER/API_NAME
Authorization: YOUR_API_KEY
Content-Type: application/yaml
# Request body is your complete YAML/JSON file
swagger: '2.0'
info:
title: My API
version: 1.0.0
paths:
...
使用正确的
Content-Type
标题值:
application/yaml
对于YAML或
application/json
对于JSON。
A
command-line wrapper
围绕SwaggerHub API,作为npm模块提供。
npm install -g swaggerhub-cli
指定API密钥(从
https://app.swaggerhub.com/settings/apiKey
):
swaggerhub configure
? SwaggerHub URL: https://api.swaggerhub.com
? API Key: <paste your key>
创建新API:
swaggerhub api:create OWNER/API_NAME --file myapi.yaml
更新现有API:
swaggerhub api:update OWNER/API_NAME/VERSION --file myapi.yaml --visibility private
Maven插件
https://github.com/swagger-api/swaggerhub-maven-plugin/
渐变插件
https://github.com/swagger-api/swaggerhub-gradle-plugin/