You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/swift-openapi-generator/Documentation.docc/Proposals/SOAR-0013.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Introduce an alternative naming strategy for more idiomatic Swift identifiers, i
10
10
- Versions:
11
11
- v1.0 (2024-11-27): Initial version
12
12
- 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.
13
14
- Issues:
14
15
-[apple/swift-openapi-generator#112][issuePlugin]
15
16
-[apple/swift-openapi-generator#107][issue1]
@@ -57,7 +58,7 @@ For clarity, we'll refer to the existing naming strategy as the "defensive" nami
57
58
58
59
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.
59
60
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.
61
62
62
63
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.
63
64
@@ -77,7 +78,8 @@ To get a sense for the proposed change, check out the table below that compares
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
100
102
- dashes (`-`, ASCII: `0x2d`)
101
103
- underscores (`_`, ASCII: `0x5f`)
102
104
- spaces (``, ASCII: `0x20`)
103
-
- slashes (`/`, ASCII: `0x2f`) _Added in v1.1_
105
+
- slashes (`/`, ASCII: `0x2f`) _Added in v1.1, changed meaning in 1.2_
104
106
- curly braces (`{` and `}`, ASCII: `0x7b` and `0x7d`) _Added in v1.1_
105
107
106
108
> 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