restgen

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMethod

func GetMethod(field *codegen.Field, defaultMethod string) string

func GetSelection

func GetSelection(objects *codegen.Objects, field *codegen.Field, refer bool) string

func GetURL

func GetURL(field *codegen.Field) string

func IsIgnoreField added in v0.1.3

func IsIgnoreField(field *codegen.Field) bool

func New

func New(filename string, typename string) plugin.Plugin

func NewDocPlugin added in v0.1.3

func NewDocPlugin(filename string, typename string, isPublished bool) plugin.Plugin

func ShouldHide

func ShouldHide(directive *ast.Directive) bool

_$_ [Using Functions Inside Go Templates - Calhoun.io](https://www.calhoun.io/intro-to-templates-p3-functions/# ) | ClippedOn=2021-08-10T09:45:06.709Z

func StaticCheck added in v0.0.21

func StaticCheck(data *codegen.Data)

Types

type API added in v0.1.3

type API struct {
	Get    *APIObject `yaml:"get,omitempty"`
	POST   *APIObject `yaml:"post,omitempty"`
	PUT    *APIObject `yaml:"put,omitempty"`
	Patch  *APIObject `yaml:"patch,omitempty"`
	Delete *APIObject `yaml:"delete,omitempty"`
	// contains filtered or unexported fields
}

api请求方法

func (*API) Tags added in v0.1.6

func (api *API) Tags() []string

type APIObject added in v0.1.3

type APIObject struct {
	OperationID string                  `yaml:"operationId"`
	Tags        []string                `yaml:"tags"`
	Deprecated  *bool                   `yaml:"deprecated,omitempty"`
	HCIVersions []string                `yaml:"x-hci-versions,omitempty"`
	RequestBody *APIRequestBody         `yaml:"requestBody,omitempty"`
	Parameters  []*APIParameter         `yaml:"parameters,omitempty"`
	Description string                  `yaml:"description,omitempty"`
	Responses   map[string]*APIResponse `yaml:"responses"`
}

api

type APIParameter added in v0.1.3

type APIParameter struct {
	Name        string      `yaml:"name"`
	In          string      `yaml:"in"`
	Required    bool        `yaml:"required"`
	Description string      `yaml:"description"`
	Schema      *SchemaType `yaml:"schema"`
}

type APIRequestBody added in v0.1.3

type APIRequestBody struct {
	Required bool                `yaml:"required"`
	Content  *APIResponseContent `yaml:"content"`
	// contains filtered or unexported fields
}

type APIResponse added in v0.1.3

type APIResponse struct {
	Content     *APIResponseContent `yaml:"content"`
	Description string              `yaml:"description"`
}

type APIResponseContent added in v0.1.3

type APIResponseContent struct {
	Json *SchemaObject `yaml:"application/json"`
}

type Component added in v0.1.3

type Component struct {
	Schemas map[string]*Object `yaml:"schemas"`
}

type DocPlugin added in v0.1.3

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

func (*DocPlugin) GenerateCode added in v0.1.3

func (m *DocPlugin) GenerateCode(data *codegen.Data) error

func (*DocPlugin) GenerateOpenAPIDoc added in v0.1.10

func (m *DocPlugin) GenerateOpenAPIDoc(yamlDir string, schema *ast.Schema, query *codegen.Object, mutation *codegen.Object) error

GenerateOpenAPIDoc 生成openapi文档

func (*DocPlugin) MutateConfig added in v0.1.3

func (m *DocPlugin) MutateConfig(cfg *config.Config) error

func (*DocPlugin) Name added in v0.1.3

func (m *DocPlugin) Name() string

type Object added in v0.1.3

type Object struct {
	Type        string         `yaml:"type"`
	Format      string         `yaml:"format,omitempty"`
	Description string         `yaml:"description,omitempty"`
	Enum        []string       `yaml:"enum,omitempty"`
	Required    []string       `yaml:"required,omitempty"`
	Properties  []yaml.MapItem `yaml:"properties,omitempty"`
	Minimum     *float64       `yaml:"minimum,omitempty"` //Number取值限制
	Maximum     *float64       `yaml:"maximum,omitempty"`
	OneOf       []float64      `yaml:"x-oneof,omitempty"`   // oneof枚举
	MinLength   *int64         `yaml:"minLength,omitempty"` //字符串取值限制
	MaxLength   *int64         `yaml:"maxLength,omitempty"`
	Pattern     *string        `yaml:"pattern,omitempty"`
	MinItems    *int64         `yaml:"minItems,omitempty"` //切片元素数量限制
	MaxItems    *int64         `yaml:"maxItems,omitempty"`
	// contains filtered or unexported fields
}

对象(包含入参、枚举、返回值)

type OpenAPIDoc added in v0.1.3

type OpenAPIDoc struct {
	OpenAPI    string          `yaml:"openapi"`
	Info       *OpenAPIInfo    `yaml:"info"`
	Tags       []string        `yaml:"tags,omitempty"`
	Paths      map[string]*API `yaml:"paths"`
	Components *Component      `yaml:"components"`
}

openapi文档对象

type OpenAPIInfo added in v0.1.3

type OpenAPIInfo struct {
	Version     string `yaml:"version"`
	Description string `yaml:"description"`
	Title       string `yaml:"title"`
}

type Plugin

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

func (*Plugin) GenerateCode

func (m *Plugin) GenerateCode(data *codegen.Data) error

func (*Plugin) MutateConfig

func (m *Plugin) MutateConfig(cfg *config.Config) error

func (*Plugin) Name

func (m *Plugin) Name() string

type ResolverBuild

type ResolverBuild struct {
	*codegen.Data

	TypeName string
}

type SchemaObject added in v0.1.3

type SchemaObject struct {
	Schema *SchemaType `yaml:"schema"`
}

type SchemaType added in v0.1.3

type SchemaType struct {
	Type        string    `yaml:"type,omitempty"`
	Nullable    *bool     `yaml:"nullable,omitempty"`
	Description string    `yaml:"description,omitempty"`
	Format      string    `yaml:"format,omitempty"`
	Ref         string    `yaml:"$ref,omitempty"`
	Items       *TypeBase `yaml:"items,omitempty"`
	OneOf       []float64 `yaml:"x-oneof,omitempty"` // oneof枚举
	Minimum     *float64  `yaml:"minimum,omitempty"` //Number取值限制
	Maximum     *float64  `yaml:"maximum,omitempty"`
	MinLength   *int64    `yaml:"minLength,omitempty"` //字符串取值限制
	MaxLength   *int64    `yaml:"maxLength,omitempty"`
	Pattern     *string   `yaml:"pattern,omitempty"`
	MinItems    *int64    `yaml:"minItems,omitempty"` //切片元素数量限制
	MaxItems    *int64    `yaml:"maxItems,omitempty"`
	// contains filtered or unexported fields
}

type TypeBase added in v0.1.3

type TypeBase struct {
	Type      string    `yaml:"type,omitempty"`
	Format    string    `yaml:"format,omitempty"`
	Ref       string    `yaml:"$ref,omitempty"`
	OneOf     []float64 `yaml:"x-oneof,omitempty"` // oneof枚举
	Minimum   *float64  `yaml:"minimum,omitempty"` //Number取值限制
	Maximum   *float64  `yaml:"maximum,omitempty"`
	MinLength *int64    `yaml:"minLength,omitempty"` //字符串取值限制
	MaxLength *int64    `yaml:"maxLength,omitempty"`
	Pattern   *string   `yaml:"pattern,omitempty"`
	MinItems  *int64    `yaml:"minItems,omitempty"` //切片元素数量限制
	MaxItems  *int64    `yaml:"maxItems,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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