Skip to content

Commit 33c6156

Browse files
committed
chore: initial generator config
1 parent e80a2f3 commit 33c6156

File tree

51 files changed

+27222
-0
lines changed

Some content is hidden

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

51 files changed

+27222
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.expediagroup.sdk.xap.generator.mustache
2+
3+
import com.samskivert.mustache.Mustache
4+
import com.samskivert.mustache.Template
5+
import java.io.Serializable
6+
import java.io.Writer
7+
import org.openapitools.codegen.CodegenResponse
8+
9+
class AllowedMediaTypesLambda : Mustache.Lambda, Serializable {
10+
override fun execute(
11+
fragment: Template.Fragment,
12+
writer: Writer,
13+
) {
14+
val response: CodegenResponse = fragment.context() as CodegenResponse
15+
if (response.is2xx) {
16+
val mediaTypes: List<String> =
17+
response.content.keys.filter {
18+
!it.contains("xml", ignoreCase = true)
19+
}
20+
21+
val context = mapOf("mediaTypes" to mediaTypes)
22+
fragment.execute(context, writer)
23+
}
24+
}
25+
}

generator/build.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,41 @@ group = project.property("GROUP_ID") as String
1010
dependencies {
1111
api("org.openapitools:openapi-generator:7.11.0")
1212
}
13+
14+
openApiGenerate {
15+
inputSpec = System.getProperty("inputSpec") ?: "$projectDir/src/main/resources/specs.yaml"
16+
17+
packageName = "com.expediagroup.sdk.xap"
18+
invokerPackage = "com.expediagroup.sdk.xap"
19+
apiPackage = "com.expediagroup.sdk.xap.operations"
20+
modelPackage = "com.expediagroup.sdk.xap.models"
21+
22+
dryRun = false
23+
cleanupOutput = false
24+
generateApiDocumentation = false
25+
generateApiTests = false
26+
generateModelTests = false
27+
enablePostProcessFile = true
28+
29+
templateDir = "$projectDir/src/main/resources/templates"
30+
configFile = "$projectDir/src/main/resources/generator-config.yaml"
31+
outputDir = "$rootDir/xap-sdk/src/main/kotlin"
32+
33+
additionalProperties.put(CodegenConstants.ENUM_PROPERTY_NAMING, "UPPERCASE")
34+
additionalProperties.put("allowedMediaTypes", AllowedMediaTypesLambda())
35+
36+
configOptions.put("sourceFolder", "")
37+
38+
globalProperties.put("supportingFiles", "Room.kt")
39+
}
40+
41+
tasks.named("openApiGenerate").configure {
42+
doLast {
43+
exec {
44+
commandLine(
45+
"../gradlew ktlintFormat".split(" "),
46+
)
47+
workingDir = File("$rootDir/xap-sdk").absoluteFile
48+
}
49+
}
50+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
files:
2+
operation_params.mustache:
3+
templateType: API
4+
destinationFilename: Params.kt
5+
room.mustache:
6+
templateType: SupportingFiles
7+
destinationFilename: Room.kt
8+
folder: com/expediagroup/sdk/xap/models
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./node_modules/gts/"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('gts/.prettierrc.json')
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
kind: parameter
5+
regex: freeCancellationEndDateTime
6+
stopBy:
7+
kind: class_declaration
8+
regex: Builder
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rule:
2+
kind: user_type
3+
pattern: $TYPE
4+
inside:
5+
any:
6+
- kind: class_parameter
7+
regex: freeCancellationEndDateTime
8+
- kind: nullable_type
9+
inside:
10+
kind: class_parameter
11+
regex: freeCancellationEndDateTime
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
kind: parameter
5+
regex: dateTime
6+
stopBy:
7+
kind: class_declaration
8+
regex: Builder

0 commit comments

Comments
 (0)