本文整理汇总了Golang中github.com/vikstrous/go-swagger/spec.Schema.AddExtension方法的典型用法代码示例。如果您正苦于以下问题:Golang Schema.AddExtension方法的具体用法?Golang Schema.AddExtension怎么用?Golang Schema.AddExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vikstrous/go-swagger/spec.Schema
的用法示例。
在下文中一共展示了Schema.AddExtension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestTypeResolver_BasicTypes
func TestTypeResolver_BasicTypes(t *testing.T) {
_, resolver, err := basicTaskListResolver(t)
if assert.NoError(t, err) {
// primitives and string formats
for _, val := range schTypeVals {
sch := new(spec.Schema)
sch.Typed(val.Type, val.Format)
rt, err := resolver.ResolveSchema(sch, true)
if assert.NoError(t, err) {
assert.False(t, rt.IsNullable)
assertPrimitiveResolve(t, val.Type, val.Format, val.Expected, rt)
}
}
// arrays of primitives and string formats
for _, val := range schTypeVals {
var sch spec.Schema
sch.Typed(val.Type, val.Format)
rt, err := resolver.ResolveSchema(new(spec.Schema).CollectionOf(sch), true)
if assert.NoError(t, err) {
assert.True(t, rt.IsArray)
}
}
// primitives and string formats
for _, val := range schTypeVals {
sch := new(spec.Schema)
sch.Typed(val.Type, val.Format)
sch.Extensions = make(spec.Extensions)
sch.Extensions["x-isnullable"] = true
rt, err := resolver.ResolveSchema(sch, true)
if assert.NoError(t, err) {
assert.True(t, rt.IsNullable, "expected %q (%q) to be nullable", val.Type, val.Format)
assertPrimitiveResolve(t, val.Type, val.Format, val.Expected, rt)
}
}
// arrays of primitives and string formats
for _, val := range schTypeVals {
var sch spec.Schema
sch.Typed(val.Type, val.Format)
sch.AddExtension("x-isnullable", true)
rt, err := resolver.ResolveSchema(new(spec.Schema).CollectionOf(sch), true)
if assert.NoError(t, err) {
assert.True(t, rt.IsArray)
}
}
}
}