本文整理汇总了Golang中github.com/aiyi/swagger-gin/spec.Schema.AllOf方法的典型用法代码示例。如果您正苦于以下问题:Golang Schema.AllOf方法的具体用法?Golang Schema.AllOf怎么用?Golang Schema.AllOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aiyi/swagger-gin/spec.Schema
的用法示例。
在下文中一共展示了Schema.AllOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestTypeResolver_ObjectType
func TestTypeResolver_ObjectType(t *testing.T) {
_, resolver, err := basicTaskListResolver(t)
resolver.ModelName = "TheModel"
defer func() { resolver.ModelName = "" }()
if assert.NoError(t, err) {
//very poor schema definitions (as in none)
types := []string{"object", ""}
for _, tpe := range types {
sch := new(spec.Schema)
sch.Typed(tpe, "")
rt, err := resolver.ResolveSchema(sch, true)
if assert.NoError(t, err) {
assert.True(t, rt.IsMap)
assert.False(t, rt.IsComplexObject)
assert.Equal(t, "map[string]interface{}", rt.GoType)
assert.Equal(t, "object", rt.SwaggerType)
}
sch.Properties = make(map[string]spec.Schema)
var ss spec.Schema
sch.Properties["tags"] = *(&ss).CollectionOf(*spec.StringProperty())
rt, err = resolver.ResolveSchema(sch, false)
assert.True(t, rt.IsComplexObject)
assert.False(t, rt.IsMap)
assert.Equal(t, "models.TheModel", rt.GoType)
assert.Equal(t, "object", rt.SwaggerType)
sch.Properties = nil
nsch := new(spec.Schema)
nsch.Typed(tpe, "")
nsch.AllOf = []spec.Schema{*sch}
rt, err = resolver.ResolveSchema(nsch, false)
if assert.NoError(t, err) {
assert.True(t, rt.IsComplexObject)
assert.False(t, rt.IsMap)
assert.Equal(t, "models.TheModel", rt.GoType)
assert.Equal(t, "object", rt.SwaggerType)
}
}
sch := new(spec.Schema)
rt, err := resolver.ResolveSchema(sch, true)
if assert.NoError(t, err) {
assert.True(t, rt.IsMap)
assert.False(t, rt.IsComplexObject)
assert.Equal(t, "map[string]interface{}", rt.GoType)
assert.Equal(t, "object", rt.SwaggerType)
}
sch = new(spec.Schema)
var sp spec.Schema
sp.Typed("object", "")
sch.AllOf = []spec.Schema{sp}
rt, err = resolver.ResolveSchema(sch, true)
if assert.NoError(t, err) {
assert.True(t, rt.IsComplexObject)
assert.False(t, rt.IsMap)
assert.Equal(t, "models.TheModel", rt.GoType)
assert.Equal(t, "object", rt.SwaggerType)
}
}
}