Skip to content

Commit

Permalink
fix: jsonschema
Browse files Browse the repository at this point in the history
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 ce264f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/schema.go
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions pkg/config/config.go
Expand Up @@ -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
}
Expand Down
26 changes: 26 additions & 0 deletions www/docs/static/schema.json

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.