本文整理匯總了Golang中github.com/cloudwan/gohan/schema.Schema.JSON方法的典型用法代碼示例。如果您正苦於以下問題:Golang Schema.JSON方法的具體用法?Golang Schema.JSON怎麽用?Golang Schema.JSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudwan/gohan/schema.Schema
的用法示例。
在下文中一共展示了Schema.JSON方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetSchema
//GetSchema returns the schema filtered and trimmed for a specific user or nil when the user shouldn't see it at all
func GetSchema(s *schema.Schema, authorization schema.Authorization) (result *schema.Resource, err error) {
manager := schema.GetManager()
metaschema, _ := manager.Schema("schema")
policy, _ := manager.PolicyValidate("read", s.GetPluralURL(), authorization)
if policy == nil {
return
}
if s.IsAbstract() {
return
}
rawSchema := s.JSON()
filteredSchema := util.ExtendMap(nil, s.JSONSchema)
rawSchema["schema"] = filteredSchema
schemaProperties, schemaPropertiesOrder, schemaRequired := policy.FilterSchema(
util.MaybeMap(s.JSONSchema["properties"]),
util.MaybeStringList(s.JSONSchema["propertiesOrder"]),
util.MaybeStringList(s.JSONSchema["required"]))
filteredSchema["properties"] = schemaProperties
filteredSchema["propertiesOrder"] = schemaPropertiesOrder
filteredSchema["required"] = schemaRequired
result, err = schema.NewResource(metaschema, rawSchema)
if err != nil {
log.Warning("%s %s", result, err)
return
}
return
}