Skip to content

Commit

Permalink
fix(jsonschema): allow string as tags type
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Jan 9, 2025
1 parent cfa688f commit 8ba7eaa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 0 additions & 3 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"github.com/evilmartians/lefthook/internal/lefthook"
)

////go:embed schema.json
// var jsonSchema []byte

type validate struct{}

func (validate) New(opts *lefthook.Options) *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions internal/config/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type Command struct {
Run string `json:"run" mapstructure:"run" toml:"run" yaml:"run"`
Files string `json:"files,omitempty" mapstructure:"files" toml:"files,omitempty" yaml:",omitempty"`

Skip interface{} `json:"skip,omitempty" jsonschema:"oneof_type=boolean;array" mapstructure:"skip" toml:"skip,omitempty,inline" yaml:",omitempty"`
Only interface{} `json:"only,omitempty" jsonschema:"oneof_type=boolean;array" mapstructure:"only" toml:"only,omitempty,inline" yaml:",omitempty"`
Tags []string `json:"tags,omitempty" mapstructure:"tags" toml:"tags,omitempty" yaml:",omitempty"`
Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"`
Skip interface{} `json:"skip,omitempty" jsonschema:"oneof_type=boolean;array" mapstructure:"skip" toml:"skip,omitempty,inline" yaml:",omitempty"`
Only interface{} `json:"only,omitempty" jsonschema:"oneof_type=boolean;array" mapstructure:"only" toml:"only,omitempty,inline" yaml:",omitempty"`
Tags []string `json:"tags,omitempty" jsonschema:"oneof_type=string;array" mapstructure:"tags" toml:"tags,omitempty" yaml:",omitempty"`
Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"`

FileTypes []string `json:"file_types,omitempty" koanf:"file_types" mapstructure:"file_types" toml:"file_types,omitempty" yaml:"file_types,omitempty"`

Expand Down
4 changes: 2 additions & 2 deletions internal/config/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type Job struct {
Files string `json:"files,omitempty" mapstructure:"files" toml:"files,omitempty" yaml:",omitempty"`
FailText string `json:"fail_text,omitempty" koanf:"fail_text" mapstructure:"fail_text" toml:"fail_text,omitempty" yaml:"fail_text,omitempty"`

Tags []string `json:"tags,omitempty" mapstructure:"tags" toml:"tags,omitempty" yaml:",omitempty"`
FileTypes []string `json:"file_types,omitempty" koanf:"file_types" mapstructure:"file_types" toml:"file_types,omitempty" yaml:"file_types,omitempty"`
Tags []string `json:"tags,omitempty" jsonschema:"oneof_type=array" mapstructure:"tags" toml:"tags,omitempty" yaml:",omitempty"`
FileTypes []string `json:"file_types,omitempty" koanf:"file_types" mapstructure:"file_types" toml:"file_types,omitempty" yaml:"file_types,omitempty"`

Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"`

Expand Down
19 changes: 15 additions & 4 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
]
},
"tags": {
"oneOf": [
{
"type": "string"
},
{
"type": "array"
}
],
"items": {
"type": "string"
},
"type": "array"
}
},
"env": {
"additionalProperties": {
Expand Down Expand Up @@ -219,10 +226,14 @@
"type": "string"
},
"tags": {
"oneOf": [
{
"type": "array"
}
],
"items": {
"type": "string"
},
"type": "array"
}
},
"file_types": {
"items": {
Expand Down

0 comments on commit 8ba7eaa

Please sign in to comment.