本文整理匯總了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)
}
}
}
}