Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed41536
Update Java toolchain configuration and bump OAuth2 client version
Jul 8, 2025
83aade6
update openapi generator and deps
Jul 8, 2025
4c0af7b
use openapi generator
Jul 8, 2025
a2d303a
remove all generated files
Jul 8, 2025
2de8835
update GitHub Actions to use latest checkout and setup-java actions
Jul 8, 2025
753c8a5
add RetryingOAuth and ApiClient to .openapi-generator-ignore
Jul 9, 2025
7b42b7b
custom retry oauth and apiclient
Jul 9, 2025
d799e16
refactor: replace HashMap with Map.of() for ApiClient initialization
Jul 9, 2025
5f8f4cb
add retryoauth test back
Jul 9, 2025
ad0fe6e
ignore files for genration
Jul 9, 2025
edcd169
update to latest publish
Jul 9, 2025
9c83580
use generated classes
Jul 10, 2025
909d6b5
multi module project
Jul 14, 2025
6762468
remove top level example files
Jul 14, 2025
e2677ce
add custom Java client codegen with validation skipping and publishin…
Jul 14, 2025
90fc126
api client library
Jul 14, 2025
7445a2b
examples module
Jul 14, 2025
e796de2
publish based on moving to multimodule
Jul 14, 2025
7d9ae2a
update skipValidationFor list in openApiGenerate configuration
Jul 14, 2025
632f64a
remove direct calls
Jul 14, 2025
9eabc45
clean before building
Jul 14, 2025
bff1ba1
local dev
Jul 14, 2025
ed88bb4
attempt to fix github build
Jul 14, 2025
0c1e91f
remove debug steps for OpenAPI Generator plugin from build workflow
Jul 14, 2025
e84bba4
add build step for OpenAPI Generator plugin to verify contents
Jul 14, 2025
8ba5380
remove unused configuration and RetryingOAuth implementation
Jul 14, 2025
a3a5dd5
improve error handling in CreateSceneExample by using logger for exce…
Jul 15, 2025
0b79edd
remove .openapi-generator-ignore file as it is no longer needed
Jul 15, 2025
346834b
remove lenient JSON parsing from ApiClient and clean up commented-out…
Jul 15, 2025
43c60f5
remove obsolete OpenAPI generator files and version information
Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 8 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: 17, distribution: temurin }
- name: Build and Verify
run: ./gradlew build
run: |
# Build the plugin first and check its contents
./gradlew :openapi-generator-plugin:build

# Now run the full build
./gradlew clean build
16 changes: 10 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: publish

on: { push: { branches: [main] } }
on:
push:
branches: [main]
workflow_dispatch:


jobs:
detect-publish:
runs-on: ubuntu-latest
outputs:
publish: ${{ steps.detect-publish.outputs.publish }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- id: detect-publish
run: |
result=$(./scripts/detect-publish.sh)
Expand All @@ -20,8 +24,8 @@ jobs:
needs: [detect-publish]
if: needs.detect-publish.outputs.publish == 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: 17, distribution: temurin }
- name: Publish
env:
Expand All @@ -33,6 +37,6 @@ jobs:
-P signingPassword=${{ secrets.ORG_GRADLE_PROJECT_signingPassword }} \
-P ossrhUsername=${{ secrets.OSSRH_USERNAME }} \
-P ossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
publishToSonatype \
closeAndReleaseSonatypeStagingRepository
:api-client-library:publishToSonatype \
:api-client-library:closeAndReleaseSonatypeStagingRepository
./scripts/publish.sh
413 changes: 0 additions & 413 deletions .openapi-generator/FILES

This file was deleted.

1 change: 0 additions & 1 deletion .openapi-generator/VERSION

This file was deleted.

106 changes: 106 additions & 0 deletions MULTI_MODULE_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Vertex API Client Java - Multi-Module Project

This project has been restructured as a multi-module Gradle project with the following modules:

## Modules

### 1. `openapi-generator-plugin`
Custom Gradle plugin for generating Vertex API client code using OpenAPI Generator.

**Location**: `openapi-generator-plugin/`

**Purpose**:
- Contains custom OpenAPI code generation logic
- Provides a reusable Gradle plugin for generating the API client
- Includes any custom templates or generators specific to Vertex API

**Build**:
```bash
./gradlew :openapi-generator-plugin:build
./gradlew :openapi-generator-plugin:publishToMavenLocal
```

### 2. `api-client-library`
The main API client library generated from the OpenAPI specification.

**Location**: `api-client-library/`

**Purpose**:
- Contains the generated API client code
- Includes authentication utilities
- Provides the core SDK functionality

**Build**:
```bash
./gradlew :api-client-library:build
```

**Generate API Client**:
```bash
./gradlew :api-client-library:openApiGenerate
```

### 3. `examples`
Example applications demonstrating how to use the API client library.

**Location**: `examples/`

**Purpose**:
- Contains example code showing API usage
- Includes command-line utilities for common operations
- Demonstrates best practices for using the API client

**Run Examples**:
```bash
./gradlew :examples:run
./gradlew :examples:runCreateAssemblyExample
./gradlew :examples:listExamples
```

## Build Order

The modules have dependencies on each other and should be built in this order:

1. `openapi-generator-plugin` (standalone)
2. `api-client-library` (uses the plugin)
3. `examples` (depends on the library)

## Building the Entire Project

To build all modules:
```bash
./gradlew build
```

To clean and rebuild everything:
```bash
./gradlew clean build
```

## Publishing

The library can be published to Maven repositories:
```bash
./gradlew :api-client-library:publishToMavenLocal
./gradlew publish
```

## Development Workflow

1. Make changes to the OpenAPI generator plugin if needed
2. Build and publish the plugin locally: `./gradlew :openapi-generator-plugin:publishToMavenLocal`
3. Regenerate the API client: `./gradlew :api-client-library:openApiGenerate`
4. Build the library: `./gradlew :api-client-library:build`
5. Test with examples: `./gradlew :examples:run`

## Migration Notes

This project was converted from a single-module to a multi-module structure:

- **Original structure**: All code in `src/main/java/com/vertexvis/`
- **New structure**:
- Code generation logic → `openapi-generator-plugin/`
- Core API client → `api-client-library/`
- Examples → `examples/`

The functionality remains the same, but the code is now better organized and the generator can be reused across projects.
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,54 @@ Then, check out our [sample applications](./src/main/java/com/vertexvis/example)

## Local Development

This project uses a multi-module Gradle structure. For detailed information about the modules and their purposes, refer to the [Multi-Module README](./MULTI_MODULE_README.md).

### Build Order

1. Build the OpenAPI Generator Plugin:
```bash
./gradlew :openapi-generator-plugin:build
./gradlew :openapi-generator-plugin:publishToMavenLocal
```

2. Generate the API Client:
```bash
./gradlew :api-client-library:openApiGenerate
```

3. Build the API Client Library:
```bash
./gradlew :api-client-library:build
```

4. Run Example Applications:
```bash
./gradlew :examples:run
./gradlew :examples:listExamples
```

### Building the Entire Project

To build all modules:
```bash
./gradlew build
```

### Versioning

To bump the version of all modules:
```bash
# Version client
./scripts/bump-version.sh [patch|minor|major]
```

### Publishing

To publish to Maven Local:
```bash
./gradlew :api-client-library:publishToMavenLocal
```

# After bumping version, generate using latest OpenAPI spec
./scripts/generate.sh
To publish to Maven Central:
```bash
./gradlew publish
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ docs/

src/main/AndroidManifest.xml
src/test/
**/auth/RetryingOAuth.java
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the custom RetryingOAuth

151 changes: 151 additions & 0 deletions api-client-library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
buildscript{
dependencies {
classpath files("$rootDir/openapi-generator-plugin/build/libs/openapi-generator-plugin-0.11.0.jar")
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'org.openapi.generator' version '7.14.0'
}

description = 'Vertex API Client Library for Java'

dependencies {
implementation 'io.swagger:swagger-annotations:1.6.14'
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.13.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2'
implementation 'org.apache.commons:commons-lang3:3.15.0'
implementation 'javax.annotation:javax.annotation-api:1.3'
implementation 'org.openapitools:jackson-databind-nullable:0.2.6'

testImplementation(platform('org.junit:junit-bom:5.10.3'))
testImplementation('org.junit.jupiter:junit-jupiter:5.10.3')
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
}

openApiGenerate {
verbose = false
generatorName = 'vertex-java' // Use our custom generator
generateModelTests = false
generateApiTests = false
generateModelDocumentation = false
remoteInputSpec = 'https://platform.vertexvis.com/spec'
outputDir = "${buildDir}/generated/"
invokerPackage = 'com.vertexvis'
modelPackage = 'com.vertexvis.model'
apiPackage = 'com.vertexvis.api'
templateDir = "${project(':openapi-generator-plugin').projectDir}/src/main/resources/vertex-java"
configOptions = [
openApiNullable: "false",
dateLibrary: "java8",
hideGenerationTimestamp: "true",
useRuntimeException: "true",
]
additionalProperties = [
skipValidationFor: "Part,PartData,PartDataAttributes,QueuedJobData,QueuedJob,QueuedJobDataAttributes" // Comma-separated list of models to skip validation for
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is where we specify classes to skip validation for. As we update vertex-api, these can be removed

]
ignoreFileOverride = "${projectDir}/.openapi-generator-ignore"
}

sourceSets {
main {
java {
srcDirs += [
"${buildDir}/generated/src/main/java"
]
}
}
}
tasks.named("openApiGenerate").configure {
dependsOn(":openapi-generator-plugin:build")
}

compileJava.dependsOn tasks.openApiGenerate
compileTestJava.dependsOn tasks.openApiGenerate

// Ensure our custom generator plugin is built before we generate
tasks.openApiGenerate.dependsOn ':openapi-generator-plugin:build'

java {
withJavadocJar()
withSourcesJar()
}

tasks.named('sourcesJar') {
dependsOn tasks.openApiGenerate
from sourceSets.main.allJava
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

jar {
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

publishing {
publications {
maven(MavenPublication) {
artifactId = 'api-client-java'
from components.java
pom {
name = 'com.vertexvis:api-client-java'
description = 'The Vertex REST API client for Java.'
url = 'https://github.com/Vertexvis/vertex-api-client-java'
licenses {
license {
name = 'MIT'
url = 'https://github.com/Vertexvis/vertex-api-client-java/blob/main/LICENSE'
}
}
developers {
developer {
email = 'support@vertexvis.com'
name = 'Vertex Developers'
organizationUrl = 'https://developer.vertexvis.com/'
}
}
scm {
connection = 'scm:git:git@github.com:vertexvis/vertex-api-client-java.git'
developerConnection = 'scm:git:git@github.com:vertexvis/vertex-api-client-java.git'
url = 'https://github.com/Vertexvis/vertex-api-client-java'
}
}
}
}
}

signing {
def hasSigningKey = project.hasProperty("signingKey")
def hasSigningPassword = project.hasProperty("signingPassword")
required { hasSigningKey && hasSigningPassword && !project.version.endsWith("-SNAPSHOT") }
if (hasSigningKey && hasSigningPassword) {
def base64Decode = { prop ->
return new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim()
}
useInMemoryPgpKeys(base64Decode("signingKey"), base64Decode("signingPassword"))
}
sign publishing.publications.maven
}

javadoc {
options.tags = ["http.response.details:a:Http Response Details"]
if(JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
dependsOn tasks.openApiGenerate
}

tasks.withType(Sign) {
dependsOn tasks.withType(GenerateModuleMetadata)
dependsOn tasks.withType(Jar)
}

tasks.withType(PublishToMavenLocal) {
dependsOn tasks.withType(Sign)
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RetryingOAuth(
}

public void setFlow(OAuthFlow flow) {
if (flow == OAuthFlow.application) {
if (flow == OAuthFlow.APPLICATION) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest version changed this to all caps

tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
}
}
Expand Down Expand Up @@ -165,4 +165,4 @@ public Response intercept(Chain chain) throws IOException {
);
}
}
}
}
Loading