Skip to content

Commit

Permalink
Generate separate server endpoints per domain
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpgrailsdev committed Aug 10, 2022
1 parent 29c3426 commit 5f58f5a
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions airbyte-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,49 @@ plugins {

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

// Deprecated -- can be removed once airbyte-server is converted to use the per-domain endpoints generated by generateApiServer
task generateApiServerLegacy(type: GenerateTask) {
def serverOutputDir = "$buildDir/generated/api/server"

inputs.file specFile
outputs.dir serverOutputDir

generatorName = "jaxrs-spec"
inputSpec = specFile
outputDir = serverOutputDir

apiPackage = "io.airbyte.api.generated"
invokerPackage = "io.airbyte.api.invoker.generated"
modelPackage = "io.airbyte.api.model.generated"

importMappings = [
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
]

generateApiDocumentation = false

configOptions = [
dateLibrary : "java8",
generatePom : "false",
interfaceOnly: "true",
/*
JAX-RS generator does not respect nullable properties defined in the OpenApi Spec.
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.
The below Jackson annotation is made to only keep non null values in serialized json.
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.
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
*/
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
]
}

task generateApiServer(type: GenerateTask) {
def serverOutputDir = "$buildDir/generated/api/server"

Expand Down Expand Up @@ -45,10 +88,14 @@ task generateApiServer(type: GenerateTask) {
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.
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
*/
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)"
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",

// Generate separate classes for each endpoint "domain"
useTags: "true"
]
}
compileJava.dependsOn tasks.generateApiServer

compileJava.dependsOn tasks.generateApiServerLegacy, tasks.generateApiServer

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

0 comments on commit 5f58f5a

Please sign in to comment.