Skip to content

Commit 10bcd9f

Browse files
authored
Generate separate server endpoints per domain (#15513)
1 parent 43b3cd8 commit 10bcd9f

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

airbyte-api/build.gradle

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,49 @@ plugins {
77

88
def specFile = "$projectDir/src/main/openapi/config.yaml"
99

10+
// Deprecated -- can be removed once airbyte-server is converted to use the per-domain endpoints generated by generateApiServer
11+
task generateApiServerLegacy(type: GenerateTask) {
12+
def serverOutputDir = "$buildDir/generated/api/server"
13+
14+
inputs.file specFile
15+
outputs.dir serverOutputDir
16+
17+
generatorName = "jaxrs-spec"
18+
inputSpec = specFile
19+
outputDir = serverOutputDir
20+
21+
apiPackage = "io.airbyte.api.generated"
22+
invokerPackage = "io.airbyte.api.invoker.generated"
23+
modelPackage = "io.airbyte.api.model.generated"
24+
25+
importMappings = [
26+
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
27+
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
28+
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
29+
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
30+
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
31+
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
32+
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
33+
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
34+
]
35+
36+
generateApiDocumentation = false
37+
38+
configOptions = [
39+
dateLibrary : "java8",
40+
generatePom : "false",
41+
interfaceOnly: "true",
42+
/*
43+
JAX-RS generator does not respect nullable properties defined in the OpenApi Spec.
44+
It means that if a field is not nullable but not set it is still returning a null value for this field in the serialized json.
45+
The below Jackson annotation is made to only keep non null values in serialized json.
46+
We are not yet using nullable=true properties in our OpenApi so this is a valid workaround at the moment to circumvent the default JAX-RS behavior described above.
47+
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
48+
*/
49+
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
50+
]
51+
}
52+
1053
task generateApiServer(type: GenerateTask) {
1154
def serverOutputDir = "$buildDir/generated/api/server"
1255

@@ -45,10 +88,14 @@ task generateApiServer(type: GenerateTask) {
4588
We are not yet using nullable=true properties in our OpenApi so this is a valid workaround at the moment to circumvent the default JAX-RS behavior described above.
4689
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
4790
*/
48-
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)"
91+
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
92+
93+
// Generate separate classes for each endpoint "domain"
94+
useTags: "true"
4995
]
5096
}
51-
compileJava.dependsOn tasks.generateApiServer
97+
98+
compileJava.dependsOn tasks.generateApiServerLegacy, tasks.generateApiServer
5299

53100
task generateApiClient(type: GenerateTask) {
54101
def clientOutputDir = "$buildDir/generated/api/client"

0 commit comments

Comments
 (0)