schema: expose InUse and Description.
This commit is contained in:
@@ -18,12 +18,12 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const DefaultSchemaURL = "https://raw.githubusercontent.com/nostr-protocol/registry-of-kinds/daaa3a2a5573606aa0a4c4a98c25460ea9a1e388/schema.yaml"
|
||||
const DefaultSchemaURL = "https://raw.githubusercontent.com/nostr-protocol/registry-of-kinds/fa6e1bedc2d499eb01e716183089214e26a52877/schema.yaml"
|
||||
|
||||
// this is used by hex.Decode in the "hex" validator -- we don't care about data races
|
||||
var hexdummydecoder = make([]byte, 128)
|
||||
|
||||
func fetchSchemaFromURL(schemaURL string) (Schema, error) {
|
||||
func FetchSchemaFromURL(schemaURL string) (Schema, error) {
|
||||
resp, err := http.Get(schemaURL)
|
||||
if err != nil {
|
||||
return Schema{}, fmt.Errorf("failed to fetch schema from URL: %w", err)
|
||||
@@ -50,9 +50,11 @@ type Schema struct {
|
||||
}
|
||||
|
||||
type KindSchema struct {
|
||||
Content nextSpec `yaml:"content"`
|
||||
Required []string `yaml:"required"`
|
||||
Tags []tagSpec `yaml:"tags"`
|
||||
Description string `yaml:"description"`
|
||||
InUse bool `yaml:"in_use"`
|
||||
Content nextSpec `yaml:"content"`
|
||||
Required []string `yaml:"required"`
|
||||
Tags []tagSpec `yaml:"tags"`
|
||||
}
|
||||
|
||||
type tagSpec struct {
|
||||
@@ -187,7 +189,7 @@ func NewValidatorFromFile(filename string) (Validator, error) {
|
||||
}
|
||||
|
||||
func NewValidatorFromURL(schemaURL string) (Validator, error) {
|
||||
schema, err := fetchSchemaFromURL(schemaURL)
|
||||
schema, err := FetchSchemaFromURL(schemaURL)
|
||||
if err != nil {
|
||||
return Validator{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user