From 2c4ca55b1419782c89e335427e05195560e23369 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Thu, 19 Dec 2024 11:12:55 -0600 Subject: [PATCH] fix schema --- compiler/types/yaml/yaml/stage.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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