导出 OpenAPI/Swagger 格式数据
POST
/v1/projects/{projectId}/export-openapi请求参数
Path 参数
projectId
string
必需
示例值:
{{projectId}}
Query 参数
locale
string
可选
示例值:
zh-CN
Body 参数application/json
scope
必需
One of
type
enum<string>
必需
枚举值:
ALL
excludedByTags
array[string]
可选
排除掉包含指定标签的内容
options
object
可选
includeApifoxExtensionProperties
boolean
可选
指定是否包含 Apifox 的 OpenAPI 规范扩展字段x-apifox
。
默认值:
false
addFoldersToTags
boolean
可选
指定是否在标签字段中包含接口的目录名称。
默认值:
false
oasVersion
enum<string>
可选
指定用于导出的 OpenAPI 规范的版本。可以有值如 "2.0","3.0" 或 "3.1"。
枚举值:
3.03.12.0
默认值:
3.1
exportFormat
enum<string>
可选
指定导出的 OpenAPI 文件的格式。可以有值如 "JSON" 或 "YAML"。
枚举值:
JSONYAML
默认值:
JSON
environmentIds
array[number]
可选
指定要导出的环境的 ID。
示例
{
"scope": {
"type": "ALL",
"excludedByTags": [
"pet"
]
},
"options": {
"includeApifoxExtensionProperties": false,
"addFoldersToTags": false
},
"oasVersion": "3.1",
"exportFormat": "JSON"
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
openapi
string
必需
info
object
必需
tags
array [object]
必需
paths
object
必需
components
object
必需
servers
array[string]
必需
示例
{
"openapi": "3.0.1",
"info": {
"title": "示例",
"description": "",
"version": "1.0.0"
},
"tags": [
{
"name": "示例项目"
},
{
"name": "宠物"
}
],
"paths": {
"/pet/{petId}": {
"get": {
"summary": "查询宠物详情",
"deprecated": false,
"description": "",
"tags": [
"示例项目",
"宠物"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "宠物 ID",
"required": true,
"example": "1",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"minimum": 0,
"maximum": 0,
"description": "状态码"
},
"data": {
"$ref": "#/components/schemas/Pet",
"description": "宠物信息"
}
},
"required": [
"code",
"data"
]
},
"examples": {
"1": {
"summary": "成功示例",
"value": {
"code": 0,
"data": {
"name": "Hello Kity",
"photoUrls": [
"http://dummyimage.com/400x400"
],
"id": 3,
"category": {
"id": 71,
"name": "Cat"
},
"tags": [
{
"id": 22,
"name": "Cat"
}
],
"status": "sold"
}
}
}
}
}
}
},
"400": {
"description": "参数不正确",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
]
}
}
}
},
"404": {
"description": "记录不存在",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
]
}
}
}
}
},
"security": []
},
"delete": {
"summary": "删除宠物信息",
"deprecated": false,
"description": "",
"tags": [
"示例项目",
"宠物"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "api_key",
"in": "header",
"description": "",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"minimum": 0,
"maximum": 0
}
},
"required": [
"code"
]
},
"examples": {
"1": {
"summary": "成功示例",
"value": {
"code": 0
}
}
}
}
}
}
},
"security": []
}
},
"/pet": {
"post": {
"summary": "新建宠物信息",
"deprecated": false,
"description": "",
"tags": [
"示例项目",
"宠物"
],
"parameters": [],
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object",
"properties": {
"name": {
"description": "宠物名",
"example": "Hello Kitty",
"type": "string"
},
"status": {
"description": "宠物销售状态",
"example": "sold",
"type": "string"
}
},
"required": [
"name",
"status"
]
}
}
}
},
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"minimum": 0,
"maximum": 0
},
"data": {
"$ref": "#/components/schemas/Pet",
"description": "宠物信息"
}
},
"required": [
"code",
"data"
]
},
"examples": {
"1": {
"summary": "成功示例",
"value": {
"code": 0,
"data": {
"name": "Hello Kity",
"photoUrls": [
"http://dummyimage.com/400x400"
],
"id": 3,
"category": {
"id": 71,
"name": "Cat"
},
"tags": [
{
"id": 22,
"name": "Cat"
}
],
"status": "sold"
}
}
}
}
}
}
}
},
"security": []
},
"put": {
"summary": "修改宠物信息",
"deprecated": false,
"description": "",
"tags": [
"示例项目",
"宠物"
],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
}
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"data": {
"$ref": "#/components/schemas/Pet",
"description": "宠物信息"
}
},
"required": [
"code",
"data"
]
},
"examples": {
"1": {
"summary": "成功示例",
"value": {
"code": 0,
"data": {
"name": "Hello Kity",
"photoUrls": [
"http://dummyimage.com/400x400"
],
"id": 3,
"category": {
"id": 71,
"name": "Cat"
},
"tags": [
{
"id": 22,
"name": "Cat"
}
],
"status": "sold"
}
}
}
}
}
}
},
"404": {
"description": "记录不存在",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
}
},
"405": {
"description": "验证错误",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
}
}
},
"security": []
}
},
"/pet/findByStatus": {
"get": {
"summary": "根据状态查找宠物列表",
"deprecated": false,
"description": "",
"tags": [
"示例项目",
"宠物"
],
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet",
"description": "宠物信息"
}
},
"examples": {
"1": {
"summary": "成功示例",
"value": {
"code": 0,
"data": [
{
"name": "Hello Kity",
"photoUrls": [
"http://dummyimage.com/400x400"
],
"id": 3,
"category": {
"id": 71,
"name": "Cat"
},
"tags": [
{
"id": 22,
"name": "Cat"
}
],
"status": "sold"
},
{
"name": "White Dog",
"photoUrls": [
"http://dummyimage.com/400x400"
],
"id": 3,
"category": {
"id": 71,
"name": "Dog"
},
"tags": [
{
"id": 22,
"name": "Dog"
}
],
"status": "sold"
}
]
}
}
}
}
}
},
"400": {
"description": "错误的 status 值",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer"
}
},
"required": [
"code"
]
}
}
}
}
},
"security": []
}
}
},
"components": {
"schemas": {
"Tag": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"minimum": 1,
"description": "标签ID编号"
},
"name": {
"type": "string",
"description": "标签名称"
}
},
"xml": {
"name": "Tag"
}
},
"Category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"minimum": 1,
"description": "分组ID编号"
},
"name": {
"type": "string",
"description": "分组名称"
}
},
"xml": {
"name": "Category"
}
},
"Pet": {
"required": [
"name",
"photoUrls",
"id",
"category",
"tags",
"status"
],
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"minimum": 1,
"description": "宠物ID编号"
},
"category": {
"$ref": "#/components/schemas/Category",
"description": "分组"
},
"name": {
"type": "string",
"description": "名称",
"examples": [
"doggie"
]
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
},
"description": "照片URL"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tag"
},
"description": "标签"
},
"status": {
"type": "string",
"description": "宠物销售状态",
"enum": [
"available",
"pending",
"sold"
]
}
}
}
},
"securitySchemes": {}
},
"servers": []
}
最后修改时间: 5 个月前