Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate separate server endpoints per domain #15513

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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