Skip to content

Commit 2e4a50c

Browse files
BouillieOlivier Leonard
authored andcommitted
Scala akka-http server (OpenAPITools#5758)
* Scala akka-http server base implementation * [scala-akka-http-server] petStore samples * Improved the formatting of generated files * Updated scala-akka-http server samples * [scala-akka-http-server] the groupId, artifactId and artifactVersion default value are used as intended. * Fixed the default operation not being correctly generated on parameterless operations * Added build.sbt.mustache supporting file * Updated scala-akka-http server samples * ScalaAkkaHttpServer: Fixed a String.format call to use Locale.ROOT for locale * [scala-akka-http-server] Fixed defaultValue being escaped during generation * Added scala-akka-http.md * Replaced all "⇒" character with "=>" to retain compatibility with scala 2.13 * [scala-akka-http] Added a config option akkaHttpVersion It's set in the generated build.sbt. * Updated scala-akka-http server samples * [scala-akka-http] More accurate akkaHttpVersion parsing * Updated scala-akka-http.md * [scala-akka-http] Changed the akka-http version check to fix the generation of StringDirectives * Updated scala-akka-http samples * updated scala-akka-http.md Co-authored-by: Olivier Leonard <[email protected]>
1 parent 009fffb commit 2e4a50c

34 files changed

+2128
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=$(ls -ld "$SCRIPT")
7+
link=$(expr "$ls" : '.*-> \(.*\)$')
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=$(dirname "$SCRIPT")/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=$(dirname "$SCRIPT")/..
17+
APP_DIR=$(cd "${APP_DIR}"; pwd)
18+
fi
19+
20+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-akka-http -o samples/server/petstore/scala-akka-http"
30+
31+
java ${JAVA_OPTS} -jar ${executable} ${ags}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
8+
set ags=generate --artifact-id "scala-akka-http-petstore-server" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-akka-http -o samples\server\petstore\scala-akka-http
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

docs/generators.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ The following generators are available:
120120
* [ruby-on-rails](generators/ruby-on-rails.md)
121121
* [ruby-sinatra](generators/ruby-sinatra.md)
122122
* [rust-server](generators/rust-server.md)
123+
* [scala-akka-http](generators/scala-akka-http.md)
123124
* [scala-finch](generators/scala-finch.md)
124125
* [scala-lagom-server](generators/scala-lagom-server.md)
125126
* [scala-play-server](generators/scala-play-server.md)

docs/generators/scala-akka-http.md

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
---
2+
title: Config Options for scala-akka-http
3+
sidebar_label: scala-akka-http
4+
---
5+
6+
| Option | Description | Values | Default |
7+
| ------ | ----------- | ------ | ------- |
8+
|akkaHttpVersion|The version of akka-http| |10.1.10|
9+
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
10+
|apiPackage|package for generated api classes| |null|
11+
|artifactId|artifactId| |openapi-scala-akka-http-server|
12+
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
13+
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (prefered for JDK 1.8+)</dd></dl>|java8|
14+
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
15+
|groupId|groupId in generated pom.xml| |org.openapitools|
16+
|invokerPackage|root package for generated code| |org.openapitools.server|
17+
|modelPackage|package for generated models| |null|
18+
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
19+
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
20+
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
21+
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
22+
|sourceFolder|source folder for generated code| |null|
23+
24+
## IMPORT MAPPING
25+
26+
| Type/Alias | Imports |
27+
| ---------- | ------- |
28+
|Array|java.util.List|
29+
|ArrayList|java.util.ArrayList|
30+
|Date|java.util.Date|
31+
|DateTime|org.joda.time.*|
32+
|File|java.io.File|
33+
|HashMap|java.util.HashMap|
34+
|ListBuffer|scala.collection.mutable.ListBuffer|
35+
|ListSet|scala.collection.immutable.ListSet|
36+
|LocalDate|org.joda.time.*|
37+
|LocalDateTime|org.joda.time.*|
38+
|LocalTime|org.joda.time.*|
39+
|Timestamp|java.sql.Timestamp|
40+
|URI|java.net.URI|
41+
|UUID|java.util.UUID|
42+
43+
44+
## INSTANTIATION TYPES
45+
46+
| Type/Alias | Instantiated By |
47+
| ---------- | --------------- |
48+
|array|ListBuffer|
49+
|map|Map|
50+
|set|Set|
51+
52+
53+
## LANGUAGE PRIMITIVES
54+
55+
<ul class="column-ul">
56+
<li>Any</li>
57+
<li>Array</li>
58+
<li>Boolean</li>
59+
<li>Double</li>
60+
<li>Float</li>
61+
<li>Int</li>
62+
<li>List</li>
63+
<li>Long</li>
64+
<li>Map</li>
65+
<li>Object</li>
66+
<li>Seq</li>
67+
<li>String</li>
68+
<li>boolean</li>
69+
</ul>
70+
71+
## RESERVED WORDS
72+
73+
<ul class="column-ul">
74+
<li>abstract</li>
75+
<li>case</li>
76+
<li>catch</li>
77+
<li>class</li>
78+
<li>def</li>
79+
<li>do</li>
80+
<li>else</li>
81+
<li>extends</li>
82+
<li>false</li>
83+
<li>final</li>
84+
<li>finally</li>
85+
<li>for</li>
86+
<li>forsome</li>
87+
<li>if</li>
88+
<li>implicit</li>
89+
<li>import</li>
90+
<li>lazy</li>
91+
<li>match</li>
92+
<li>new</li>
93+
<li>null</li>
94+
<li>object</li>
95+
<li>override</li>
96+
<li>package</li>
97+
<li>private</li>
98+
<li>protected</li>
99+
<li>return</li>
100+
<li>sealed</li>
101+
<li>super</li>
102+
<li>this</li>
103+
<li>throw</li>
104+
<li>trait</li>
105+
<li>true</li>
106+
<li>try</li>
107+
<li>type</li>
108+
<li>val</li>
109+
<li>var</li>
110+
<li>while</li>
111+
<li>with</li>
112+
<li>yield</li>
113+
</ul>
114+
115+
## FEATURE SET
116+
117+
118+
### Client Modification Feature
119+
| Name | Supported | Defined By |
120+
| ---- | --------- | ---------- |
121+
|BasePath|✗|ToolingExtension
122+
|Authorizations|✗|ToolingExtension
123+
|UserAgent|✗|ToolingExtension
124+
125+
### Data Type Feature
126+
| Name | Supported | Defined By |
127+
| ---- | --------- | ---------- |
128+
|Custom|✗|OAS2,OAS3
129+
|Int32|✓|OAS2,OAS3
130+
|Int64|✓|OAS2,OAS3
131+
|Float|✓|OAS2,OAS3
132+
|Double|✓|OAS2,OAS3
133+
|Decimal|✓|ToolingExtension
134+
|String|✓|OAS2,OAS3
135+
|Byte|✓|OAS2,OAS3
136+
|Binary|✓|OAS2,OAS3
137+
|Boolean|✓|OAS2,OAS3
138+
|Date|✓|OAS2,OAS3
139+
|DateTime|✓|OAS2,OAS3
140+
|Password|✓|OAS2,OAS3
141+
|File|✓|OAS2
142+
|Array|✓|OAS2,OAS3
143+
|Maps|✓|ToolingExtension
144+
|CollectionFormat|✓|OAS2
145+
|CollectionFormatMulti|✓|OAS2
146+
|Enum|✓|OAS2,OAS3
147+
|ArrayOfEnum|✓|ToolingExtension
148+
|ArrayOfModel|✓|ToolingExtension
149+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
150+
|ArrayOfCollectionOfModel|✓|ToolingExtension
151+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
152+
|MapOfEnum|✓|ToolingExtension
153+
|MapOfModel|✓|ToolingExtension
154+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
155+
|MapOfCollectionOfModel|✓|ToolingExtension
156+
|MapOfCollectionOfEnum|✓|ToolingExtension
157+
158+
### Documentation Feature
159+
| Name | Supported | Defined By |
160+
| ---- | --------- | ---------- |
161+
|Readme|✓|ToolingExtension
162+
|Model|✓|ToolingExtension
163+
|Api|✓|ToolingExtension
164+
165+
### Global Feature
166+
| Name | Supported | Defined By |
167+
| ---- | --------- | ---------- |
168+
|Host|✓|OAS2,OAS3
169+
|BasePath|✓|OAS2,OAS3
170+
|Info|✓|OAS2,OAS3
171+
|Schemes|✗|OAS2,OAS3
172+
|PartialSchemes|✓|OAS2,OAS3
173+
|Consumes|✓|OAS2
174+
|Produces|✓|OAS2
175+
|ExternalDocumentation|✓|OAS2,OAS3
176+
|Examples|✓|OAS2,OAS3
177+
|XMLStructureDefinitions|✗|OAS2,OAS3
178+
|MultiServer|✗|OAS3
179+
|ParameterizedServer|✗|OAS3
180+
|ParameterStyling|✗|OAS3
181+
|Callbacks|✗|OAS3
182+
|LinkObjects|✗|OAS3
183+
184+
### Parameter Feature
185+
| Name | Supported | Defined By |
186+
| ---- | --------- | ---------- |
187+
|Path|✓|OAS2,OAS3
188+
|Query|✓|OAS2,OAS3
189+
|Header|✓|OAS2,OAS3
190+
|Body|✓|OAS2
191+
|FormUnencoded|✓|OAS2
192+
|FormMultipart|✓|OAS2
193+
|Cookie|✗|OAS3
194+
195+
### Schema Support Feature
196+
| Name | Supported | Defined By |
197+
| ---- | --------- | ---------- |
198+
|Simple|✓|OAS2,OAS3
199+
|Composite|✓|OAS2,OAS3
200+
|Polymorphism|✗|OAS2,OAS3
201+
|Union|✗|OAS3
202+
203+
### Security Feature
204+
| Name | Supported | Defined By |
205+
| ---- | --------- | ---------- |
206+
|BasicAuth|✓|OAS2,OAS3
207+
|ApiKey|✓|OAS2,OAS3
208+
|OpenIDConnect|✗|OAS3
209+
|BearerToken|✓|OAS3
210+
|OAuth2_Implicit|✗|OAS2,OAS3
211+
|OAuth2_Password|✗|OAS2,OAS3
212+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
213+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
214+
215+
### Wire Format Feature
216+
| Name | Supported | Defined By |
217+
| ---- | --------- | ---------- |
218+
|JSON|✓|OAS2,OAS3
219+
|XML|✓|OAS2,OAS3
220+
|PROTOBUF|✗|ToolingExtension
221+
|Custom|✓|OAS2,OAS3

0 commit comments

Comments
 (0)