Skip to content
Permalink
Browse files
fix: jsonschema
very hacky, fixes #3238 for good

refs invopop/jsonschema#26

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Aug 18, 2022
1 parent aa12ad0 commit ce264f1fcae910ae4a8d4a4073687cf30f95e620
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
@@ -27,6 +27,7 @@ func newSchemaCmd() *schemaCmd {
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
schema := jsonschema.Reflect(&config.Project{})
schema.Definitions["FileInfo"] = jsonschema.Reflect(&config.FileInfo{})
schema.Description = "goreleaser configuration definition file"
bts, err := json.MarshalIndent(schema, " ", " ")
if err != nil {
@@ -427,18 +427,16 @@ type FileInfo struct {
MTime time.Time `yaml:"mtime,omitempty" json:"mtime,omitempty"`
}

// type alias to prevent stack overflow
type fileAlias File

// UnmarshalYAML is a custom unmarshaler that wraps strings in arrays.
func (f *File) UnmarshalYAML(unmarshal func(interface{}) error) error {
type t File
var str string
if err := unmarshal(&str); err == nil {
*f = File{Source: str}
return nil
}

var file fileAlias
var file t
if err := unmarshal(&file); err != nil {
return err
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce264f1

Please sign in to comment.