Skip to content

Commit 9a338b1

Browse files
committed
Merge branch 'scala-sttp4-jsoniter' of https://github.com/lbialy/openapi-generator into lbialy-scala-sttp4-jsoniter
2 parents 2a556ff + 1a630aa commit 9a338b1

20 files changed

Lines changed: 2029 additions & 1 deletion
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
---
2+
title: Documentation for the scala-sttp4-jsoniter Generator
3+
---
4+
5+
## METADATA
6+
7+
| Property | Value | Notes |
8+
| -------- | ----- | ----- |
9+
| generator name | scala-sttp4-jsoniter | pass this to the generate command after -g |
10+
| generator stability | BETA | |
11+
| generator type | CLIENT | |
12+
| generator language | Scala | |
13+
| generator default templating engine | mustache | |
14+
| helpTxt | Generates a Scala client library (beta) based on Sttp4 and Jsoniter-Scala. | |
15+
16+
## CONFIG OPTIONS
17+
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
18+
19+
| Option | Description | Values | Default |
20+
| ------ | ----------- | ------ | ------- |
21+
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
22+
|apiPackage|package for generated api classes| |null|
23+
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|java8|
24+
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
25+
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
26+
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
27+
|jsoniterVersion|The version of jsoniter-scala library| |2.31.1|
28+
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
29+
|mainPackage|Top-level package name, which defines 'apiPackage', 'modelPackage', 'invokerPackage'| |org.openapitools.client|
30+
|modelPackage|package for generated models| |null|
31+
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
32+
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
33+
|separateErrorChannel|Whether to return response as F[Either[ResponseError[ErrorType], ReturnType]]] or to flatten response's error raising them through enclosing monad (F[ReturnType]).| |true|
34+
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
35+
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
36+
|sourceFolder|source folder for generated code| |null|
37+
|sttpClientVersion|The version of sttp client| |4.0.0-M19|
38+
39+
## IMPORT MAPPING
40+
41+
| Type/Alias | Imports |
42+
| ---------- | ------- |
43+
|Array|java.util.List|
44+
|ArrayList|java.util.ArrayList|
45+
|Date|java.util.Date|
46+
|DateTime|org.joda.time.*|
47+
|File|java.io.File|
48+
|HashMap|java.util.HashMap|
49+
|ListBuffer|scala.collection.mutable.ListBuffer|
50+
|ListSet|scala.collection.immutable.ListSet|
51+
|LocalDate|org.joda.time.*|
52+
|LocalDateTime|org.joda.time.*|
53+
|LocalTime|org.joda.time.*|
54+
|Seq|scala.collection.immutable.Seq|
55+
|Set|scala.collection.immutable.Set|
56+
|Timestamp|java.sql.Timestamp|
57+
|URI|java.net.URI|
58+
|UUID|java.util.UUID|
59+
60+
61+
## INSTANTIATION TYPES
62+
63+
| Type/Alias | Instantiated By |
64+
| ---------- | --------------- |
65+
|array|ListBuffer|
66+
|map|Map|
67+
|set|Set|
68+
69+
70+
## LANGUAGE PRIMITIVES
71+
72+
<ul class="column-ul">
73+
<li>Any</li>
74+
<li>Array</li>
75+
<li>Boolean</li>
76+
<li>Byte</li>
77+
<li>Double</li>
78+
<li>Float</li>
79+
<li>Int</li>
80+
<li>List</li>
81+
<li>Long</li>
82+
<li>Map</li>
83+
<li>Object</li>
84+
<li>Seq</li>
85+
<li>String</li>
86+
<li>boolean</li>
87+
</ul>
88+
89+
## RESERVED WORDS
90+
91+
<ul class="column-ul">
92+
<li>abstract</li>
93+
<li>case</li>
94+
<li>catch</li>
95+
<li>class</li>
96+
<li>clone</li>
97+
<li>def</li>
98+
<li>do</li>
99+
<li>else</li>
100+
<li>extends</li>
101+
<li>false</li>
102+
<li>final</li>
103+
<li>finally</li>
104+
<li>for</li>
105+
<li>forSome</li>
106+
<li>if</li>
107+
<li>implicit</li>
108+
<li>import</li>
109+
<li>lazy</li>
110+
<li>match</li>
111+
<li>new</li>
112+
<li>null</li>
113+
<li>object</li>
114+
<li>override</li>
115+
<li>package</li>
116+
<li>private</li>
117+
<li>protected</li>
118+
<li>return</li>
119+
<li>sealed</li>
120+
<li>super</li>
121+
<li>this</li>
122+
<li>throw</li>
123+
<li>trait</li>
124+
<li>true</li>
125+
<li>try</li>
126+
<li>type</li>
127+
<li>val</li>
128+
<li>var</li>
129+
<li>while</li>
130+
<li>with</li>
131+
<li>yield</li>
132+
</ul>
133+
134+
## FEATURE SET
135+
136+
137+
### Client Modification Feature
138+
| Name | Supported | Defined By |
139+
| ---- | --------- | ---------- |
140+
|BasePath|✓|ToolingExtension
141+
|Authorizations|✗|ToolingExtension
142+
|UserAgent|✓|ToolingExtension
143+
|MockServer|✗|ToolingExtension
144+
145+
### Data Type Feature
146+
| Name | Supported | Defined By |
147+
| ---- | --------- | ---------- |
148+
|Custom|✗|OAS2,OAS3
149+
|Int32|✓|OAS2,OAS3
150+
|Int64|✓|OAS2,OAS3
151+
|Float|✓|OAS2,OAS3
152+
|Double|✓|OAS2,OAS3
153+
|Decimal|✓|ToolingExtension
154+
|String|✓|OAS2,OAS3
155+
|Byte|✓|OAS2,OAS3
156+
|Binary|✓|OAS2,OAS3
157+
|Boolean|✓|OAS2,OAS3
158+
|Date|✓|OAS2,OAS3
159+
|DateTime|✓|OAS2,OAS3
160+
|Password|✓|OAS2,OAS3
161+
|File|✓|OAS2
162+
|Uuid||
163+
|Array|✓|OAS2,OAS3
164+
|Null|✗|OAS3
165+
|AnyType|✗|OAS2,OAS3
166+
|Object|✓|OAS2,OAS3
167+
|Maps|✓|ToolingExtension
168+
|CollectionFormat|✓|OAS2
169+
|CollectionFormatMulti|✓|OAS2
170+
|Enum|✓|OAS2,OAS3
171+
|ArrayOfEnum|✓|ToolingExtension
172+
|ArrayOfModel|✓|ToolingExtension
173+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
174+
|ArrayOfCollectionOfModel|✓|ToolingExtension
175+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
176+
|MapOfEnum|✓|ToolingExtension
177+
|MapOfModel|✓|ToolingExtension
178+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
179+
|MapOfCollectionOfModel|✓|ToolingExtension
180+
|MapOfCollectionOfEnum|✓|ToolingExtension
181+
182+
### Documentation Feature
183+
| Name | Supported | Defined By |
184+
| ---- | --------- | ---------- |
185+
|Readme|✓|ToolingExtension
186+
|Model|✓|ToolingExtension
187+
|Api|✓|ToolingExtension
188+
189+
### Global Feature
190+
| Name | Supported | Defined By |
191+
| ---- | --------- | ---------- |
192+
|Host|✓|OAS2,OAS3
193+
|BasePath|✓|OAS2,OAS3
194+
|Info|✓|OAS2,OAS3
195+
|Schemes|✗|OAS2,OAS3
196+
|PartialSchemes|✓|OAS2,OAS3
197+
|Consumes|✓|OAS2
198+
|Produces|✓|OAS2
199+
|ExternalDocumentation|✓|OAS2,OAS3
200+
|Examples|✓|OAS2,OAS3
201+
|XMLStructureDefinitions|✗|OAS2,OAS3
202+
|MultiServer|✗|OAS3
203+
|ParameterizedServer|✗|OAS3
204+
|ParameterStyling|✗|OAS3
205+
|Callbacks|✗|OAS3
206+
|LinkObjects|✗|OAS3
207+
208+
### Parameter Feature
209+
| Name | Supported | Defined By |
210+
| ---- | --------- | ---------- |
211+
|Path|✓|OAS2,OAS3
212+
|Query|✓|OAS2,OAS3
213+
|Header|✓|OAS2,OAS3
214+
|Body|✓|OAS2
215+
|FormUnencoded|✓|OAS2
216+
|FormMultipart|✓|OAS2
217+
|Cookie|✗|OAS3
218+
219+
### Schema Support Feature
220+
| Name | Supported | Defined By |
221+
| ---- | --------- | ---------- |
222+
|Simple|✓|OAS2,OAS3
223+
|Composite|✓|OAS2,OAS3
224+
|Polymorphism|✗|OAS2,OAS3
225+
|Union|✗|OAS3
226+
|allOf|✗|OAS2,OAS3
227+
|anyOf|✗|OAS3
228+
|oneOf|✗|OAS3
229+
|not|✗|OAS3
230+
231+
### Security Feature
232+
| Name | Supported | Defined By |
233+
| ---- | --------- | ---------- |
234+
|BasicAuth|✓|OAS2,OAS3
235+
|ApiKey|✓|OAS2,OAS3
236+
|OpenIDConnect|✗|OAS3
237+
|BearerToken|✓|OAS3
238+
|OAuth2_Implicit|✗|OAS2,OAS3
239+
|OAuth2_Password|✗|OAS2,OAS3
240+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
241+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
242+
|SignatureAuth|✗|OAS3
243+
|AWSV4Signature|✗|ToolingExtension
244+
245+
### Wire Format Feature
246+
| Name | Supported | Defined By |
247+
| ---- | --------- | ---------- |
248+
|JSON|✓|OAS2,OAS3
249+
|XML|✓|OAS2,OAS3
250+
|PROTOBUF|✗|ToolingExtension
251+
|Custom|✓|OAS2,OAS3

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,16 @@ protected String formatIdentifier(String name, boolean capitalized) {
529529
if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !isReservedWord(identifier)) {
530530
return identifier;
531531
}
532-
return escapeReservedWord(identifier);
532+
if (identifier.matches("[0-9]*")) {
533+
return escapeReservedWord(identifier);
534+
}
535+
if (!capitalized || StringUtils.isNumeric(name)) {
536+
// starts with a small letter, could be a keyword or a number
537+
return escapeReservedWord(identifier);
538+
} else {
539+
// no keywords start with large letter
540+
return identifier;
541+
}
533542
}
534543

535544
protected String stripPackageName(String input) {

0 commit comments

Comments
 (0)