Skip to content

Commit

Permalink
Add missing generated code to support export of maps of strings. (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks committed Apr 5, 2022
1 parent 44c9037 commit 563c490
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion generate-gnostic/generate-compiler.go
Expand Up @@ -843,7 +843,12 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam
}
code.PrintIf(!isRequired, "}")
} else if propertyModel.MapType == "string" {
code.Print("// %+v", propertyModel)
code.Print("if m.%s != nil {", propertyModel.FieldName())
code.Print("for _, item := range m.%s {", propertyModel.FieldName())
code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))")
code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Value))")
code.Print("}")
code.Print("}")
} else if propertyModel.MapType != "" {
code.Print("if m.%s != nil {", propertyModel.FieldName())
code.Print("for _, item := range m.%s {", propertyModel.FieldName())
Expand Down
7 changes: 6 additions & 1 deletion openapiv2/OpenAPIv2.go
Expand Up @@ -7887,7 +7887,12 @@ func (m *Oauth2Scopes) ToRawInfo() *yaml.Node {
if m == nil {
return info
}
// &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:}
if m.AdditionalProperties != nil {
for _, item := range m.AdditionalProperties {
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Value))
}
}
return info
}

Expand Down
7 changes: 6 additions & 1 deletion openapiv3/OpenAPIv3.go
Expand Up @@ -8560,7 +8560,12 @@ func (m *Strings) ToRawInfo() *yaml.Node {
if m == nil {
return info
}
// &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:}
if m.AdditionalProperties != nil {
for _, item := range m.AdditionalProperties {
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Value))
}
}
return info
}

Expand Down

0 comments on commit 563c490

Please sign in to comment.