-
Notifications
You must be signed in to change notification settings - Fork 1
[PLAT-6843] -- Update to the current vertex-api spec and current openapi generator (v7.14.0) #63
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
Changes from all commits
ed41536
83aade6
4c0af7b
a2d303a
2de8835
753c8a5
7b42b7b
d799e16
5f8f4cb
ad0fe6e
edcd169
9c83580
909d6b5
6762468
e2677ce
90fc126
7445a2b
e796de2
7d9ae2a
632f64a
9eabc45
bff1ba1
ed88bb4
0c1e91f
e84bba4
8ba5380
a3a5dd5
0b79edd
346834b
43c60f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ docs/ | |
|
|
||
| src/main/AndroidManifest.xml | ||
| src/test/ | ||
| **/auth/RetryingOAuth.java | ||
| 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ public RetryingOAuth( | |
| } | ||
|
|
||
| public void setFlow(OAuthFlow flow) { | ||
| if (flow == OAuthFlow.application) { | ||
| if (flow == OAuthFlow.APPLICATION) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. latest version changed this to all caps |
||
| tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS); | ||
| } | ||
| } | ||
|
|
@@ -165,4 +165,4 @@ public Response intercept(Chain chain) throws IOException { | |
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the custom RetryingOAuth