generator

package
v0.0.0-...-dcbff68 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeywordMapping = map[string]string{
	"type": "t",
}

Functions

func KeywordMappingFunc

func KeywordMappingFunc(name string) string

func LoadExtraConfig

func LoadExtraConfig(configFile string) error

Types

type APIDefinition

type APIDefinition struct {
	Tags       []string
	Method     string
	Path       string
	Operation  string
	Parameters []*ParamDefinition
	Responses  map[int]*Response
}

type EnumValue

type EnumValue struct {
	Name  string
	Value string
}

type ExtraConfig

type ExtraConfig struct {
	Paths  map[string]map[string]MethodConfig `yaml:"paths"`
	Models map[string]ModelConfig             `yaml:"models"`
}

type FieldDefinition

type FieldDefinition struct {
	Name    string
	Type    string
	Tag     string
	Comment string
}

type Generator

type Generator struct {
	Config    *config.Config
	Services  map[string]ServiceDefinition
	ModelPkgs map[string]ModelPkgDefinition
}

func New

func New(config *config.Config) *Generator

func (*Generator) Generate

func (g *Generator) Generate() error

func (*Generator) ParseSwagger

func (g *Generator) ParseSwagger(b []byte) error

type MethodConfig

type MethodConfig struct {
	Name   string `yaml:"name"`   // 方法名称
	Ignore bool   `yaml:"ignore"` // 是否忽略该方法
}

type MethodDefinition

type MethodDefinition struct {
	Name            string
	Summary         string
	Endpoint        string
	FormatEndpoint  string
	HTTPMethod      string
	Parameters      []*ParamDefinition
	ReturnType      string
	PathParams      []*ParamDefinition
	QueryParams     []*ParamDefinition
	BodyParams      []*ParamDefinition
	ResponseType    string // 新增响应类型字段
	IsArrayResponse bool   // 是否是数组响应
}

type ModelConfig

type ModelConfig struct {
	IgnoreFields []string `yaml:"ignore_fields"`
}

type ModelDefinition

type ModelDefinition struct {
	Name        string
	PackagePath string
	Description string
	Fields      []*FieldDefinition
	IsEnum      bool
	EnumType    string
	EnumValues  []EnumValue
}

type ModelPkgDefinition

type ModelPkgDefinition struct {
	Models []*ModelDefinition
}

type ParamDefinition

type ParamDefinition struct {
	Name        string
	In          string // path, query, body
	Type        string
	Required    bool
	Description string
}

type Response

type Response struct {
	Schema      string
	Description string
}

type ServiceDefinition

type ServiceDefinition struct {
	ServiceName string
	StructName  string
	Methods     []*MethodDefinition
	Models      []*ModelDefinition
	Imports     map[string]struct{}
	ImportList  []string
}

Jump to

Keyboard shortcuts

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