@@ -190,7 +190,7 @@ spotless {
190
190
191
191
// OpenAPI integration
192
192
val basePackage = project.group.toString()
193
- val openAPIgenerationPath = " $buildDir /generated/openapi"
193
+ val openAPIgenerationPath = " ${project.layout.buildDirectory} /generated/openapi"
194
194
195
195
// Pairs of the different OpenAPI files we use. Each pair must have its own 'category' as first argument as these
196
196
// are used to generate corresponding packages
@@ -215,20 +215,28 @@ openApiFiles.forEach {
215
215
packageName.set(targetPackageName)
216
216
apiPackage.set(targetPackageName)
217
217
modelPackage.set(targetPackageName)
218
- // WARNING: there are patched mustache files used!
218
+ // We use patched mustache so that only the necessary parts (i.e. resources and models)
219
+ // are generated. additionally we patch the used serialization framework as the `ktor` plugin
220
+ // uses a different one than we do in the model-server. The templates are based on
221
+ // https://github.com/OpenAPITools/openapi-generator/tree/809b3331a95b3c3b7bcf025d16ae09dc0682cd69/modules/openapi-generator/src/main/resources/kotlin-server
219
222
templateDir.set(" $projectDir /src/main/resources/openapi/templates" )
220
223
configOptions.set(
221
224
mapOf (
225
+ // we use the ktor generator to generate server side resources and model (i.e. data classes)
222
226
" library" to " ktor" ,
227
+ // the generated artifacts are not built independently, thus no dedicated build files have to be generated
223
228
" omitGradleWrapper" to " true" ,
229
+ // the path to resource generation we need
224
230
" featureResources" to " true" ,
231
+ // disable features we do not use
225
232
" featureAutoHead" to " false" ,
226
233
" featureCompression" to " false" ,
227
234
" featureHSTS" to " false" ,
228
235
" featureMetrics" to " false" ,
229
236
),
230
237
)
231
- // generate only Paths and Models
238
+ // generate only Paths and Models - only this set will produce the intended Paths.kt as well as the models
239
+ // the openapi generator is generally very picky and configuring it is rather complex
232
240
globalProperties.putAll(
233
241
mapOf (
234
242
" models" to " " ,
@@ -259,5 +267,5 @@ openApiFiles.forEach {
259
267
}
260
268
261
269
// add openAPI generated artifacts to the sourceSets
262
- java. sourceSets.getByName( " main" ).java .srcDir(file( " $outputPath /src/main/kotlin" ) )
270
+ sourceSets[ " main" ].kotlin .srcDir(" $outputPath /src/main/kotlin" )
263
271
}
0 commit comments