Skip to content

Commit

Permalink
chore: add option to skip properties for a node
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Jul 11, 2024
1 parent e56893d commit 9f8be71
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Schema struct {
ReadOnly bool `json:"readOnly,omitempty"`
Default interface{} `json:"default,omitempty"`
AdditionalProperties *bool `json:"additionalProperties"`
SkipProperties bool `json:"skipProperties,omitempty"`
ID string `json:"$id,omitempty"`
}

Expand Down Expand Up @@ -126,6 +127,10 @@ func processComment(schema *Schema, comment string) (isRequired bool) {
if v, err := strconv.ParseFloat(value, 64); err == nil {
schema.Maximum = &v
}
case "skipProperties":
if v, err := strconv.ParseBool(value); err == nil {
schema.SkipProperties = v

Check warning on line 132 in pkg/schema.go

View check run for this annotation

Codecov / codecov/patch

pkg/schema.go#L130-L132

Added lines #L130 - L132 were not covered by tests
}
case "minimum":
if v, err := strconv.ParseFloat(value, 64); err == nil {
schema.Minimum = &v
Expand Down Expand Up @@ -246,6 +251,9 @@ func parseNode(keyNode *yaml.Node, valNode *yaml.Node) (*Schema, bool) {
}

propIsRequired := processComment(schema, getComment(keyNode, valNode))
if schema.SkipProperties {
schema.Properties = nil

Check warning on line 255 in pkg/schema.go

View check run for this annotation

Codecov / codecov/patch

pkg/schema.go#L255

Added line #L255 was not covered by tests
}

return schema, propIsRequired
}

0 comments on commit 9f8be71

Please sign in to comment.