Bugfix: OpenAPI-gen was not generating extensions correctly
This commit is contained in:
parent
67a6c68d77
commit
6dd38a4350
@ -336,7 +336,11 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
|||||||
if len(required) > 0 {
|
if len(required) > 0 {
|
||||||
g.Do("Required: []string{\"$.$\"},\n", strings.Join(required, "\",\""))
|
g.Do("Required: []string{\"$.$\"},\n", strings.Join(required, "\",\""))
|
||||||
}
|
}
|
||||||
g.Do("},\n},\n", nil)
|
g.Do("},\n", nil)
|
||||||
|
if err := g.generateExtensions(t.CommentLines); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
g.Do("},\n", nil)
|
||||||
g.Do("Dependencies: []string{\n", args)
|
g.Do("Dependencies: []string{\n", args)
|
||||||
// Map order is undefined, sort them or we may get a different file generated each time.
|
// Map order is undefined, sort them or we may get a different file generated each time.
|
||||||
keys := []string{}
|
keys := []string{}
|
||||||
@ -353,11 +357,7 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
|||||||
}
|
}
|
||||||
g.Do("\"$.$\",", k)
|
g.Do("\"$.$\",", k)
|
||||||
}
|
}
|
||||||
g.Do("},\n", nil)
|
g.Do("},\n},\n", nil)
|
||||||
if err := g.generateExtensions(t.CommentLines); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.Do("},\n", nil)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ func (g openAPITypeWriter) generateExtensions(CommentLines []string) error {
|
|||||||
for _, val := range tagValues {
|
for _, val := range tagValues {
|
||||||
if strings.HasPrefix(val, tagExtensionPrefix) {
|
if strings.HasPrefix(val, tagExtensionPrefix) {
|
||||||
if !anyExtension {
|
if !anyExtension {
|
||||||
g.Do("spec.VendorExtensible: {\nExtensions: spec.Extensions{\n", nil)
|
g.Do("VendorExtensible: spec.VendorExtensible{\nExtensions: spec.Extensions{\n", nil)
|
||||||
anyExtension = true
|
anyExtension = true
|
||||||
}
|
}
|
||||||
parts := strings.SplitN(val, ":", 2)
|
parts := strings.SplitN(val, ":", 2)
|
||||||
|
@ -227,7 +227,7 @@ Format: "byte",
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"WithExtension": {
|
"WithExtension": {
|
||||||
spec.VendorExtensible: {
|
VendorExtensible: spec.VendorExtensible{
|
||||||
Extensions: spec.Extensions{
|
Extensions: spec.Extensions{
|
||||||
"x-kubernetes-member-tag": "member_test",
|
"x-kubernetes-member-tag": "member_test",
|
||||||
},
|
},
|
||||||
@ -241,15 +241,15 @@ Format: "",
|
|||||||
},
|
},
|
||||||
Required: []string{"String","Int64","Int32","Int16","Int8","Uint","Uint64","Uint32","Uint16","Uint8","Byte","Bool","Float64","Float32","ByteArray","WithExtension"},
|
Required: []string{"String","Int64","Int32","Int16","Int8","Uint","Uint64","Uint32","Uint16","Uint8","Byte","Bool","Float64","Float32","ByteArray","WithExtension"},
|
||||||
},
|
},
|
||||||
},
|
VendorExtensible: spec.VendorExtensible{
|
||||||
Dependencies: []string{
|
|
||||||
},
|
|
||||||
spec.VendorExtensible: {
|
|
||||||
Extensions: spec.Extensions{
|
Extensions: spec.Extensions{
|
||||||
"x-kubernetes-type-tag": "type_test",
|
"x-kubernetes-type-tag": "type_test",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Dependencies: []string{
|
||||||
|
},
|
||||||
|
},
|
||||||
`, buffer.String())
|
`, buffer.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user