本文整理汇总了Golang中github.com/vikstrous/go-swagger/spec.Schema.Items方法的典型用法代码示例。如果您正苦于以下问题:Golang Schema.Items方法的具体用法?Golang Schema.Items怎么用?Golang Schema.Items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vikstrous/go-swagger/spec.Schema
的用法示例。
在下文中一共展示了Schema.Items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestTypeResolver_AdditionalItems
func TestTypeResolver_AdditionalItems(t *testing.T) {
_, resolver, err := basicTaskListResolver(t)
tpe := spec.StringProperty()
if assert.NoError(t, err) {
// arrays of primitives and string formats with additional formats
for _, val := range schTypeVals {
var sch spec.Schema
sch.Typed(val.Type, val.Format)
var coll spec.Schema
coll.Type = []string{"array"}
coll.Items = new(spec.SchemaOrArray)
coll.Items.Schema = tpe
coll.AdditionalItems = new(spec.SchemaOrBool)
coll.AdditionalItems.Schema = &sch
rt, err := resolver.ResolveSchema(&coll, true)
if assert.NoError(t, err) && assert.True(t, rt.IsArray) {
assert.True(t, rt.HasAdditionalItems)
assert.False(t, rt.IsNullable)
//if assert.NotNil(t, rt.ElementType) {
//assertPrimitiveResolve(t, "string", "", "string", *rt.ElementType)
//}
}
}
}
}
示例2: TestTypeResolver_TupleTypes
func TestTypeResolver_TupleTypes(t *testing.T) {
_, resolver, err := basicTaskListResolver(t)
if assert.NoError(t, err) {
// tuple type (items with multiple schemas)
parent := new(spec.Schema)
parent.Typed("array", "")
parent.Items = new(spec.SchemaOrArray)
parent.Items.Schemas = append(
parent.Items.Schemas,
*spec.StringProperty(),
*spec.Int64Property(),
*spec.Float64Property(),
*spec.BoolProperty(),
*spec.ArrayProperty(spec.StringProperty()),
*spec.RefProperty("#/definitions/Comment"),
)
rt, err := resolver.ResolveSchema(parent, true)
if assert.NoError(t, err) {
assert.False(t, rt.IsArray)
assert.True(t, rt.IsTuple)
}
}
}