diff --git a/pkg/configuration/configuration.go b/pkg/configuration/configuration.go index 6874a7e..8228c63 100644 --- a/pkg/configuration/configuration.go +++ b/pkg/configuration/configuration.go @@ -141,7 +141,7 @@ type Argument struct { Default interface{} `yaml:"default,omitempty"` // Schema is a JSON schema, in YAML, for the argument. - Schema map[string]interface{} `yaml:"schema"` + Schema map[string]any `yaml:"schema"` // From is a reference to an argument in another module, if this is // set, all other fields are ignored and instead the module referenced diff --git a/schemas/manifest.jsonschema.json b/schemas/manifest.jsonschema.json index 4b06ee7..16e5305 100644 --- a/schemas/manifest.jsonschema.json +++ b/schemas/manifest.jsonschema.json @@ -17,7 +17,7 @@ "description": "Default is the default value for this argument if it's not set.\nThis cannot be set when required is true." }, "schema": { - "type": "object", + "$ref": "https://json-schema.org/draft-07/schema#", "description": "Schema is a JSON schema, in YAML, for the argument." }, "from": { diff --git a/schemas/stencil.jsonschema.json b/schemas/stencil.jsonschema.json index 002c56f..1888016 100644 --- a/schemas/stencil.jsonschema.json +++ b/schemas/stencil.jsonschema.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft-07/schema#", "$id": "https://go.rgst.io/stencil/pkg/configuration/manifest", "$ref": "#/$defs/Manifest", "$defs": { diff --git a/tools/schemagen/schemagen.go b/tools/schemagen/schemagen.go index c78aba4..641dc32 100644 --- a/tools/schemagen/schemagen.go +++ b/tools/schemagen/schemagen.go @@ -62,6 +62,18 @@ func main() { // VSCode doesn't handle above draft-07 right now, so we force it. schema.Version = "https://json-schema.org/draft-07/schema#" + // Apply manifest-specific overrides. + if s.FileName == "manifest" { + subSchema, ok := schema.Definitions["Argument"].Properties.Get("schema") + if !ok { + fmt.Println("failed to update schema property for manifest to include $ref") + os.Exit(1) + } + + subSchema.Ref = schema.Version + subSchema.Type = "" // Don't set type. + } + b, err := schema.MarshalJSON() if err != nil { fmt.Printf("error generating schema for %s: %v\n", s.FileName, err)