{ "schemes": [ "http" ], "swagger": "2.0", "info": { "description": "这是一个用户和登录相关的接口文档", "title": "用户和登录相关接口", "contact": { "name": "oneCat-user" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "basePath": "/", "paths": { "/api/v1/login": { "post": { "description": "如果是微信登录,需要传递 WXcode和手机号,然后调用微信接口获取 openid 和 unionid。", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "用户模块" ], "summary": "登录接口", "parameters": [ { "description": "请求参数", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/user.LoginRequest" } } ], "responses": { "200": { "description": "成功响应", "schema": { "$ref": "#/definitions/user.LoginResponse" } } } } }, "/api/v1/user": { "get": { "security": [ { "ApiKeyAuth": [] } ], "description": "通过手机号获取用户信息,只返回用户的昵称、电话、性别、ID、创建时间和头像", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "用户模块" ], "summary": "获取用户信息接口", "parameters": [ { "type": "string", "description": "用户手机号", "name": "phone", "in": "query", "required": true } ], "responses": { "200": { "description": "成功响应", "schema": { "$ref": "#/definitions/user.Response-common_User" } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/user.Response-string" } }, "404": { "description": "用户不存在", "schema": { "$ref": "#/definitions/user.Response-string" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/user.Response-string" } } } } } }, "definitions": { "common.User": { "type": "object", "properties": { "avatar": { "type": "string" }, "created_at": { "type": "string" }, "gender": { "type": "integer" }, "id": { "type": "integer" }, "nick_name": { "type": "string" }, "password": { "type": "string" }, "phone": { "type": "string" }, "wx_session": { "type": "string" }, "wx_union_id": { "type": "string" } } }, "user.LoginRequest": { "type": "object", "properties": { "captcha": { "type": "string" }, "password": { "type": "string" }, "phone": { "type": "string" }, "wx_code": { "type": "string" } } }, "user.LoginResponse": { "type": "object", "properties": { "code": { "type": "integer" }, "expire": { "type": "string" }, "message": { "type": "string" }, "token": { "type": "string" } } }, "user.Response-common_User": { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "$ref": "#/definitions/common.User" }, "message": { "type": "string" } } }, "user.Response-string": { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } } }