Documentation ¶
Index ¶
- func IsBaseType(t string) (is bool, openApiType string)
- type AllOfSchema
- type AnySchema
- type ArraySchema
- type ErrSchema
- type GoAstToSchema
- type GoExprWithPath
- type GoStruct
- type IdentSchema
- type Modify
- type NotFoundGoExpr
- type ObjectProp
- type ObjectSchema
- type OpenApi
- type OutPutFormat
- type ParamsItem
- type ParamsList
- type PkgGetter
- type Schema
- type XData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBaseType ¶
all type of openapi: array, boolean, integer, number , object, string
Types ¶
type AllOfSchema ¶
type AllOfSchema struct { AllOf []Schema `json:"allOf"` // AllOf 也有Properties字段, 这是为了在js中使用此字段转为params数组 Properties jsonordered.MapSlice `json:"x-properties"` IsSchema bool `json:"x-schema"` }
type ArraySchema ¶
type GoAstToSchema ¶
type GoAstToSchema struct {
// contains filtered or unexported fields
}
type GoExprWithPath ¶
type GoExprWithPath struct {
// contains filtered or unexported fields
}
func (*GoExprWithPath) GetMember ¶
func (g *GoExprWithPath) GetMember(k string) (interface{}, error)
如果类型是 结构体, 则还需要查询到子方法或者子成员
func (*GoExprWithPath) Key ¶
func (expr *GoExprWithPath) Key() (string, error)
Key 返回某表达式的唯一标识. 用于判断是否重复, 如 ref的生成, 递归判断. 返回key格式如 pkgname.Ident, e.g. github.com/gopenapi/gopenapi/internal/delivery/http/handler.PetHandler 例:
- *model.Pet, 返回 xxx/model.Pet
- model.Pet , 返回 xxx/model.Pet
- Pet , 返回 {当前包}.Pet
- 其他情况下则认为没有唯一标识.
func (*GoExprWithPath) MarshalJSON ¶
func (g *GoExprWithPath) MarshalJSON() ([]byte, error)
在解析成json时(在js脚本中使用), 需要解析成js脚本能使用的格式, 即 GoStruct
type GoStruct ¶
type GoStruct struct { // FullDoc 是整个注释(除去变量部分) FullDoc string `json:"doc"` // FullDoc的第一句 Summary string `json:"summary"` // FullDoc除了第一个的剩下注释 Description string `json:"description"` // Meta 是变量部分, 应该使用json序列化后(给js脚本)使用 Meta jsonordered.MapSlice `json:"meta"` Schema Schema `json:"schema,omitempty"` XGoStruct bool `json:"x-gostruct"` }
处理 go 注释为元数据 这个值是js脚本的参数, 故需要正确的被json序列化.
type IdentSchema ¶
type IdentSchema struct { Ref string `json:"$ref,omitempty"` Type string `json:"type"` Description string `json:"description,omitempty"` Default interface{} `json:"default,omitempty"` Enum []interface{} `json:"enum,omitempty"` IsSchema bool `json:"x-schema,omitempty"` Example interface{} `json:"example,omitempty"` }
基础类型, string / int
type NotFoundGoExpr ¶
type NotFoundGoExpr struct {
// contains filtered or unexported fields
}
NotFoundGoExpr 用于表示没有找到Go表达式
如 schema(apkg.xxx), 如果apkg中没有找到xxx, 则会返回 NotFoundGoExpr 不返回nil的原因是需要有更多的信息用于友好提示
type ObjectProp ¶
type ObjectProp struct { Schema Schema `json:"schema"` Meta jsonordered.MapSlice `json:"meta,omitempty"` Tag map[string]string `json:"tag,omitempty"` }
ObjectProp 对象的成员
type ObjectSchema ¶
type ObjectSchema struct { Ref string `json:"$ref,omitempty"` Type string `json:"type"` Description string `json:"description,omitempty"` Properties jsonordered.MapSlice `json:"properties"` Example interface{} `json:"example,omitempty"` Modify []Modify `json:"modify,omitempty"` IsSchema bool `json:"x-schema,omitempty"` }
func (*ObjectSchema) GetMember ¶
func (o *ObjectSchema) GetMember(k string) (interface{}, error)
实现装饰器语法 schema(model.x).require('id','name', any)
type OpenApi ¶
type OpenApi struct {
// contains filtered or unexported fields
}
func (*OpenApi) CompleteYaml ¶
func (o *OpenApi) CompleteYaml(inYaml string, typ OutPutFormat) (dest string, err error)
完成openapi, 入口
type ParamsItem ¶
type ParamsItem struct { // From 表示此item来至那, 如 go From string `json:"_from"` Name string `json:"name"` Tag map[string]string `json:"tag"` Description string `json:"description"` Meta jsonordered.MapSlice `json:"meta,omitempty"` Schema Schema `json:"schema"` // Error 存储错误,用于友好提示 Error string `json:"error,omitempty"` }
从go结构体能读出的数据, 用于parameters
func (*ParamsItem) ToYaml ¶
func (t *ParamsItem) ToYaml(useTag string) []yaml.MapItem
type ParamsList ¶
type ParamsList []ParamsItem
openapi.params格式
func (ParamsList) ToYaml ¶
func (p ParamsList) ToYaml(useTag string) interface{}
Click to show internal directories.
Click to hide internal directories.