Skip to content

Commit 47f3978

Browse files
authored
fix: handling of "additionalProperties: true" (#77)
Signed-off-by: roee88 <roee88@gmail.com>
1 parent 339d2b0 commit 47f3978

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

example/crds/example.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ spec:
1818
schema:
1919
openAPIV3Schema:
2020
properties:
21+
arbitrary:
22+
description: arbitrary field
23+
type: object
24+
additionalProperties: true
25+
default: {}
2126
messages:
2227
items:
2328
additionalProperties:

example/output.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ Resource Types:
4949
<td>object</td>
5050
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
5151
<td>true</td>
52+
</tr><tr>
53+
<td><b>arbitrary</b></td>
54+
<td>map[string]string</td>
55+
<td>
56+
arbitrary field<br/>
57+
<br/>
58+
<i>Default</i>: map[]<br/>
59+
</td>
60+
<td>false</td>
5261
</tr><tr>
5362
<td><b><a href="#examplemessagesindexkey">messages</a></b></td>
5463
<td>[]map[string]object</td>

pkg/builder/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func getTypeName(props *apiextensions.JSONSchemaProps) string {
220220

221221
// map
222222
if props.Type == "object" && props.AdditionalProperties != nil {
223-
if props.AdditionalProperties.Schema == nil && props.AdditionalItems.Allows {
223+
if props.AdditionalProperties.Schema == nil && props.AdditionalProperties.Allows {
224224
return "map[string]string"
225225
}
226226
return "map[string]"

0 commit comments

Comments
 (0)