examples

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package examples @info.title: openapi3文档测试接口 @info.description: |-

该接口文档用于测试本程序生成的文档

@info.termsOfService: http://swagger.io/terms/ @info.contact.email: 807495056@qq.com @info.license.name: Apache 2.0 @info.license.url: http://www.apache.org/licenses/LICENSE-2.0.html @info.version: 1.0.0

@externalDocs.description:Find out more about Swagger @externalDocs.url: http://swagger.io

@servers: url=/v1;description=版本v1 @servers: url=/v2;description=版本v2

@tags: name=default @tags: name=user;description=用户管理 @tags: name=admin;description=后台管理

验证设置 @components.securitySchemes: field=token;type=apiKey;name=token;in=header

@components.securitySchemes: |-

field=projectID;type=oauth2;
flows={
	   "implicit": {
	     "authorizationUrl": "https://example.com/api/oauth/dialog",
	     "scopes": {
	       "write:pets": "modify pets in your account",
	       "read:pets": "read your pets"
	     }
	   }
	 }

@global.res: status=500; in=application/json; content=服务器链接失败; desc=系统内部错误 @global.param: in=query; name=type; type=string; desc=类型

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Index added in v0.0.2

func Index()

Index openapi @summary: 测试结构体递归注释 @res: status=200; in=application/json;content=github.com/getkin/kin-openapi/openapi3.T; desc=递归注释 @router: method=get;path=/index

func Upload added in v0.0.7

func Upload()

Upload 上传文件 @summary: 上传文件 @body: in=multipart/form-data; content=examples.UploadRequest; desc=上传文件 @router: method=put;path=/upload

Types

type Admin added in v0.0.2

type Admin struct {
}

func (Admin) Login added in v0.0.2

func (a Admin) Login()

Login openapi @summary: 登录后台 @description: 登录后返回token信息 @tags: admin @body: in=application/json; content=examples.LoginRequest; desc=登录参数 @res: status=200; in=application/json; content=examples.ResponseSuccess; desc=登录成功 @res: status=404; in=application/json; content=examples.ResponseError; desc=退出成功 @security: token;projectID=write:pets,read:pets @router: method=post;path=/admin/login

func (Admin) Logout added in v0.0.2

func (a Admin) Logout()

Logout openapi @summary: 退出登录 @description: 清除后端的登录缓存 @tags: admin @res: status=200; in=application/json; content=examples.ResponseSuccess; desc=退出成功 @res: status=404; in=application/json; content=examples.ResponseError; desc=退出失败 @security: token;projectID=write:pets,read:pets @router: method=delete;path=/admin/logout

type LoginRequest added in v0.0.2

type LoginRequest struct {
	Account  string `json:"account" openapi:"required"`  // 账号
	Password string `json:"password" openapi:"required"` // 密码
	Code     string `json:"code" required:"true"`        // 验证码
}

LoginRequest 是登录参数

type ResponseError added in v0.0.2

type ResponseError struct {
	Code int    `json:"code" default:"404"` // 错误码
	Msg  string `json:"msg" default:"返回失败"` // 错误信息
}

type ResponseSuccess added in v0.0.2

type ResponseSuccess struct {
	Code int `json:"code" default:"0"` // 操作成功
}

type UploadRequest added in v0.0.7

type UploadRequest struct {
	FileBinary string `json:"file_binary" type:"binary"` // 上传文件
	FileBase64 string `json:"file_base64" type:"binary"` // 上传文件
}

type User added in v0.0.2

type User struct {
}

func (*User) GetList added in v0.0.2

func (u *User) GetList()

GetList openapi @summary: 获取用户列表 @description: 用户列表接口需要授权 @tags: user @param: in=query; name=name; type=string; desc=用户名称 @param: in=query; name=sex; type=string; desc=用户性别 @res: status=200; in=application/json; content=[]examples.UserListResponseSuccess; desc=获取成功 @res: status=404; in=application/json; content=examples.ResponseError; desc=获取失败 @security: token;projectID=write:pets,read:pets @router: method=get;path=/user/list

func (*User) Info added in v0.0.2

func (u *User) Info()

Info openapi @summary: 用户信息 @description: 根据用户id查找用户信息 @tags: user @param: in=path; name=id; type=int64; required; desc=主键; minimum=1;maximum=10;default=1 @res: status=200; in=application/json; content=examples.UserListResponseSuccess; desc=返回信息 @res: status=404; in=application/json; content=examples.ResponseError; desc=获取失败 @security: token;projectID=write:pets,read:pets @router: method=get;path=/user/{id}

type UserListResponseSuccess added in v0.0.2

type UserListResponseSuccess struct {
	ID         int       `json:"id" default:"1"`                            // 主键
	Name       string    `json:"name" default:"张三"`                         // 名称
	Desc       string    `json:"desc" default:"张三非常棒"`                      // 简介
	CreateTime time.Time `json:"create_time" default:"2024-02-20 14:21:13"` // 创建时间
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL