diff --git a/airbyte-api/build.gradle b/airbyte-api/build.gradle index f9314d1b0c646..10a36e9fb2aee 100644 --- a/airbyte-api/build.gradle +++ b/airbyte-api/build.gradle @@ -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" @@ -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"