Skip to content

Commit

Permalink
fix: use draft 7
Browse files Browse the repository at this point in the history
  • Loading branch information
dadav committed Sep 14, 2023
1 parent 2a6d149 commit cf37aea
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The first files found will be read and a jsonschema will be created.
For every dependency defined in the Chart.yaml file, a reference to the dependencies jsonschema
will be created.

The tool uses jsonschema `draft/2020-12`.
The tool uses jsonschema Draft 7, because the library helm uses only supports that version.

## Installation

Expand Down
70 changes: 35 additions & 35 deletions pkg/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,40 @@ type SchemaOrBool interface{}

// Schema struct contains yaml tags for reading, json for writing (creating the jsonschema)
type Schema struct {
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Default interface{} `yaml:"default,omitempty" json:"default,omitempty"`
Properties map[string]*Schema `yaml:"properties,omitempty" json:"properties,omitempty"`
Pattern string `yaml:"pattern,omitempty" json:"pattern,omitempty"`
Format string `yaml:"format,omitempty" json:"format,omitempty"`
Required bool `yaml:"required,omitempty" json:"-"`
Deprecated bool `yaml:"deprecated,omitempty" json:"deprecated,omitempty"`
Items *Schema `yaml:"items,omitempty" json:"items,omitempty"`
PrefixedItems []*Schema `yaml:"prefixedItems,omitempty" json:"prefixedItems,omitempty"`
Enum []string `yaml:"enum,omitempty" json:"enum,omitempty"`
Const string `yaml:"const,omitempty" json:"const,omitempty"`
Examples []string `yaml:"examples,omitempty" json:"examples,omitempty"`
Minimum *int `yaml:"minimum,omitempty" json:"minimum,omitempty"`
Maximum *int `yaml:"maximum,omitempty" json:"maximum,omitempty"`
ExclusiveMinimum *int `yaml:"exclusiveMinimum,omitempty" json:"exclusiveMinimum,omitempty"`
ExclusiveMaximum *int `yaml:"exclusiveMaximum,omitempty" json:"exclusiveMaximum,omitempty"`
MultipleOf *int `yaml:"multipleOf,omitempty" json:"multipleOf,omitempty"`
AdditionalProperties SchemaOrBool `yaml:"additionalProperties,omitempty" json:"additionalProperties,omitempty"`
PatternProperties map[string]*Schema `yaml:"patternProperties,omitempty" json:"patternProperties,omitempty"`
RequiredProperties []string `yaml:"-" json:"required,omitempty"`
UnevaluatedProperties SchemaOrBool `yaml:"unevaluatedProperties,omitempty" json:"unevaluatedProperties,omitempty"`
UnevaluatedItems SchemaOrBool `yaml:"unevaluatedItems,omitempty" json:"unevaluatedItems,omitempty"`
AnyOf []*Schema `yaml:"anyOf,omitempty" json:"anyOf,omitempty"`
OneOf []*Schema `yaml:"oneOf,omitempty" json:"oneOf,omitempty"`
AllOf []*Schema `yaml:"allOf,omitempty" json:"allOf,omitempty"`
If *Schema `yaml:"if,omitempty" json:"if,omitempty"`
Then *Schema `yaml:"then,omitempty" json:"then,omitempty"`
Else *Schema `yaml:"else,omitempty" json:"else,omitempty"`
HasData bool `yaml:"-" json:"-"`
Ref string `yaml:"$ref,omitempty" json:"$ref,omitempty"`
Schema string `yaml:"$schema,omitempty" json:"$schema,omitempty"`
Id string `yaml:"$id,omitempty" json:"$id,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Default interface{} `yaml:"default,omitempty" json:"default,omitempty"`
Properties map[string]*Schema `yaml:"properties,omitempty" json:"properties,omitempty"`
Pattern string `yaml:"pattern,omitempty" json:"pattern,omitempty"`
Format string `yaml:"format,omitempty" json:"format,omitempty"`
// Required is not specified in jsonschema. We use this value to compute the requiredProperties
// value
Required bool `yaml:"required,omitempty" json:"-"`
Deprecated bool `yaml:"deprecated,omitempty" json:"deprecated,omitempty"`
Items *Schema `yaml:"items,omitempty" json:"items,omitempty"`
Enum []string `yaml:"enum,omitempty" json:"enum,omitempty"`
Const string `yaml:"const,omitempty" json:"const,omitempty"`
Examples []string `yaml:"examples,omitempty" json:"examples,omitempty"`
Minimum *int `yaml:"minimum,omitempty" json:"minimum,omitempty"`
Maximum *int `yaml:"maximum,omitempty" json:"maximum,omitempty"`
ExclusiveMinimum *int `yaml:"exclusiveMinimum,omitempty" json:"exclusiveMinimum,omitempty"`
ExclusiveMaximum *int `yaml:"exclusiveMaximum,omitempty" json:"exclusiveMaximum,omitempty"`
MultipleOf *int `yaml:"multipleOf,omitempty" json:"multipleOf,omitempty"`
AdditionalProperties SchemaOrBool `yaml:"additionalProperties,omitempty" json:"additionalProperties,omitempty"`
PatternProperties map[string]*Schema `yaml:"patternProperties,omitempty" json:"patternProperties,omitempty"`
// Computed from Required value
RequiredProperties []string `yaml:"-" json:"required,omitempty"`
AnyOf []*Schema `yaml:"anyOf,omitempty" json:"anyOf,omitempty"`
OneOf []*Schema `yaml:"oneOf,omitempty" json:"oneOf,omitempty"`
AllOf []*Schema `yaml:"allOf,omitempty" json:"allOf,omitempty"`
If *Schema `yaml:"if,omitempty" json:"if,omitempty"`
Then *Schema `yaml:"then,omitempty" json:"then,omitempty"`
Else *Schema `yaml:"else,omitempty" json:"else,omitempty"`
HasData bool `yaml:"-" json:"-"`
Ref string `yaml:"$ref,omitempty" json:"$ref,omitempty"`
Schema string `yaml:"$schema,omitempty" json:"$schema,omitempty"`
Id string `yaml:"$id,omitempty" json:"$id,omitempty"`
}

// Set sets the HasData field to true
Expand Down Expand Up @@ -306,7 +306,7 @@ func YamlToSchema(
requiredProperties := []string{}

schema.Type = "object"
schema.Schema = "http://json-schema.org/draft/2020-12/schema#"
schema.Schema = "http://json-schema.org/draft-07/schema#"
schema.Properties = YamlToSchema(
node.Content[0],
keepFullComment,
Expand Down

0 comments on commit cf37aea

Please sign in to comment.