本文整理汇总了Golang中github.com/go-swagger/go-swagger/spec.Document.SchemasWithAllOf方法的典型用法代码示例。如果您正苦于以下问题:Golang Document.SchemasWithAllOf方法的具体用法?Golang Document.SchemasWithAllOf怎么用?Golang Document.SchemasWithAllOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/go-swagger/go-swagger/spec.Document
的用法示例。
在下文中一共展示了Document.SchemasWithAllOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: discriminatorInfo
func discriminatorInfo(doc *spec.Document) *discInfo {
baseTypes := make(map[string]discor)
for _, sch := range doc.AllDefinitions() {
if sch.Schema.Discriminator != "" {
tpe, _ := sch.Schema.Extensions.GetString("x-go-name")
if tpe == "" {
tpe = swag.ToGoName(sch.Name)
}
baseTypes[sch.Ref.String()] = discor{
FieldName: sch.Schema.Discriminator,
GoType: tpe,
JSONName: sch.Name,
}
}
}
subTypes := make(map[string]discee)
for _, sch := range doc.SchemasWithAllOf() {
for _, ao := range sch.Schema.AllOf {
if ao.Ref.String() != "" {
if bt, ok := baseTypes[ao.Ref.String()]; ok {
name, _ := sch.Schema.Extensions.GetString("x-class")
if name == "" {
name, _ = sch.Schema.Extensions.GetString("x-go-name")
}
if name == "" {
name = swag.ToGoName(sch.Name)
}
tpe, _ := sch.Schema.Extensions.GetString("x-go-name")
if tpe == "" {
tpe = swag.ToGoName(sch.Name)
}
dce := discee{
FieldName: bt.FieldName,
FieldValue: name,
Ref: sch.Ref,
ParentRef: ao.Ref,
JSONName: sch.Name,
GoType: tpe,
}
subTypes[sch.Ref.String()] = dce
bt.Children = append(bt.Children, dce)
baseTypes[ao.Ref.String()] = bt
}
}
}
}
return &discInfo{Discriminators: baseTypes, Discriminated: subTypes}
}