9
9
"github.com/atombender/go-jsonschema/pkg/schemas"
10
10
)
11
11
12
- var errCannotSupportMultipleTypesForAdditionalProperties = errors .New ("cannot support multiple types for additional properties" )
12
+ var errTooManyTypesForAdditionalProperties = errors .New ("cannot support multiple types for additional properties" )
13
13
14
14
type schemaGenerator struct {
15
15
* Generator
@@ -535,10 +535,10 @@ func (g *schemaGenerator) generateStructType(
535
535
structType .AddField (structField )
536
536
}
537
537
538
- // checking .Not here because `false` is unmarshalled to .Not = Type{}
538
+ // Checking .Not here because `false` is unmarshalled to .Not = Type{}.
539
539
if t .AdditionalProperties != nil && t .AdditionalProperties .Not == nil {
540
540
if len (t .AdditionalProperties .Type ) > 1 {
541
- return nil , errCannotSupportMultipleTypesForAdditionalProperties
541
+ return nil , errTooManyTypesForAdditionalProperties
542
542
}
543
543
544
544
var (
@@ -554,30 +554,35 @@ func (g *schemaGenerator) generateStructType(
554
554
KeyType : codegen.PrimitiveType {Type : "string" },
555
555
ValueType : codegen.PrimitiveType {Type : "string" },
556
556
}
557
+
557
558
case schemas .TypeNameArray :
558
559
defaultValue = map [string ][]any {}
559
560
fieldType = codegen.MapType {
560
561
KeyType : codegen.PrimitiveType {Type : "string" },
561
562
ValueType : codegen.ArrayType {Type : codegen.EmptyInterfaceType {}},
562
563
}
564
+
563
565
case schemas .TypeNameNumber :
564
566
defaultValue = map [string ]float64 {}
565
567
fieldType = codegen.MapType {
566
568
KeyType : codegen.PrimitiveType {Type : "string" },
567
569
ValueType : codegen.PrimitiveType {Type : "float64" },
568
570
}
571
+
569
572
case schemas .TypeNameInteger :
570
573
defaultValue = map [string ]int {}
571
574
fieldType = codegen.MapType {
572
575
KeyType : codegen.PrimitiveType {Type : "string" },
573
576
ValueType : codegen.PrimitiveType {Type : "int" },
574
577
}
578
+
575
579
case schemas .TypeNameBoolean :
576
580
defaultValue = map [string ]bool {}
577
581
fieldType = codegen.MapType {
578
582
KeyType : codegen.PrimitiveType {Type : "string" },
579
583
ValueType : codegen.PrimitiveType {Type : "bool" },
580
584
}
585
+
581
586
default :
582
587
defaultValue = map [string ]any {}
583
588
fieldType = codegen.MapType {
0 commit comments