OpenAPI 电商 API
高级 OpenAPI
用于包含产品和订单的最小电商 API 的 OpenAPI 3.1 文档。 一个真实、可直接使用的示例,你可以复制、调整,或用来测试自己的代码。
{
"openapi": "3.1.0",
"info": {
"title": "Ecommerce API",
"version": "2.0.0"
},
"paths": {
"/products": {
"get": {
"summary": "List products",
"responses": {
"200": { "description": "Product list" }
}
}
},
"/orders": {
"post": {
"summary": "Place an order",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productId": { "type": "string" },
"quantity": { "type": "integer" }
}
}
}
}
}
}
}
},
"responses": {
"201": { "description": "Order placed" }
}
}
}
}
} 更多示例
- openapi
- ecommerce
- REST