GenerateAdditionalPropertyBoilerplate generates all the glue code which provides the API for interacting with additional properties and JSON-ification
(t *template.Template, typeDefs []TypeDefinition)
| 1112 | // GenerateAdditionalPropertyBoilerplate generates all the glue code which provides |
| 1113 | // the API for interacting with additional properties and JSON-ification |
| 1114 | func GenerateAdditionalPropertyBoilerplate(t *template.Template, typeDefs []TypeDefinition) (string, error) { |
| 1115 | var filteredTypes []TypeDefinition |
| 1116 | |
| 1117 | m := map[string]bool{} |
| 1118 | |
| 1119 | for _, t := range typeDefs { |
| 1120 | if found := m[t.TypeName]; found { |
| 1121 | continue |
| 1122 | } |
| 1123 | |
| 1124 | m[t.TypeName] = true |
| 1125 | |
| 1126 | if t.Schema.HasAdditionalProperties { |
| 1127 | filteredTypes = append(filteredTypes, t) |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | context := struct { |
| 1132 | Types []TypeDefinition |
| 1133 | }{ |
| 1134 | Types: filteredTypes, |
| 1135 | } |
| 1136 | |
| 1137 | return GenerateTemplates([]string{"additional-properties.tmpl"}, t, context) |
| 1138 | } |
| 1139 | |
| 1140 | func GenerateUnionBoilerplate(t *template.Template, typeDefs []TypeDefinition) (string, error) { |
| 1141 | var filteredTypes []TypeDefinition |
no test coverage detected