serverURLEnumKeys returns deterministic identifier suffixes for each enum value of `v`, in `v.Enum` order. Each suffix is just the value with its first character upper-cased — matching what the previous template-only path produced for happy-path specs (` `), so adopters with
(v *openapi3.ServerVariable)
| 184 | // correctness improvement, not a naming change for any spec that |
| 185 | // actually compiled before. |
| 186 | func serverURLEnumKeys(v *openapi3.ServerVariable) []string { |
| 187 | keys := make([]string, len(v.Enum)) |
| 188 | seen := make(map[string]int, len(v.Enum)) |
| 189 | for i, val := range v.Enum { |
| 190 | base := UppercaseFirstCharacter(val) |
| 191 | if n, dup := seen[base]; dup { |
| 192 | keys[i] = base + strconv.Itoa(n) |
| 193 | seen[base] = n + 1 |
| 194 | } else { |
| 195 | keys[i] = base |
| 196 | seen[base] = 1 |
| 197 | } |
| 198 | } |
| 199 | return keys |
| 200 | } |
| 201 | |
| 202 | // serverURLEnumValues returns the EnumValues map handed to GenerateEnums |
| 203 | // for variable `v`: key is the deduplicated identifier suffix from |
no test coverage detected
searching dependent graphs…