schema

package
v0.0.0-...-07eafe9 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package schema 将 ast 转换铖 openapi 的 schema 对象

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPath

func NewPath(t string) (*openapi3.SchemaRef, error)

NewPath 根据 t 生成路径参数的 Schema

如果 t 的类型无法解析,则会尝试将其作为正则进行处理,如果还是不行则返回错误。

Types

type Error

type Error struct {
	Msg any
	Pos token.Pos
}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Log

func (err *Error) Log(l *logger.Logger, fset *token.FileSet)

type Schema

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

Schema 管理 Schema 的查询

func New

func New(l *logger.Logger) *Schema

func (*Schema) New

func (s *Schema) New(ctx context.Context, t *openapi.OpenAPI, typePath string, q bool) (*openapi3.SchemaRef, error)

New 根据类型名称 typePath 生成 SchemaRef 对象

typePath 表示需要查找的类型名,一般格式为 [path.]name,path 为包的路径,name 为类型名。 如果是内置类型可省略 path 部分。 如果 typePath 以 #components/schemas 开头,则从 t.Components.Schemas 下查找。 q 是否用于查询参数,如果是查询参数,那么字段名的获取将采用 json。

可能返回的错误值为 Error

func (*Schema) Packages

func (s *Schema) Packages() *pkg.Packages

Packages 返回关联的 pkg.Packages

Jump to

Keyboard shortcuts

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