{
"openapi": "3.0.3",
"info": {
"title": "蓝色天空网 · 学习接口",
"version": "1.0.0",
"description": "mbsky.com 本地独立模拟服务;此地址不指向生产后台。",
"contact": {
"name": "蓝色天空网",
"url": "https://mbsky.com"
}
},
"servers": [
{
"url": "/api/v1",
"description": "独立本机教学服务"
}
],
"tags": [
{
"name": "users",
"description": "users模拟教学操作"
},
{
"name": "auth",
"description": "auth模拟教学操作"
},
{
"name": "books",
"description": "books模拟教学操作"
},
{
"name": "products",
"description": "products模拟教学操作"
},
{
"name": "orders",
"description": "orders模拟教学操作"
}
],
"paths": {
"/users": {
"get": {
"operationId": "listUsers",
"summary": "分页和状态过滤用户",
"tags": [
"users"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserList"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"$ref": "#/components/parameters/Page"
},
{
"$ref": "#/components/parameters/Limit"
},
{
"$ref": "#/components/parameters/Offset"
},
{
"name": "status",
"in": "query",
"schema": {
"type": "string",
"enum": [
"active",
"inactive",
"banned"
]
}
}
]
},
"post": {
"operationId": "createUser",
"summary": "创建用户",
"tags": [
"users"
],
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "用户名或邮箱冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NewUser"
}
}
}
}
}
},
"/users/{userId}": {
"get": {
"operationId": "getUser",
"summary": "获取用户详情",
"tags": [
"users"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserDetail"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
},
"put": {
"operationId": "replaceUser",
"summary": "整体替换允许的用户资料",
"tags": [
"users"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserDetail"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ReplaceUser"
}
}
}
}
},
"delete": {
"operationId": "deleteUser",
"summary": "删除用户",
"tags": [
"users"
],
"responses": {
"204": {
"description": "成功"
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
},
"patch": {
"operationId": "patchUser",
"summary": "部分更新允许的用户字段",
"tags": [
"users"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserDetail"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUser"
}
}
}
}
}
},
"/auth/login": {
"post": {
"operationId": "login",
"summary": "教学用户登录",
"tags": [
"auth"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Token"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "凭证错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Login"
}
}
}
}
}
},
"/auth/register": {
"post": {
"operationId": "register",
"summary": "注册独立模拟用户",
"tags": [
"auth"
],
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegisterResult"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NewUser"
}
}
}
}
}
},
"/books": {
"get": {
"operationId": "listBooks",
"summary": "分页过滤books",
"tags": [
"books"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BookList"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"parameters": [
{
"$ref": "#/components/parameters/Page"
},
{
"$ref": "#/components/parameters/Limit"
},
{
"name": "category",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "author",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "title",
"in": "query",
"schema": {
"type": "string"
}
}
]
},
"post": {
"operationId": "createBook",
"summary": "创建books",
"tags": [
"books"
],
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BookInput"
}
}
}
}
}
},
"/books/{bookId}": {
"get": {
"operationId": "getBook",
"summary": "books详情/替换/删除",
"tags": [
"books"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"parameters": [
{
"name": "bookId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
},
"put": {
"operationId": "replaceBook",
"summary": "books详情/替换/删除",
"tags": [
"books"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "bookId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BookInput"
}
}
}
}
},
"delete": {
"operationId": "deleteBook",
"summary": "books详情/替换/删除",
"tags": [
"books"
],
"responses": {
"204": {
"description": "成功"
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "bookId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
},
"patch": {
"operationId": "patchBook",
"summary": "部分更新允许的图书字段",
"tags": [
"books"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "bookId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BookPatch"
}
}
}
}
}
},
"/products": {
"get": {
"operationId": "listProducts",
"summary": "分页过滤products",
"tags": [
"products"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProductList"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"parameters": [
{
"$ref": "#/components/parameters/Page"
},
{
"$ref": "#/components/parameters/Limit"
},
{
"name": "category",
"in": "query",
"schema": {
"type": "string"
}
}
]
},
"post": {
"operationId": "createProduct",
"summary": "创建products",
"tags": [
"products"
],
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "资源冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProductInput"
}
}
}
}
}
},
"/products/{productId}": {
"get": {
"operationId": "getProduct",
"summary": "products详情/替换/删除",
"tags": [
"products"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"security": [],
"parameters": [
{
"name": "productId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
},
"put": {
"operationId": "replaceProduct",
"summary": "products详情/替换/删除",
"tags": [
"products"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Product"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "productId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProductInput"
}
}
}
}
},
"delete": {
"operationId": "deleteProduct",
"summary": "products详情/替换/删除",
"tags": [
"products"
],
"responses": {
"204": {
"description": "成功"
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"name": "productId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
}
}
]
}
},
"/orders": {
"get": {
"operationId": "listOrders",
"summary": "查询自己的订单",
"tags": [
"orders"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderList"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"parameters": [
{
"$ref": "#/components/parameters/Page"
},
{
"$ref": "#/components/parameters/Limit"
},
{
"name": "status",
"in": "query",
"schema": {
"type": "string",
"enum": [
"pending",
"processing",
"shipped",
"delivered",
"cancelled"
]
}
}
]
},
"post": {
"operationId": "createOrder",
"summary": "按真实产品价格计算模拟订单",
"tags": [
"orders"
],
"responses": {
"201": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order"
}
}
}
},
"400": {
"description": "输入错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "权限不足",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "本地教学限流",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "请求体过大",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "媒体类型错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrderInput"
}
}
}
}
}
}
},
"components": {
"schemas": {
"UserBase": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50
},
"email": {
"type": "string",
"format": "email"
},
"status": {
"type": "string",
"enum": [
"active",
"inactive",
"banned"
]
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"required": [
"id",
"username",
"email",
"status",
"createdAt"
]
},
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50
},
"email": {
"type": "string",
"format": "email"
},
"status": {
"type": "string",
"enum": [
"active",
"inactive",
"banned"
]
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"allOf": [
{
"$ref": "#/components/schemas/UserBase"
}
],
"additionalProperties": false
},
"UserDetail": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50
},
"email": {
"type": "string",
"format": "email"
},
"status": {
"type": "string",
"enum": [
"active",
"inactive",
"banned"
]
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
},
"firstName": {
"type": "string",
"maxLength": 80
},
"lastName": {
"type": "string",
"maxLength": 80
},
"phone": {
"type": "string",
"maxLength": 30
},
"lastLogin": {
"type": "string",
"format": "date-time"
}
},
"allOf": [
{
"$ref": "#/components/schemas/UserBase"
}
],
"additionalProperties": false
},
"NewUser": {
"type": "object",
"properties": {
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50
},
"email": {
"type": "string",
"format": "email"
},
"password": {
"type": "string",
"minLength": 8,
"maxLength": 100,
"writeOnly": true
}
},
"required": [
"username",
"email",
"password"
],
"additionalProperties": false
},
"UpdateUser": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"firstName": {
"type": "string",
"maxLength": 80
},
"lastName": {
"type": "string",
"maxLength": 80
},
"phone": {
"type": "string",
"maxLength": 30
},
"password": {
"type": "string",
"minLength": 8,
"maxLength": 100,
"writeOnly": true
}
},
"minProperties": 1,
"additionalProperties": false
},
"Login": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string",
"writeOnly": true
}
},
"required": [
"username",
"password"
],
"additionalProperties": false
},
"Error": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
],
"additionalProperties": false
},
"Token": {
"type": "object",
"properties": {
"accessToken": {
"type": "string"
},
"tokenType": {
"type": "string",
"enum": [
"Bearer"
]
},
"expiresIn": {
"type": "integer",
"minimum": 1
}
},
"required": [
"accessToken",
"tokenType",
"expiresIn"
],
"additionalProperties": false
},
"Address": {
"type": "object",
"properties": {
"street": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"state": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"zipCode": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"country": {
"type": "string",
"minLength": 1,
"maxLength": 120
}
},
"required": [
"street",
"city",
"state",
"zipCode",
"country"
],
"additionalProperties": false
},
"ProductInput": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"description": {
"type": "string",
"maxLength": 1000
},
"priceCents": {
"type": "integer",
"minimum": 0,
"maximum": 100000000
},
"category": {
"type": "string",
"enum": [
"electronics",
"books",
"clothing",
"food"
]
},
"inStock": {
"type": "boolean",
"default": true
}
},
"required": [
"name",
"priceCents",
"category"
],
"additionalProperties": false
},
"OrderItemInput": {
"type": "object",
"properties": {
"productId": {
"type": "integer",
"minimum": 1
},
"quantity": {
"type": "integer",
"minimum": 1,
"maximum": 100
}
},
"required": [
"productId",
"quantity"
],
"additionalProperties": false
},
"OrderInput": {
"type": "object",
"properties": {
"items": {
"type": "array",
"minItems": 1,
"maxItems": 100,
"items": {
"$ref": "#/components/schemas/OrderItemInput"
}
},
"shippingAddress": {
"$ref": "#/components/schemas/Address"
}
},
"required": [
"items",
"shippingAddress"
],
"additionalProperties": false
},
"BookInput": {
"type": "object",
"properties": {
"title": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"author": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"publishDate": {
"type": "string",
"format": "date"
},
"isbn": {
"type": "string",
"format": "isbn",
"description": "Custom validation: real ISBN10/13 checksum; sample code does not claim actual publisher assignment."
},
"category": {
"type": "string",
"minLength": 1,
"maxLength": 40
}
},
"required": [
"title",
"author",
"isbn"
],
"additionalProperties": false
},
"ReplaceUser": {
"type": "object",
"properties": {
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50
},
"email": {
"type": "string",
"format": "email"
},
"status": {
"type": "string",
"enum": [
"active",
"inactive",
"banned"
]
},
"firstName": {
"type": "string",
"maxLength": 80
},
"lastName": {
"type": "string",
"maxLength": 80
},
"phone": {
"type": "string",
"maxLength": 30
}
},
"required": [
"username",
"email",
"status"
],
"additionalProperties": false
},
"Product": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"description": {
"type": "string",
"maxLength": 1000
},
"priceCents": {
"type": "integer",
"minimum": 0,
"maximum": 100000000
},
"category": {
"type": "string",
"enum": [
"electronics",
"books",
"clothing",
"food"
]
},
"inStock": {
"type": "boolean",
"default": true
},
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"required": [
"name",
"priceCents",
"category",
"id",
"createdAt"
],
"additionalProperties": false
},
"Book": {
"type": "object",
"properties": {
"title": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"author": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"publishDate": {
"type": "string",
"format": "date"
},
"isbn": {
"type": "string",
"format": "isbn",
"description": "Custom validation: real ISBN10/13 checksum; sample code does not claim actual publisher assignment."
},
"category": {
"type": "string",
"minLength": 1,
"maxLength": 40
},
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
}
},
"required": [
"title",
"author",
"isbn",
"id"
],
"additionalProperties": false
},
"BookPatch": {
"type": "object",
"properties": {
"title": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"author": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"publishDate": {
"type": "string",
"format": "date"
},
"isbn": {
"type": "string",
"format": "isbn",
"description": "Custom validation: real ISBN10/13 checksum; sample code does not claim actual publisher assignment."
},
"category": {
"type": "string",
"minLength": 1,
"maxLength": 40
}
},
"additionalProperties": false,
"minProperties": 1
},
"OrderItem": {
"type": "object",
"properties": {
"productId": {
"type": "integer",
"minimum": 1
},
"quantity": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"unitPriceCents": {
"type": "integer",
"minimum": 0,
"readOnly": true
}
},
"required": [
"productId",
"quantity",
"unitPriceCents"
],
"additionalProperties": false
},
"Order": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"userId": {
"type": "integer",
"minimum": 1,
"readOnly": true
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderItem"
}
},
"shippingAddress": {
"$ref": "#/components/schemas/Address"
},
"totalCents": {
"type": "integer",
"minimum": 0,
"readOnly": true
},
"status": {
"type": "string",
"enum": [
"pending",
"processing",
"shipped",
"delivered",
"cancelled"
]
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"required": [
"id",
"userId",
"items",
"shippingAddress",
"totalCents",
"status",
"createdAt"
],
"additionalProperties": false
},
"UserList": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0
},
"page": {
"type": "integer",
"minimum": 1
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
},
"required": [
"total",
"page",
"limit",
"data"
],
"additionalProperties": false
},
"BookList": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0
},
"page": {
"type": "integer",
"minimum": 1
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Book"
}
}
},
"required": [
"total",
"page",
"limit",
"data"
],
"additionalProperties": false
},
"ProductList": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0
},
"page": {
"type": "integer",
"minimum": 1
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
},
"required": [
"total",
"page",
"limit",
"data"
],
"additionalProperties": false
},
"OrderList": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0
},
"page": {
"type": "integer",
"minimum": 1
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
}
},
"required": [
"total",
"page",
"limit",
"data"
],
"additionalProperties": false
},
"RegisterResult": {
"type": "object",
"properties": {
"user": {
"$ref": "#/components/schemas/User"
},
"token": {
"$ref": "#/components/schemas/Token"
}
},
"required": [
"user",
"token"
],
"additionalProperties": false
}
},
"parameters": {
"Page": {
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"default": 1
}
},
"Limit": {
"name": "limit",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
}
},
"Offset": {
"name": "offset",
"in": "query",
"schema": {
"type": "integer",
"minimum": 0,
"default": 0
}
}
},
"responses": {
"Unauthorized": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"NotFound": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
},
"apiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
},
"OAuthExample": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.invalid/authorize",
"tokenUrl": "https://example.invalid/token",
"scopes": {
"read": "读取",
"write": "写入"
}
}
}
}
}
},
"security": [
{
"bearerAuth": []
}
]
}
本例需在 Windows / Node24.22.1 / SwaggerUI5.34.1 / Edge156 / Python3.12 / 固定生成器历史兼容版本 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows / Node24.22.1 / SwaggerUI5.34.1 / Edge156 / Python3.12 / 固定生成器历史兼容版本
入口文件:projects/swagger-lab/specs/openapi.json
预期结果与验证条件观察提示
- 按本章对应实际结果核对,未运行的其它环境仍待处理
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联13章) · 含当前章节或实例 · mbskycom202611a548.zip