Skip to content

[PLAT-6843] -- Update to the current vertex-api spec and current openapi generator (v7.14.0)#63

Merged
gbiv merged 30 commits into
mainfrom
try-again-bump
Jul 23, 2025
Merged

[PLAT-6843] -- Update to the current vertex-api spec and current openapi generator (v7.14.0)#63
gbiv merged 30 commits into
mainfrom
try-again-bump

Conversation

@gbiv
Copy link
Copy Markdown
Contributor

@gbiv gbiv commented Jul 8, 2025

Summary

Updating the Java client to the latest vertex-api spec faced critical OpenAPI generator issues:

  • v5.4.0: Broken AnyOf/OneOf handling requiring manual workarounds

  • v7.14.0: Fixed AnyOf/OneOf but broke POST /parts and POST /scene-items endpoints due to multiple return type limitations.

    This PR implements a custom OpenAPI generator with multi-module gradle project to resolve compatibility issues while upgrading to the latest tooling.


Multi-Module gradle projects

  • openapi-generator-plugin: Custom generator extending v7.14.0 with template modifications
  • api-client-library: Generated client using custom generator with selective validation skipping
  • examples: Demonstration applications moved to dedicated module

Custom Generator Implementation

  • Extended pojo.mustache template to support "skip validation" configuration
  • Added selective validation bypass for problematic models: Part, PartData, PartDataAttributes, QueuedJobData, QueuedJob, QueuedJobDataAttributes
  • Maintains full API compatibility while resolving generation conflicts

Code Cleanup

  • Removed generated files from the repo since there isn't a requirement for customization
  • Cleaned up OpenAPI generator artifacts and configuration files (handled mostly in gradle plugin configuration)
  • Updated CI/CD pipeline for multi-module builds

Test Plan

Release Notes

Possible Regressions

  • publishing isn't tested so a follow-up might be needed to make sure the library is published

Dependencies

Ticket

NOTES

Updated one of the examples for now to test as well as published locally and tested locally with the shared parts library tests. Will update that repo once this is published

@gbiv gbiv changed the title Try again bump Update to latest openapi generator Jul 10, 2025
@gbiv gbiv self-assigned this Jul 15, 2025
@gbiv gbiv changed the title Update to latest openapi generator [PLAT-6843] -- Update to latest openapi generator Jul 15, 2025
@gbiv gbiv changed the title [PLAT-6843] -- Update to latest openapi generator [PLAT-6843] -- Update to the current vertex-api spec and current openapi generator (v7.14.0) Jul 15, 2025
@sonarqubecloud
Copy link
Copy Markdown

/**
* Custom Java client codegen that supports conditional validation skipping.
*/
public class VertexJavaClientCodegen extends JavaClientCodegen implements CodegenConfig {
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.

Customization to exclude models from validation.

@@ -0,0 +1 @@
com.vertexvis.codegen.VertexJavaClientCodegen
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.

register the generator extension

Comment on lines +541 to +547
{{^vendorExtensions.x-skip-validation}}
validateJsonElement(jsonElement);
{{/vendorExtensions.x-skip-validation}}
{{#vendorExtensions.x-skip-validation}}
// vertex:TODO: Skipping validation during deserialization of the JSON element based on configuration
// validateJsonElement(jsonElement);
{{/vendorExtensions.x-skip-validation}}
Copy link
Copy Markdown
Contributor Author

@gbiv gbiv Jul 15, 2025

Choose a reason for hiding this comment

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

Conditional validation based on the skip validation extension


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

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


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

@gbiv gbiv marked this pull request as ready for review July 15, 2025 20:15
@gbiv gbiv requested a review from a team as a code owner July 15, 2025 20:15
Copy link
Copy Markdown
Contributor

@mikemccarty-vertex mikemccarty-vertex left a comment

Choose a reason for hiding this comment

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

impressive!

Have you tested the output against one of our repos?

@gbiv
Copy link
Copy Markdown
Contributor Author

gbiv commented Jul 15, 2025

impressive!

Have you tested the output against one of our repos?

Only locally against the shared parts library tests repo. I'll need to PR that one once this one is published...The way this is published, it's not clear to me how to get a "snapshot" version like we can with our other libs that use vertex-maven-gradle-plugin

@gbiv gbiv requested review from a team, mikemccarty-vertex and sourada-e5 July 23, 2025 13:50
Copy link
Copy Markdown
Contributor

@mikemccarty-vertex mikemccarty-vertex left a comment

Choose a reason for hiding this comment

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

LGTM

@gbiv
Copy link
Copy Markdown
Contributor Author

gbiv commented Jul 23, 2025

I'm anticipating that the publishing won't work due to the current configuration. So I will open a new PR to address that if it fails to publish a new artifact on this merge.

@gbiv gbiv merged commit bff0b0a into main Jul 23, 2025
2 checks passed
@gbiv gbiv deleted the try-again-bump branch July 23, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants