Skip to content

Commit e1f5e42

Browse files
committed
Version: 1.2: Updated based on feedback
1 parent ce91c22 commit e1f5e42

File tree

1 file changed

+5
-3
lines changed
  • Sources/swift-openapi-generator/Documentation.docc/Proposals

1 file changed

+5
-3
lines changed

Sources/swift-openapi-generator/Documentation.docc/Proposals/SOAR-0013.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Introduce an alternative naming strategy for more idiomatic Swift identifiers, i
1010
- Versions:
1111
- v1.0 (2024-11-27): Initial version
1212
- v1.1 (2024-11-28): Also handle "/", "{", and "}" for better synthesized operation names
13+
- v1.2 (2024-12-10): Treat "/" as a word separator and improve handling of the lowercasing of acronyms at the start of an identifier.
1314
- Issues:
1415
- [apple/swift-openapi-generator#112][issuePlugin]
1516
- [apple/swift-openapi-generator#107][issue1]
@@ -57,7 +58,7 @@ For clarity, we'll refer to the existing naming strategy as the "defensive" nami
5758

5859
Part of the new strategy is adjusting the capitalization, and producing `UpperCamelCase` names for types, and `lowerCamelCase` names for members, as is common in hand-written Swift code.
5960

60-
After attempting to produce an more idiomatic identifier, this strategy will fall back to the defensive strategy, to replace any remaining invalid symbols.
61+
This strategy will fall back to the defensive strategy if it encounters any invalid symbols in the identifier.
6162

6263
The second feature introduced as part of this proposal is a way to provide a string -> string map to fully override only specific OpenAPI names and provide their exact Swift identifiers. This is the ultimate escape hatch when both naming strategies fail to provide the desired result for the adopter.
6364

@@ -77,7 +78,8 @@ To get a sense for the proposed change, check out the table below that compares
7778
| `version 2.0` | `version_space_2_period_0` | `Version2_0` | `version2_0` |
7879
| `naïve café` | `naïve_space_café` | `NaïveCafé` | `naïveCafé` |
7980
| `__user` | `__user` | `__User` | `__user` |
80-
| `get/pets/{petId}` _Added in v1.1_ | `get_sol_pets_sol__lcub_petId_rcub_` | `Get_pets_petId` | `get_pets_petId` |
81+
| `get/pets/{petId}` _Changed in v1.2_ | `get_sol_pets_sol__lcub_petId_rcub_` | `GetPetsPetId` | `getPetsPetId` |
82+
| `HTTPProxy` _Added in v1.2_ | `HTTPProxy` | `HTTPProxy` | `httpProxy` |
8183
| `order#123` | `order_num_123` | `order_num_123` | `order_num_123` |
8284

8385
Notice that in the last example, since the OpenAPI name contains the pound (`#`) character, the idiomatic naming strategy falls back to the defensive naming strategy. In all the other cases, however, the resulting names are more idiomatic Swift identifiers.
@@ -100,7 +102,7 @@ The idiomatic naming strategy (check out the current code [here][impl], look for
100102
- dashes (`-`, ASCII: `0x2d`)
101103
- underscores (`_`, ASCII: `0x5f`)
102104
- spaces (` `, ASCII: `0x20`)
103-
- slashes (`/`, ASCII: `0x2f`) _Added in v1.1_
105+
- slashes (`/`, ASCII: `0x2f`) _Added in v1.1, changed meaning in 1.2_
104106
- curly braces (`{` and `}`, ASCII: `0x7b` and `0x7d`) _Added in v1.1_
105107

106108
> Note: We let [`Swift.String.isLetter`](https://developer.apple.com/documentation/swift/character/isletter) decide whether a character is a letter, which has the advantage of including letters in the non-ASCII range. Swift identifiers also support a [wide range](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#Identifiers) of alphanumeric characters.

0 commit comments

Comments
 (0)