导出数据(OpenAPI/Swagger 格式)
/api/v1/projects/{projectId}/export-openapi
请求参数
Path 参数
projectId
string
必需
项目 ID,打开 Apifox 进入项目里的“项目设置”查看
示例值:
{{projectId}}
Body 参数application/json
version
string
必需
OpenAPI Spec 版本
枚举值:
3.03.12.0
excludeExtension
boolean
必需
不包含 Apifox 扩展的 OpenAPI 字段(x-apifox-***)
excludeTagsWithFolder
boolean
必需
不将 API 文档的目录,作为 Tags 字段导出
type
integer
导出范围
枚举值:
123
apiDetailId
array[integer]
指定接口ID
checkedFolder
array[integer]
指定接口目录ID
excludeTags
array[string]
排除标签
includeTags
array[string]
指定标签
selectedEnvironments
array [object {3}]
运行环境
id
integer
环境ID
name
string
环境名称
baseUrl
string
环境前置URL
openApiFormat
string
文件格式
枚举值:
jsonyaml
示例
{
"version": "3.0",
"excludeExtension": true,
"excludeTagsWithFolder": false,
"type": 1,
"apiDetailId": [],
"checkedFolder": [],
"excludeTags": [],
"includeTags": [],
"selectedEnvironments": [],
"openApiFormat": "json"
}
示例代码
返回响应
成功(200)
成功(200)
HTTP 状态码: 200
内容格式: JSON
数据结构
openapi
string
必需
info
object {0}
必需
tags
array [object {0}]
必需
paths
object {0}
必需
components
object {0}
必需
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": []
}
修改时间 1 个月前