Skip to content

Commit

Permalink
airbyte-api: remove server-legacy api code generation (airbytehq#34541)
Browse files Browse the repository at this point in the history
  • Loading branch information
postamar authored and jatinyadav-cc committed Feb 26, 2024
1 parent c5345a2 commit a0c4e4f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 86 deletions.
1 change: 1 addition & 0 deletions airbyte-cdk/java/airbyte-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ MavenLocal debugging steps:

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:-----------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.15.2 | 2024-01-25 | [\#34441](https://github.com/airbytehq/airbyte/pull/34441) | Improve airbyte-api build performance. |
| 0.15.1 | 2024-01-25 | [\#34451](https://github.com/airbytehq/airbyte/pull/34451) | Async destinations: Better logging when we fail to parse an AirbyteMessage |
| 0.15.0 | 2024-01-23 | [\#34441](https://github.com/airbytehq/airbyte/pull/34441) | Removed connector registry and micronaut dependencies. |
| 0.14.2 | 2024-01-24 | [\#34458](https://github.com/airbytehq/airbyte/pull/34458) | Handle case-sensitivity in sentry error grouping |
Expand Down
124 changes: 39 additions & 85 deletions airbyte-cdk/java/airbyte-cdk/airbyte-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,24 @@ java {
}
}

def specFile = "$projectDir/src/main/openapi/config.yaml"
String specFile = "$projectDir/src/main/openapi/config.yaml"
String serverOutputDir = "$buildDir/generated/api/server"
String clientOutputDir = "$buildDir/generated/api/client"
String docsOutputDir = "$buildDir/generated/api/docs"
Map<String,String> schemaMappingsValue = [
'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',
]

def generate = tasks.register('generate')

// Deprecated -- can be removed once airbyte-server is converted to use the per-domain endpoints generated by generateApiServer
def generateApiServerLegacy = tasks.register('generateApiServerLegacy', 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"

schemaMappings.set([
'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.set([
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)",
])
}
generate.configure {
dependsOn generateApiServerLegacy
}

def generateApiServer = tasks.register('generateApiServer', GenerateTask) {
def serverOutputDir = "$buildDir/generated/api/server"

inputs.file specFile
outputs.dir serverOutputDir
Expand All @@ -75,16 +41,7 @@ def generateApiServer = tasks.register('generateApiServer', GenerateTask) {
invokerPackage = "io.airbyte.api.invoker.generated"
modelPackage = "io.airbyte.api.model.generated"

schemaMappings.set([
'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',
])
schemaMappings.set(schemaMappingsValue)

generateApiDocumentation = false

Expand All @@ -100,17 +57,13 @@ def generateApiServer = tasks.register('generateApiServer', GenerateTask) {
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)",

// Generate separate classes for each endpoint "domain"
useTags: "true"
])
}
generate.configure {
dependsOn generateApiServer
}

def generateApiClient = tasks.register('generateApiClient', GenerateTask) {
def clientOutputDir = "$buildDir/generated/api/client"

inputs.file specFile
outputs.dir clientOutputDir
Expand All @@ -123,16 +76,7 @@ def generateApiClient = tasks.register('generateApiClient', GenerateTask) {
invokerPackage = "io.airbyte.api.client.invoker.generated"
modelPackage = "io.airbyte.api.client.model.generated"

schemaMappings.set([
'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',
])
schemaMappings.set(schemaMappingsValue)

library = "native"

Expand All @@ -149,7 +93,6 @@ generate.configure {
}

def generateApiDocs = tasks.register('generateApiDocs', GenerateTask) {
def docsOutputDir = "$buildDir/generated/api/docs"

generatorName = "html"
inputSpec = specFile
Expand All @@ -159,16 +102,7 @@ def generateApiDocs = tasks.register('generateApiDocs', GenerateTask) {
invokerPackage = "io.airbyte.api.client.invoker.generated"
modelPackage = "io.airbyte.api.client.model.generated"

schemaMappings.set([
'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',
])
schemaMappings.set(schemaMappingsValue)

generateApiDocumentation = false

Expand All @@ -190,9 +124,25 @@ def generateApiDocs = tasks.register('generateApiDocs', GenerateTask) {
}
}
}
generate.configure {
def deleteExistingDocs = tasks.register('deleteOldApiDocs', Delete) {
delete rootProject.file("docs/reference/api/generated-api-html")
}
deleteExistingDocs.configure {
dependsOn generateApiDocs
}
def copyApiDocs = tasks.register('copyApiDocs', Copy) {
from(docsOutputDir) {
include "**/*.html"
}
into rootProject.file("docs/reference/api/generated-api-html")
includeEmptyDirs = false
}
copyApiDocs.configure {
dependsOn deleteExistingDocs
}
generate.configure {
dependsOn copyApiDocs
}

dependencies {
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
Expand All @@ -209,7 +159,11 @@ dependencies {
sourceSets {
main {
java {
srcDirs "$buildDir/generated/api/server/src/gen/java", "$buildDir/generated/api/client/src/main/java", "$projectDir/src/main/java"
srcDirs([
"$projectDir/src/main/java",
"${serverOutputDir}/src/gen/java",
"${clientOutputDir}/src/main/java",
])
}
resources {
srcDir "$projectDir/src/main/openapi/"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.15.1
version=0.15.2

0 comments on commit a0c4e4f

Please sign in to comment.