@@ -215,28 +215,36 @@ func (b *APIs) parsePrimitiveValidation(t *types.Type, found sets.String, commen
215
215
return props , buff .String ()
216
216
}
217
217
218
+ type mapTempateArgs struct {
219
+ Result string
220
+ SkipMap bool
221
+ }
222
+
218
223
var mapTemplate = template .Must (template .New ("map-template" ).Parse (
219
224
`v1beta1.JSONSchemaProps{
220
225
Type: "object",
221
- AdditionalProperties: &v1beta1.JSONSchemaPropsOrBool{
226
+ {{if not .SkipMap}} AdditionalProperties: &v1beta1.JSONSchemaPropsOrBool{
222
227
Allows: true,
223
- // Schema: &{{.}},
224
- },
228
+ Schema: &{{.Result }},
229
+ },{{end}}
225
230
}` ))
226
231
227
232
// parseMapValidation returns a JSONSchemaProps object and its serialization in
228
233
// Go that describe the validations for the given map type.
229
234
func (b * APIs ) parseMapValidation (t * types.Type , found sets.String , comments []string ) (v1beta1.JSONSchemaProps , string ) {
230
- additionalProps , _ := b .typeToJSONSchemaProps (t .Elem , found , comments )
235
+ additionalProps , result := b .typeToJSONSchemaProps (t .Elem , found , comments )
231
236
props := v1beta1.JSONSchemaProps {
232
237
Type : "object" ,
233
- AdditionalProperties : & v1beta1.JSONSchemaPropsOrBool {
238
+ }
239
+ parseOption := b .arguments .CustomArgs .(* ParseOptions )
240
+ if ! parseOption .SkipMap {
241
+ props .AdditionalProperties = & v1beta1.JSONSchemaPropsOrBool {
234
242
Allows : true ,
235
- Schema : & additionalProps },
243
+ Schema : & additionalProps }
236
244
}
237
245
238
246
buff := & bytes.Buffer {}
239
- if err := mapTemplate .Execute (buff , "" ); err != nil {
247
+ if err := mapTemplate .Execute (buff , mapTempateArgs { result , parseOption . SkipMap } ); err != nil {
240
248
log .Fatalf ("%v" , err )
241
249
}
242
250
return props , buff .String ()
0 commit comments