Skip to content

Commit

Permalink
Exclude unexported fields from JSON schema (#3191)
Browse files Browse the repository at this point in the history
Ignore fields contained in structs with JSON name "-" from the generated JSON schema.
  • Loading branch information
ryantse authored Jun 2, 2021
1 parent 4f1ab4b commit 0bc87c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Fix #3126: a KubernetesClientException will be thrown from patch/replace rather than a null being returned when the item does not exist
* Fix #3121: ServiceOperationImpl replace will throw a KubernetesClientException rather than a NPE if the item doesn't exist
* Fix #3189: VersionInfo contains null data in OpenShift 4.6
* Fix #3190: Ignore fields with name "-" when using the Go to JSON schema generator

#### Improvements
* Fix #3149: replace(item) will consult the item's resourceVersion for the first PUT attempt when not specifically locked on a resourceVersion
Expand Down
3 changes: 3 additions & 0 deletions generator/pkg/schemagen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ func (g *schemaGenerator) getStructProperties(t reflect.Type) map[string]JSONPro
fieldList := g.getFields(t)
for _, field := range fieldList {
jsonName := g.jsonFieldName(field)
if jsonName == "-" {
continue
}
result[jsonName] = g.propertyDescriptor(field, t)
}

Expand Down

0 comments on commit 0bc87c2

Please # to comment.