Skip to content

Commit d81b5a3

Browse files
andrewwilsonnewguiarnwing328
authored
#20883 - Add new Misk Kotlin OpenAPI Generator (#20885)
* first pass * Fix extra new line * adding generator file * Run new.sh script * Fix template directory and ignore failing tests * fixing up content type * adding controller impl * cleanup interface * typo * removing bodytype * adding protos * fixing 2 * Fix headerParamsSimple * removing protos etc. * fixing imports * removing commented code * fixing imports * fixing return * fixing file * adding comment * remove adminapi * move to jakarta * reverting break * fixing httpMethods * pushing mediaTypes * Adds gradle mustache templates * Setup simple build.gradle.kts * Adds basic model.mustache for model generation * fixing summary * fixing summary 2 * Removes unnecesssary line * fixing return type * fixing override * fixing httpcall * Delete proto folder creation * fixing return type * fixing void return type * fixing space * removing reactive * removing imports * Fixing spacing * Fixing tabbing * fixing headers * add comment * Adds unit tests * cleanup * Correct getHelp() description * cleanup 2 * removiing pathParams files * fixup * fixup 3 * removing more files * Adds GitHub Workflow generation * removing form params as not required * Adds tests for OptionsProvider * Renamed file to match * remove whitespace * remove whitespace * adding documentation * adding documentation * removing swagger annotations * adding tests * Adds Guice Module * Grab OpenAPI title to generate module name * Revert "Grab OpenAPI title to generate module name" This reverts commit 9c9b935f5dbee6e0974ebf66b4f611f107df70c2. * Update sample * Removes moduleFileName additional property * adding tests * adding tests 2 * adding tests 3 * adding tests 4 * added media types * re-adding tests * fixing camelcase * fixing mediatypes * default mediatype * adding validation * adding validation * removing swagger * adding gradle dependency * adding gradle dependency * fixing types * fixing return types * fixing tests * final fixes * tweaks * fixing file etc. * Update samples/ folder * fixing jakarta * fixing jakarta 2 * fixing impl * Fix unit tests * fixing jakarta * fixing jakarta 2 * final final final changes * Fix initialization of BigDecimal for default values * update samples, docs * fixing RequestHeader * fixing RequestHeader 2 * fixing RequestHeader 2 * add validateSpec=false * fix pom version --------- Co-authored-by: Guido Arnau <guido@squareup.com> Co-authored-by: William Cheng <wing328hk@gmail.com>
1 parent c8cfa16 commit d81b5a3

File tree

100 files changed

+3370
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3370
-42
lines changed

.github/workflows/samples-kotlin-server-jdk17.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
- samples/server/petstore/kotlin-server/javalin-6
4343
- samples/server/petstore/kotlin-server/ktor
4444
- samples/server/petstore/kotlin-server/ktor2
45+
- samples/server/petstore/kotlin-misk
4546
# comment out due to gradle build failure
4647
# - samples/server/petstore/kotlin-spring-default/
4748
steps:
@@ -66,4 +67,4 @@ jobs:
6667
arguments: wrapper
6768
- name: Build
6869
working-directory: ${{ matrix.sample }}
69-
run: ./gradlew build -x test
70+
run: ./gradlew build -x test

.github/workflows/samples-kotlin-server-jdk21.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- samples/server/petstore/kotlin-server/ktor
2626
- samples/server/petstore/kotlin-server/ktor2
2727
- samples/server/petstore/kotlin-server-required-and-nullable-properties
28+
- samples/server/petstore/kotlin-misk
2829
steps:
2930
- uses: actions/checkout@v4
3031
- uses: actions/setup-java@v4

.github/workflows/samples-kotlin-server.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- samples/server/others/kotlin-server/jaxrs-spec
4848
- samples/server/others/kotlin-server/jaxrs-spec-array-response
4949
- samples/server/petstore/kotlin-spring-cloud
50+
- samples/server/petstore/kotlin-misk
5051
# comment out due to gradle build failure
5152
#- samples/server/petstore/kotlin-spring-default
5253
# no build.gradle file
@@ -73,4 +74,4 @@ jobs:
7374
arguments: wrapper
7475
- name: Build
7576
working-directory: ${{ matrix.sample }}
76-
run: ./gradlew build -x test
77+
run: ./gradlew build -x test

bin/configs/kotlin-misk.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generatorName: kotlin-misk
2+
outputDir: samples/server/petstore/kotlin-misk
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-misk
5+
validateSpec: false
6+
additionalProperties:
7+
hideGenerationTimestamp: "true"
8+
moduleClassName: "PetStoreModule"

docs/generators.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ The following generators are available:
122122
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
123123
* [jaxrs-spec](generators/jaxrs-spec.md)
124124
* [julia-server (beta)](generators/julia-server.md)
125+
* [kotlin-misk](generators/kotlin-misk.md)
125126
* [kotlin-server](generators/kotlin-server.md)
126127
* [kotlin-spring](generators/kotlin-spring.md)
127128
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)

docs/generators/kotlin-misk.md

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
---
2+
title: Documentation for the kotlin-misk Generator
3+
---
4+
5+
## METADATA
6+
7+
| Property | Value | Notes |
8+
| -------- | ----- | ----- |
9+
| generator name | kotlin-misk | pass this to the generate command after -g |
10+
| generator stability | STABLE | |
11+
| generator type | SERVER | |
12+
| generator language | Kotlin | |
13+
| generator default templating engine | mustache | |
14+
| helpTxt | Generates a kotlin-misk server. | |
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+
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
22+
|apiSuffix|suffix for api classes| |Api|
23+
|artifactId|Generated artifact id (name of jar).| |null|
24+
|artifactVersion|Generated artifact's package version.| |1.0.0|
25+
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
26+
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
27+
|modelMutable|Create mutable models| |false|
28+
|moduleClassName|Name of the generated module class| |OpenApiModule|
29+
|packageName|Generated artifact package name.| |org.openapitools|
30+
|parcelizeModels|toggle &quot;@Parcelize&quot; for generated models| |null|
31+
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |null|
32+
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
33+
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
34+
|sourceFolder|source folder for generated code| |src/main/kotlin|
35+
|useBeanValidation|Use BeanValidation API annotations to validate data types| |true|
36+
37+
## IMPORT MAPPING
38+
39+
| Type/Alias | Imports |
40+
| ---------- | ------- |
41+
|BigDecimal|java.math.BigDecimal|
42+
|Date|java.time.LocalDate|
43+
|DateTime|java.time.OffsetDateTime|
44+
|File|java.io.File|
45+
|LocalDate|java.time.LocalDate|
46+
|LocalDateTime|java.time.LocalDateTime|
47+
|LocalTime|java.time.LocalTime|
48+
|Timestamp|java.sql.Timestamp|
49+
|URI|java.net.URI|
50+
|UUID|java.util.UUID|
51+
52+
53+
## INSTANTIATION TYPES
54+
55+
| Type/Alias | Instantiated By |
56+
| ---------- | --------------- |
57+
|array|kotlin.collections.ArrayList|
58+
|list|kotlin.collections.ArrayList|
59+
|map|kotlin.collections.HashMap|
60+
61+
62+
## LANGUAGE PRIMITIVES
63+
64+
<ul class="column-ul">
65+
<li>kotlin.Array</li>
66+
<li>kotlin.Boolean</li>
67+
<li>kotlin.Byte</li>
68+
<li>kotlin.ByteArray</li>
69+
<li>kotlin.Char</li>
70+
<li>kotlin.Double</li>
71+
<li>kotlin.Float</li>
72+
<li>kotlin.Int</li>
73+
<li>kotlin.Long</li>
74+
<li>kotlin.Short</li>
75+
<li>kotlin.String</li>
76+
<li>kotlin.collections.List</li>
77+
<li>kotlin.collections.Map</li>
78+
<li>kotlin.collections.MutableList</li>
79+
<li>kotlin.collections.MutableMap</li>
80+
<li>kotlin.collections.MutableSet</li>
81+
<li>kotlin.collections.Set</li>
82+
</ul>
83+
84+
## RESERVED WORDS
85+
86+
<ul class="column-ul">
87+
<li>ApiResponse</li>
88+
<li>abstract</li>
89+
<li>actual</li>
90+
<li>annotation</li>
91+
<li>as</li>
92+
<li>break</li>
93+
<li>class</li>
94+
<li>companion</li>
95+
<li>const</li>
96+
<li>constructor</li>
97+
<li>continue</li>
98+
<li>contract</li>
99+
<li>crossinline</li>
100+
<li>data</li>
101+
<li>delegate</li>
102+
<li>do</li>
103+
<li>dynamic</li>
104+
<li>else</li>
105+
<li>enum</li>
106+
<li>expect</li>
107+
<li>external</li>
108+
<li>false</li>
109+
<li>field</li>
110+
<li>final</li>
111+
<li>finally</li>
112+
<li>for</li>
113+
<li>fun</li>
114+
<li>if</li>
115+
<li>import</li>
116+
<li>in</li>
117+
<li>infix</li>
118+
<li>init</li>
119+
<li>inline</li>
120+
<li>inner</li>
121+
<li>interface</li>
122+
<li>internal</li>
123+
<li>is</li>
124+
<li>it</li>
125+
<li>lateinit</li>
126+
<li>noinline</li>
127+
<li>null</li>
128+
<li>object</li>
129+
<li>open</li>
130+
<li>operator</li>
131+
<li>out</li>
132+
<li>override</li>
133+
<li>package</li>
134+
<li>param</li>
135+
<li>private</li>
136+
<li>property</li>
137+
<li>protected</li>
138+
<li>public</li>
139+
<li>receiver</li>
140+
<li>reified</li>
141+
<li>return</li>
142+
<li>sealed</li>
143+
<li>setparam</li>
144+
<li>super</li>
145+
<li>suspend</li>
146+
<li>tailrec</li>
147+
<li>this</li>
148+
<li>throw</li>
149+
<li>true</li>
150+
<li>try</li>
151+
<li>typealias</li>
152+
<li>typeof</li>
153+
<li>val</li>
154+
<li>value</li>
155+
<li>var</li>
156+
<li>vararg</li>
157+
<li>when</li>
158+
<li>where</li>
159+
<li>while</li>
160+
</ul>
161+
162+
## FEATURE SET
163+
164+
165+
### Client Modification Feature
166+
| Name | Supported | Defined By |
167+
| ---- | --------- | ---------- |
168+
|BasePath|✗|ToolingExtension
169+
|Authorizations|✗|ToolingExtension
170+
|UserAgent|✗|ToolingExtension
171+
|MockServer|✗|ToolingExtension
172+
173+
### Data Type Feature
174+
| Name | Supported | Defined By |
175+
| ---- | --------- | ---------- |
176+
|Custom|✗|OAS2,OAS3
177+
|Int32|✓|OAS2,OAS3
178+
|Int64|✓|OAS2,OAS3
179+
|Float|✓|OAS2,OAS3
180+
|Double|✓|OAS2,OAS3
181+
|Decimal|✓|ToolingExtension
182+
|String|✓|OAS2,OAS3
183+
|Byte|✓|OAS2,OAS3
184+
|Binary|✓|OAS2,OAS3
185+
|Boolean|✓|OAS2,OAS3
186+
|Date|✓|OAS2,OAS3
187+
|DateTime|✓|OAS2,OAS3
188+
|Password|✓|OAS2,OAS3
189+
|File|✓|OAS2
190+
|Uuid||
191+
|Array|✓|OAS2,OAS3
192+
|Null|✗|OAS3
193+
|AnyType|✗|OAS2,OAS3
194+
|Object|✓|OAS2,OAS3
195+
|Maps|✓|ToolingExtension
196+
|CollectionFormat|✓|OAS2
197+
|CollectionFormatMulti|✓|OAS2
198+
|Enum|✓|OAS2,OAS3
199+
|ArrayOfEnum|✓|ToolingExtension
200+
|ArrayOfModel|✓|ToolingExtension
201+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
202+
|ArrayOfCollectionOfModel|✓|ToolingExtension
203+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
204+
|MapOfEnum|✓|ToolingExtension
205+
|MapOfModel|✓|ToolingExtension
206+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
207+
|MapOfCollectionOfModel|✓|ToolingExtension
208+
|MapOfCollectionOfEnum|✓|ToolingExtension
209+
210+
### Documentation Feature
211+
| Name | Supported | Defined By |
212+
| ---- | --------- | ---------- |
213+
|Readme|✓|ToolingExtension
214+
|Model|✓|ToolingExtension
215+
|Api|✓|ToolingExtension
216+
217+
### Global Feature
218+
| Name | Supported | Defined By |
219+
| ---- | --------- | ---------- |
220+
|Host|✓|OAS2,OAS3
221+
|BasePath|✓|OAS2,OAS3
222+
|Info|✓|OAS2,OAS3
223+
|Schemes|✗|OAS2,OAS3
224+
|PartialSchemes|✓|OAS2,OAS3
225+
|Consumes|✓|OAS2
226+
|Produces|✓|OAS2
227+
|ExternalDocumentation|✓|OAS2,OAS3
228+
|Examples|✓|OAS2,OAS3
229+
|XMLStructureDefinitions|✗|OAS2,OAS3
230+
|MultiServer|✗|OAS3
231+
|ParameterizedServer|✗|OAS3
232+
|ParameterStyling|✗|OAS3
233+
|Callbacks|✗|OAS3
234+
|LinkObjects|✗|OAS3
235+
236+
### Parameter Feature
237+
| Name | Supported | Defined By |
238+
| ---- | --------- | ---------- |
239+
|Path|✓|OAS2,OAS3
240+
|Query|✓|OAS2,OAS3
241+
|Header|✓|OAS2,OAS3
242+
|Body|✓|OAS2
243+
|FormUnencoded|✓|OAS2
244+
|FormMultipart|✓|OAS2
245+
|Cookie|✓|OAS3
246+
247+
### Schema Support Feature
248+
| Name | Supported | Defined By |
249+
| ---- | --------- | ---------- |
250+
|Simple|✓|OAS2,OAS3
251+
|Composite|✓|OAS2,OAS3
252+
|Polymorphism|✗|OAS2,OAS3
253+
|Union|✗|OAS3
254+
|allOf|✗|OAS2,OAS3
255+
|anyOf|✗|OAS3
256+
|oneOf|✗|OAS3
257+
|not|✗|OAS3
258+
259+
### Security Feature
260+
| Name | Supported | Defined By |
261+
| ---- | --------- | ---------- |
262+
|BasicAuth|✗|OAS2,OAS3
263+
|ApiKey|✗|OAS2,OAS3
264+
|OpenIDConnect|✗|OAS3
265+
|BearerToken|✗|OAS3
266+
|OAuth2_Implicit|✗|OAS2,OAS3
267+
|OAuth2_Password|✗|OAS2,OAS3
268+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
269+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
270+
|SignatureAuth|✗|OAS3
271+
|AWSV4Signature|✗|ToolingExtension
272+
273+
### Wire Format Feature
274+
| Name | Supported | Defined By |
275+
| ---- | --------- | ---------- |
276+
|JSON|✗|OAS2,OAS3
277+
|XML|✗|OAS2,OAS3
278+
|PROTOBUF|✓|ToolingExtension
279+
|Custom|✗|OAS2,OAS3

0 commit comments

Comments
 (0)