UserService · UserService_CreateUser
基于协议生成的参考。授权与实例策略仍然生效。结构描述继承自 MIT 许可的应用接口定义;本站不会向真实服务执行示例。
访问权限
首个账号成为实例管理员。之后的匿名注册遵循实例注册与密码策略及部署挑战。管理员可以创建用户;普通注册不能请求管理员权限。
创建检查不是幂等保证
会校验 username 和非空 password;提供 userId 时必须与 username 一致。邮箱会去除首尾空白并转为小写,不能被其他账号重复使用。validateOnly 不创建账号,但不预留用户名,也不保证之后一定能创建。此实现没有使用声明的 requestId 去重。POST 结果不明确时,重试前先检查账号是否已存在。
请求
CreateUser creates a new user.
POST
/api/v1/users参数
| 名称 / 位置 | 类型 / 是否必需 | 描述 |
|---|---|---|
userIdquery | string OpenAPI 未标记为必需 | Optional. The resource ID to use for this user. If set, it must equal user.username and follow the username format. Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$ |
validateOnlyquery | boolean OpenAPI 未标记为必需 | Optional. If set, validate the request but don't actually create the user. |
requestIdquery | string OpenAPI 未标记为必需 | Optional. An idempotency token that can be used to ensure that multiple requests to create a user have the same result. |
请求体
必需
application/json · User
响应
200 · OK
application/json · User
default · Default error response
application/json · Status
完整操作定义
下方保留全部已声明约束、媒体类型和响应细节。结构引用链接到完整定义。
展开 JSON 定义
{
"tags": [
"UserService"
],
"description": "CreateUser creates a new user.",
"operationId": "UserService_CreateUser",
"parameters": [
{
"name": "userId",
"in": "query",
"description": "Optional. The resource ID to use for this user. If set, it must equal\n user.username and follow the username format.\n Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$",
"schema": {
"type": "string"
}
},
{
"name": "validateOnly",
"in": "query",
"description": "Optional. If set, validate the request but don't actually create the user.",
"schema": {
"type": "boolean"
}
},
{
"name": "requestId",
"in": "query",
"description": "Optional. An idempotency token that can be used to ensure that multiple\n requests to create a user have the same result.",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"default": {
"description": "Default error response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Status"
}
}
}
}
}
}