diff --git a/compiler/types/yaml/yaml/stage.go b/compiler/types/yaml/yaml/stage.go index 5f9ba37ae..fdf6c4e3f 100644 --- a/compiler/types/yaml/yaml/stage.go +++ b/compiler/types/yaml/yaml/stage.go @@ -9,6 +9,7 @@ import ( "github.com/go-vela/server/compiler/types/pipeline" "github.com/go-vela/server/compiler/types/raw" + "github.com/invopop/jsonschema" ) type ( @@ -122,6 +123,22 @@ func (s StageSlice) MarshalYAML() (interface{}, error) { return output, nil } +// JSONSchemaExtend handles some overrides that need to be in place +// for this type for the jsonschema generation. +// +// Stages are not really a slice of stages to the user. This change +// supports the map they really are. +func (StageSlice) JSONSchemaExtend(schema *jsonschema.Schema) { + schema.AdditionalProperties = jsonschema.FalseSchema + schema.Items = nil + schema.PatternProperties = map[string]*jsonschema.Schema{ + ".*": { + Ref: "#/$defs/Stage", + }, + } + schema.Type = "object" +} + // MergeEnv takes a list of environment variables and attempts // to set them in the stage environment. If the environment // variable already exists in the stage, than this will