docs

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 11 Imported by: 0

README

Flow框架文档

Flow是一个基于Gin构建的现代化Go Web应用框架,旨在提供更流畅、简洁而强大的开发体验。通过平衡易用性和灵活性,Flow框架让开发者可以快速构建高性能、可维护的Web应用。

框架理念

Flow框架的设计理念是"流畅的开发体验"。我们认为框架应该:

  • 简单但不简陋:提供清晰的API,减少模板代码,但不牺牲功能
  • 灵活但有约束:允许自定义,但提供合理的默认值和最佳实践
  • 强大但轻量:提供丰富功能,但保持核心轻量化
  • 高性能但可维护:优化性能,同时保持代码的可读性和可维护性

快速开始

安装
go get github.com/zzliekkas/flow
创建第一个应用
package main

import (
    "github.com/zzliekkas/flow"
)

func main() {
    // 创建Flow应用
    app := flow.New()
    
    // 注册路由
    app.GET("/", func(c *flow.Context) {
        c.String(200, "Hello, Flow!")
    })
    
    // 启动服务器
    app.Run(":8080")
}
使用启动选项
app := flow.New(
    flow.WithConfig("config.yaml"),
    flow.WithDatabase(),
    flow.WithLogger("info"),
    flow.WithMiddleware(middleware.Recovery()),
)

核心功能

路由系统

Flow提供直观的路由管理:

// 注册路由
app.GET("/users", GetUsers)
app.POST("/users", CreateUser)
app.GET("/users/:id", GetUser)

// 路由组
api := app.Group("/api")
{
    api.GET("/products", GetProducts)
    api.POST("/products", CreateProduct)
}

// 中间件
auth := app.Group("/auth", middleware.JWT())
{
    auth.GET("/profile", GetProfile)
}
配置管理

Flow提供灵活的配置系统:

// 加载配置
config.Load("config.yaml")

// 获取配置值
appName := config.GetString("app.name")
port := config.GetInt("server.port")
debug := config.GetBool("app.debug")
依赖注入

Flow集成了依赖注入容器:

// 注册服务
app.Provide(NewUserService)
app.Provide(NewProductService)

// 使用服务
app.GET("/users", func(c *flow.Context) {
    var userService *UserService
    c.Inject(&userService)
    users := userService.GetAll()
    c.JSON(200, users)
})
数据库操作

Flow简化了数据库操作:

// 模型定义
type User struct {
    ID        uint   `gorm:"primaryKey"`
    Name      string `gorm:"not null"`
    Email     string `gorm:"unique;not null"`
    CreatedAt time.Time
}

// 查询
var users []User
db.Find(&users)

// 创建
db.Create(&User{Name: "John", Email: "john@example.com"})
中间件

使用内置中间件:

// 全局中间件
app.Use(middleware.Logger())
app.Use(middleware.Recovery())

// 路由组中间件
api := app.Group("/api", middleware.CORS())

框架模块

Flow框架由多个模块组成,每个模块都可以独立使用:

认证系统 (auth/)

认证模块支持多种身份验证方式和权限管理:

// 配置JWT认证
auth := auth.NewJWTAuth(auth.Config{
    SecretKey: "your-secret-key",
    Expire:    24 * time.Hour,
})

// 保护路由
app.GET("/protected", auth.Middleware(), func(c *flow.Context) {
    c.String(200, "Protected resource")
})

// 获取当前用户
user := auth.CurrentUser(c)
数据库支持 (db/)

数据库模块提供GORM增强功能和事务管理:

// 初始化数据库
db.Init(db.Config{
    Driver:   "mysql",
    Host:     "localhost",
    Port:     3306,
    Username: "root",
    Password: "password",
    Database: "flow_app",
})

// 使用事务
db.Transaction(func(tx *gorm.DB) error {
    // 执行事务操作
    return nil
})
缓存系统 (cache/)

缓存模块支持多种驱动和便捷API:

// 使用Redis缓存
cache := cache.New(cache.Redis{
    Addr: "localhost:6379",
})

// 存储数据
cache.Set("key", "value", 10*time.Minute)

// 获取数据
val, err := cache.Get("key")
消息队列 (queue/)

队列模块用于异步任务处理:

// 创建队列
queue := queue.New(queue.Config{
    Driver: "redis",
    Addr:   "localhost:6379",
})

// 注册任务处理器
queue.Register("send_email", SendEmailHandler)

// 分发任务
queue.Dispatch("send_email", map[string]interface{}{
    "to":      "user@example.com",
    "subject": "Welcome",
})
国际化 (i18n/)

国际化模块支持多语言翻译:

// 初始化
i18n.Init("locales")

// 设置当前语言
i18n.SetLocale("zh-CN")

// 翻译
message := i18n.T("welcome", map[string]interface{}{
    "name": "John",
})
WebSocket支持 (websocket/)

WebSocket模块提供实时通信支持:

// 创建WebSocket管理器
ws := websocket.New()

// 注册处理器
app.GET("/ws", ws.Handler())

// 广播消息
ws.Broadcast("event", data)
开发工具 (dev/)

开发工具模块提供热重载和调试功能:

// 启用开发工具
if app.IsDebug() {
    dev.EnableHotReload("./")
    dev.EnableDebugger()
}
性能分析 (profiler/)

性能分析模块提供应用性能监控:

// 创建性能分析器
profiler := profiler.New()

// 启动分析
profiler.Start()

// 导出报告
report, err := profiler.Stop()

高级主题

部署指南

详细介绍了如何将Flow应用部署到不同环境:

  • Docker容器化
  • Kubernetes部署
  • 传统服务器部署
性能优化

提供Flow应用的性能优化建议:

  • 数据库查询优化
  • 缓存策略
  • 并发处理
测试策略

介绍Flow应用的测试最佳实践:

  • 单元测试
  • 集成测试
  • 端到端测试

贡献指南

如何为Flow框架做出贡献:

  • 代码风格规范
  • Pull Request流程
  • 问题报告指南

API参考

完整的API文档,包括:

  • 核心API
  • 各模块API
  • 辅助函数

示例应用

提供完整的示例应用:

  • 简单API服务器
  • 完整Web应用
  • 微服务架构示例

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src, dst string) error

CopyDir 复制目录及其所有内容

func CopyFile

func CopyFile(src, dst string) error

CopyFile 复制单个文件

Types

type APIDocGenerator

type APIDocGenerator struct {
	// contains filtered or unexported fields
}

APIDocGenerator 用于生成API文档的生成器

func NewAPIDocGenerator

func NewAPIDocGenerator(application *app.Application) *APIDocGenerator

NewAPIDocGenerator 创建新的API文档生成器

func (*APIDocGenerator) ExcludeDirectories

func (g *APIDocGenerator) ExcludeDirectories(dirs ...string) *APIDocGenerator

ExcludeDirectories 设置要排除的目录

func (*APIDocGenerator) Generate

func (g *APIDocGenerator) Generate() error

Generate 生成API文档

func (*APIDocGenerator) IncludeDirectories

func (g *APIDocGenerator) IncludeDirectories(dirs ...string) *APIDocGenerator

IncludeDirectories 设置要包含的目录

func (*APIDocGenerator) IncludeInternalMethods

func (g *APIDocGenerator) IncludeInternalMethods(include bool) *APIDocGenerator

IncludeInternalMethods 是否包含内部方法

func (*APIDocGenerator) IncludePrivateMethods

func (g *APIDocGenerator) IncludePrivateMethods(include bool) *APIDocGenerator

IncludePrivateMethods 是否包含私有方法

func (*APIDocGenerator) SetAPIVersion

func (g *APIDocGenerator) SetAPIVersion(version string) *APIDocGenerator

SetAPIVersion 设置API版本

func (*APIDocGenerator) SetAuthor

func (g *APIDocGenerator) SetAuthor(author string) *APIDocGenerator

SetAuthor 设置作者信息

func (*APIDocGenerator) SetBaseURL

func (g *APIDocGenerator) SetBaseURL(url string) *APIDocGenerator

SetBaseURL 设置基础URL

func (*APIDocGenerator) SetDescription

func (g *APIDocGenerator) SetDescription(desc string) *APIDocGenerator

SetDescription 设置文档描述

func (*APIDocGenerator) SetEmail

func (g *APIDocGenerator) SetEmail(email string) *APIDocGenerator

SetEmail 设置联系邮箱

func (*APIDocGenerator) SetFileExtensions

func (g *APIDocGenerator) SetFileExtensions(exts ...string) *APIDocGenerator

SetFileExtensions 设置要解析的文件扩展名

func (*APIDocGenerator) SetLicense

func (g *APIDocGenerator) SetLicense(license string) *APIDocGenerator

SetLicense 设置许可证信息

func (*APIDocGenerator) SetOutputDir

func (g *APIDocGenerator) SetOutputDir(dir string) *APIDocGenerator

SetOutputDir 设置输出目录

func (*APIDocGenerator) SetRoutePrefix

func (g *APIDocGenerator) SetRoutePrefix(prefix string) *APIDocGenerator

SetRoutePrefix 设置路由前缀

func (*APIDocGenerator) SetSourceDir

func (g *APIDocGenerator) SetSourceDir(dir string) *APIDocGenerator

SetSourceDir 设置源代码目录

func (*APIDocGenerator) SetTitle

func (g *APIDocGenerator) SetTitle(title string) *APIDocGenerator

SetTitle 设置文档标题

func (*APIDocGenerator) UseMarkdown

func (g *APIDocGenerator) UseMarkdown(use bool) *APIDocGenerator

UseMarkdown 是否使用Markdown格式

type APIDocumentation

type APIDocumentation struct {
	// 文档标题
	Title string `json:"title"`

	// 文档描述
	Description string `json:"description"`

	// API版本
	Version string `json:"version"`

	// 基础URL
	BaseURL string `json:"base_url"`

	// 生成时间
	GeneratedAt time.Time `json:"generated_at"`

	// 作者
	Author string `json:"author,omitempty"`

	// 联系邮箱
	Email string `json:"email,omitempty"`

	// 许可证
	License string `json:"license,omitempty"`

	// API端点列表
	Endpoints []APIEndpoint `json:"endpoints"`

	// 模型定义
	Models map[string]interface{} `json:"models,omitempty"`
}

APIDocumentation 表示整体API文档

type APIEndpoint

type APIEndpoint struct {
	// 端点路径
	Path string `json:"path"`

	// HTTP方法
	Method string `json:"method"`

	// 端点描述
	Description string `json:"description"`

	// 处理器函数名称
	Handler string `json:"handler"`

	// 请求参数
	RequestParams []APIParam `json:"request_params,omitempty"`

	// 请求体
	RequestBody interface{} `json:"request_body,omitempty"`

	// 响应体
	ResponseBody interface{} `json:"response_body,omitempty"`

	// 可能的响应状态码
	StatusCodes []APIStatusCode `json:"status_codes,omitempty"`

	// 中间件
	Middleware []string `json:"middleware,omitempty"`

	// 分组名
	Group string `json:"group,omitempty"`

	// 端点标签(用于分类)
	Tags []string `json:"tags,omitempty"`

	// 是否废弃
	Deprecated bool `json:"deprecated,omitempty"`

	// 废弃说明
	DeprecationMessage string `json:"deprecation_message,omitempty"`

	// 示例请求
	Examples []APIExample `json:"examples,omitempty"`
}

APIEndpoint 表示API端点信息

type APIExample

type APIExample struct {
	// 示例名称
	Name string `json:"name"`

	// 示例请求
	Request interface{} `json:"request"`

	// 示例响应
	Response interface{} `json:"response"`

	// 示例描述
	Description string `json:"description,omitempty"`
}

APIExample 表示API示例

type APIParam

type APIParam struct {
	// 参数名
	Name string `json:"name"`

	// 参数类型
	Type string `json:"type"`

	// 参数描述
	Description string `json:"description"`

	// 是否必需
	Required bool `json:"required"`

	// 默认值
	DefaultValue string `json:"default_value,omitempty"`

	// 参数位置(路径、查询、头部、正文等)
	Location string `json:"location"`

	// 验证规则
	ValidationRules string `json:"validation_rules,omitempty"`

	// 示例值
	Example string `json:"example,omitempty"`
}

APIParam 表示API参数信息

type APIStatusCode

type APIStatusCode struct {
	// HTTP状态码
	Code int `json:"code"`

	// 状态描述
	Description string `json:"description"`

	// 示例响应
	Example interface{} `json:"example,omitempty"`
}

APIStatusCode 表示API响应状态码信息

type CLIDocGenerator

type CLIDocGenerator struct {
	// contains filtered or unexported fields
}

CLIDocGenerator 用于生成命令行工具文档的生成器

func NewCLIDocGenerator

func NewCLIDocGenerator(application *app.Application) *CLIDocGenerator

NewCLIDocGenerator 创建新的CLI文档生成器

func (*CLIDocGenerator) Generate

func (g *CLIDocGenerator) Generate() error

Generate 生成CLI文档

func (*CLIDocGenerator) SetOutputDir

func (g *CLIDocGenerator) SetOutputDir(dir string) *CLIDocGenerator

SetOutputDir 设置输出目录

type ConfigDocGenerator

type ConfigDocGenerator struct {
	// contains filtered or unexported fields
}

ConfigDocGenerator 用于生成配置文档的生成器

func NewConfigDocGenerator

func NewConfigDocGenerator(application *app.Application) *ConfigDocGenerator

NewConfigDocGenerator 创建新的配置文档生成器

func (*ConfigDocGenerator) Generate

func (g *ConfigDocGenerator) Generate() error

Generate 生成配置文档

func (*ConfigDocGenerator) SetOutputDir

func (g *ConfigDocGenerator) SetOutputDir(dir string) *ConfigDocGenerator

SetOutputDir 设置输出目录

type DatabaseDocGenerator

type DatabaseDocGenerator struct {
	// contains filtered or unexported fields
}

DatabaseDocGenerator 用于生成数据库文档的生成器

func NewDatabaseDocGenerator

func NewDatabaseDocGenerator(application *app.Application) *DatabaseDocGenerator

NewDatabaseDocGenerator 创建新的数据库文档生成器

func (*DatabaseDocGenerator) Generate

func (g *DatabaseDocGenerator) Generate() error

Generate 生成数据库文档

func (*DatabaseDocGenerator) SetOutputDir

func (g *DatabaseDocGenerator) SetOutputDir(dir string) *DatabaseDocGenerator

SetOutputDir 设置输出目录

type DocumentationGenerator

type DocumentationGenerator struct {
	// contains filtered or unexported fields
}

DocumentationGenerator 是整体文档生成器,协调各种类型的文档生成

func NewDocumentationGenerator

func NewDocumentationGenerator(application *app.Application) *DocumentationGenerator

NewDocumentationGenerator 创建新的文档生成器

func (*DocumentationGenerator) AddGenerator

func (g *DocumentationGenerator) AddGenerator(generator Generator) *DocumentationGenerator

AddGenerator 添加自定义生成器

func (*DocumentationGenerator) EnableAPI

func (g *DocumentationGenerator) EnableAPI(enable bool) *DocumentationGenerator

EnableAPI 启用API文档生成

func (*DocumentationGenerator) EnableCLI

func (g *DocumentationGenerator) EnableCLI(enable bool) *DocumentationGenerator

EnableCLI 启用命令行文档生成

func (*DocumentationGenerator) EnableConfig

func (g *DocumentationGenerator) EnableConfig(enable bool) *DocumentationGenerator

EnableConfig 启用配置文档生成

func (*DocumentationGenerator) EnableDatabase

func (g *DocumentationGenerator) EnableDatabase(enable bool) *DocumentationGenerator

EnableDatabase 启用数据库文档生成

func (*DocumentationGenerator) EnableModules

func (g *DocumentationGenerator) EnableModules(enable bool) *DocumentationGenerator

EnableModules 启用模块文档生成

func (*DocumentationGenerator) EnableSearch

func (g *DocumentationGenerator) EnableSearch(enable bool) *DocumentationGenerator

EnableSearch 启用搜索功能

func (*DocumentationGenerator) EnableUI

func (g *DocumentationGenerator) EnableUI(enable bool) *DocumentationGenerator

EnableUI 启用UI生成

func (*DocumentationGenerator) Generate

func (g *DocumentationGenerator) Generate() error

Generate 执行文档生成

func (*DocumentationGenerator) SetBaseURL

SetBaseURL 设置基础URL

func (*DocumentationGenerator) SetCustomCSS

SetCustomCSS 设置自定义CSS

func (*DocumentationGenerator) SetCustomJS

SetCustomJS 设置自定义JS

func (*DocumentationGenerator) SetDescription

func (g *DocumentationGenerator) SetDescription(desc string) *DocumentationGenerator

SetDescription 设置项目描述

func (*DocumentationGenerator) SetFooter

SetFooter 设置页脚

func (*DocumentationGenerator) SetGoogleAnalyticsID

func (g *DocumentationGenerator) SetGoogleAnalyticsID(id string) *DocumentationGenerator

SetGoogleAnalyticsID 设置Google Analytics ID

func (*DocumentationGenerator) SetLogoPath

SetLogoPath 设置Logo路径

func (*DocumentationGenerator) SetOutputDir

SetOutputDir 设置输出目录

func (*DocumentationGenerator) SetProjectName

func (g *DocumentationGenerator) SetProjectName(name string) *DocumentationGenerator

SetProjectName 设置项目名称

func (*DocumentationGenerator) SetTitle

SetTitle 设置文档标题

func (*DocumentationGenerator) SetUIDir

SetUIDir 设置UI目录

func (*DocumentationGenerator) SetUITheme

SetUITheme 设置UI主题

func (*DocumentationGenerator) SetVersion

func (g *DocumentationGenerator) SetVersion(version string) *DocumentationGenerator

SetVersion 设置项目版本

type FieldDefinition

type FieldDefinition struct {
	// 字段名
	Name string `json:"name"`

	// 字段描述
	Description string `json:"description,omitempty"`

	// 字段类型
	Type string `json:"type"`

	// 字段标签
	Tags map[string]string `json:"tags,omitempty"`

	// 是否为主键
	PrimaryKey bool `json:"primary_key,omitempty"`

	// 是否必需
	Required bool `json:"required,omitempty"`

	// 字段默认值
	DefaultValue string `json:"default_value,omitempty"`

	// 是否可为空
	Nullable bool `json:"nullable,omitempty"`

	// 字段注释
	Comment string `json:"comment,omitempty"`

	// 字段验证规则
	ValidationRules string `json:"validation_rules,omitempty"`

	// 字段索引名(如果是索引)
	IndexName string `json:"index_name,omitempty"`

	// 是否唯一
	Unique bool `json:"unique,omitempty"`

	// 关联模型(如果是外键)
	RelatedModel string `json:"related_model,omitempty"`

	// 关联字段(如果是外键)
	RelatedField string `json:"related_field,omitempty"`

	// 字段示例值
	Example string `json:"example,omitempty"`
}

FieldDefinition 表示字段定义

type Generator

type Generator interface {
	// Generate 生成文档
	Generate() error
}

Generator 是文档生成器接口

type ModelDefinition

type ModelDefinition struct {
	// 模型名称
	Name string `json:"name"`

	// 模型描述
	Description string `json:"description"`

	// 模型注释
	Comment string `json:"comment,omitempty"`

	// 模型所在包路径
	Package string `json:"package"`

	// 对应的数据库表(如果有)
	Table string `json:"table,omitempty"`

	// 字段定义
	Fields []FieldDefinition `json:"fields"`
}

ModelDefinition 表示模型定义

type ModelDoc

type ModelDoc struct {
	// 文档标题
	Title string `json:"title"`

	// 文档描述
	Description string `json:"description"`

	// 生成时间
	GeneratedAt time.Time `json:"generated_at"`

	// 模型定义
	Models []ModelDefinition `json:"models"`

	// 关系定义
	Relationships []Relationship `json:"relationships,omitempty"`
}

ModelDoc 表示模型文档

type ModelDocGenerator

type ModelDocGenerator struct {
	// contains filtered or unexported fields
}

ModelDocGenerator 用于生成数据模型文档的生成器

func NewModelDocGenerator

func NewModelDocGenerator(application *app.Application) *ModelDocGenerator

NewModelDocGenerator 创建新的模型文档生成器

func (*ModelDocGenerator) AddModelPackage

func (g *ModelDocGenerator) AddModelPackage(path string) *ModelDocGenerator

AddModelPackage 添加模型包路径

func (*ModelDocGenerator) Generate

func (g *ModelDocGenerator) Generate() error

Generate 生成模型文档

func (*ModelDocGenerator) IgnoreFields

func (g *ModelDocGenerator) IgnoreFields(fields ...string) *ModelDocGenerator

IgnoreFields 设置要忽略的字段

func (*ModelDocGenerator) IncludeEmbeddedFields

func (g *ModelDocGenerator) IncludeEmbeddedFields(include bool) *ModelDocGenerator

IncludeEmbeddedFields 设置是否包含嵌入字段

func (*ModelDocGenerator) IncludePrivateFields

func (g *ModelDocGenerator) IncludePrivateFields(include bool) *ModelDocGenerator

IncludePrivateFields 设置是否包含私有字段

func (*ModelDocGenerator) SetDescription

func (g *ModelDocGenerator) SetDescription(desc string) *ModelDocGenerator

SetDescription 设置文档描述

func (*ModelDocGenerator) SetGenerateERDiagram

func (g *ModelDocGenerator) SetGenerateERDiagram(generate bool) *ModelDocGenerator

SetGenerateERDiagram 设置是否生成ER图

func (*ModelDocGenerator) SetOutputDir

func (g *ModelDocGenerator) SetOutputDir(dir string) *ModelDocGenerator

SetOutputDir 设置输出目录

func (*ModelDocGenerator) SetSourceDir

func (g *ModelDocGenerator) SetSourceDir(dir string) *ModelDocGenerator

SetSourceDir 设置源码目录

func (*ModelDocGenerator) SetTitle

func (g *ModelDocGenerator) SetTitle(title string) *ModelDocGenerator

SetTitle 设置文档标题

func (*ModelDocGenerator) UseMarkdown

func (g *ModelDocGenerator) UseMarkdown(use bool) *ModelDocGenerator

UseMarkdown 设置是否使用Markdown格式

type ModuleDocGenerator

type ModuleDocGenerator struct {
	// contains filtered or unexported fields
}

ModuleDocGenerator 用于生成模块文档的生成器

func NewModuleDocGenerator

func NewModuleDocGenerator(application *app.Application) *ModuleDocGenerator

NewModuleDocGenerator 创建新的模块文档生成器

func (*ModuleDocGenerator) Generate

func (g *ModuleDocGenerator) Generate() error

Generate 生成模块文档

func (*ModuleDocGenerator) SetOutputDir

func (g *ModuleDocGenerator) SetOutputDir(dir string) *ModuleDocGenerator

SetOutputDir 设置输出目录

type Relationship

type Relationship struct {
	// 源模型
	Source string `json:"source"`

	// 目标模型
	Target string `json:"target"`

	// 关系类型(一对一、一对多、多对多)
	Type string `json:"type"`

	// 源字段
	SourceField string `json:"source_field"`

	// 目标字段
	TargetField string `json:"target_field"`

	// 关系描述
	Description string `json:"description,omitempty"`

	// 中间表(如果是多对多关系)
	JoinTable string `json:"join_table,omitempty"`
}

Relationship 表示模型间关系

type SwaggerContact

type SwaggerContact struct {
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

SwaggerContact 表示联系人信息

type SwaggerDocument

type SwaggerDocument struct {
	Swagger             string                 `json:"swagger"`
	Info                SwaggerInfo            `json:"info"`
	Host                string                 `json:"host,omitempty"`
	BasePath            string                 `json:"basePath,omitempty"`
	Schemes             []string               `json:"schemes,omitempty"`
	Paths               map[string]interface{} `json:"paths"`
	Definitions         map[string]interface{} `json:"definitions,omitempty"`
	SecurityDefinitions map[string]interface{} `json:"securityDefinitions,omitempty"`
	Tags                []SwaggerTag           `json:"tags,omitempty"`
}

SwaggerDocument 表示Swagger文档

type SwaggerGenerator

type SwaggerGenerator struct {
	// contains filtered or unexported fields
}

SwaggerGenerator 用于生成Swagger规范文档

func NewSwaggerGenerator

func NewSwaggerGenerator(apiGenerator *APIDocGenerator) *SwaggerGenerator

NewSwaggerGenerator 创建新的Swagger文档生成器

func (*SwaggerGenerator) AddBasicAuthSecurityDefinition

func (g *SwaggerGenerator) AddBasicAuthSecurityDefinition() *SwaggerGenerator

AddBasicAuthSecurityDefinition 添加基本认证安全定义

func (*SwaggerGenerator) AddGlobalParameter

func (g *SwaggerGenerator) AddGlobalParameter(name string, parameter interface{}) *SwaggerGenerator

AddGlobalParameter 添加全局参数

func (*SwaggerGenerator) AddGlobalResponse

func (g *SwaggerGenerator) AddGlobalResponse(name string, response interface{}) *SwaggerGenerator

AddGlobalResponse 添加全局响应

func (*SwaggerGenerator) AddJWTSecurityDefinition

func (g *SwaggerGenerator) AddJWTSecurityDefinition() *SwaggerGenerator

AddJWTSecurityDefinition 添加JWT安全定义

func (*SwaggerGenerator) AddSecurityDefinition

func (g *SwaggerGenerator) AddSecurityDefinition(name string, definition interface{}) *SwaggerGenerator

AddSecurityDefinition 添加安全定义

func (*SwaggerGenerator) Generate

func (g *SwaggerGenerator) Generate() error

Generate 生成Swagger文档

func (*SwaggerGenerator) SetHost

func (g *SwaggerGenerator) SetHost(host string) *SwaggerGenerator

SetHost 设置主机名

func (*SwaggerGenerator) SetOutputDir

func (g *SwaggerGenerator) SetOutputDir(dir string) *SwaggerGenerator

SetOutputDir 设置输出目录

func (*SwaggerGenerator) SetSchemes

func (g *SwaggerGenerator) SetSchemes(schemes ...string) *SwaggerGenerator

SetSchemes 设置协议

type SwaggerInfo

type SwaggerInfo struct {
	Title       string          `json:"title"`
	Description string          `json:"description"`
	Version     string          `json:"version"`
	Contact     *SwaggerContact `json:"contact,omitempty"`
	License     *SwaggerLicense `json:"license,omitempty"`
}

SwaggerInfo 表示Swagger信息

type SwaggerLicense

type SwaggerLicense struct {
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

SwaggerLicense 表示许可证信息

type SwaggerTag

type SwaggerTag struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

SwaggerTag 表示API分组标签

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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