Skip to content

[Java][Client] Add Quarkus support#8716

Closed
djnalluri wants to merge 4 commits intoOpenAPITools:masterfrom
oaklandcorp:quarkus-mp-client
Closed

[Java][Client] Add Quarkus support#8716
djnalluri wants to merge 4 commits intoOpenAPITools:masterfrom
oaklandcorp:quarkus-mp-client

Conversation

@djnalluri
Copy link
Copy Markdown
Contributor

This PR adds support for Quarkus in the Microprofile library for the Java client. These changes, for the most part, should not affect any existing usage with the exception of disableMultipart being renamed to enableMultipart and new annotations being used when withXml is enabled. To generate for Quarkus, set the library to microprofile and add the additional property named microprofileFramework set to quarkus.

Summary of changes:

  • Added JSON-B as supported serialization library
  • Added CLI option for controlling output of Swagger annotations
  • Merged Microprofile-specific model templates into the general Java client templates
  • Removed unused Microprofile templates
  • Fixes [REQ] Java MicroPofile Rest client with Jackson serialization? #8015
  • Support for using 'asyncNative' property to toggle usage of CompletionStage or Mutiny (void return not supported)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Technical Committee:
@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @nmuesch (2021/01)

} else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
additionalProperties.put(SERIALIZATION_LIBRARY_GSON, "true");
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.remove(SERIALIZATION_LIBRARY_JSONB);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is the place where you should use switch/case for these instead adding another else if

model.imports.add("IOException");
}
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JSONB)) {
//TODO: Fill this out
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

todo

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.

I left it intentionally blank as a marker for future optimization. But indeed, it should be removed or stated to be so.

model.imports.remove("ApiModel");
model.imports.remove("JsonSerialize");
model.imports.remove("ToStringSerializer");
// if (MICROPROFILE.equals(getLibrary())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

revert commented out or fix and remove

this.serializationLibrary = SERIALIZATION_LIBRARY_JACKSON;
} else if (SERIALIZATION_LIBRARY_GSON.equalsIgnoreCase(serializationLibrary)) {
this.serializationLibrary = SERIALIZATION_LIBRARY_GSON;
} else if (SERIALIZATION_LIBRARY_JSONB.equalsIgnoreCase(serializationLibrary)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

another place for switch/case

}

@Override
public Map<String, String> typeMapping() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont think this override is needed here. typeMapping() is defined as public method in DefaultCodeGen and this doesnt change any behaviour. it returns the same typeMapping hashmap.

}

/**
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extra whitespace adds chaos to review

* Get firstName
* @return firstName
**/
@javax.annotation.Nullable
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should land in its own PR

* (except the first line).
*/
private static String toIndentedString(Object o) {
private String toIndentedString(Object o) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is potentially a breaking change with no fallback config

return this;

@Override
public boolean equals(Object o) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also belongs in its own PR, only adds chaos to this review that's long already

@agilob
Copy link
Copy Markdown
Contributor

agilob commented Feb 16, 2021

As it's a good effort I think this PR has way too many changes to go all in, it should be at last 4-7. There are at least 2 breaking changes in here as well, rename of config flag, change of static method (which looks to be static intentionally).

@djnalluri
Copy link
Copy Markdown
Contributor Author

I'm closing this PR and will break it up into multiple PR's as suggested. Thanks for the feedback.

@melloware
Copy link
Copy Markdown

@djnalluri was this ever implemented? I am looking for Quarkus support of Microprofile.

@djnalluri
Copy link
Copy Markdown
Contributor Author

This hasn't been implemented yet. The series of PR's I was hoping to break things into are layered on each other. Progress on this is stuck on #8801. You could check out the Quarkiverse plugin. It uses OpenAPI generator under the hood. https://github.com/quarkiverse/quarkus-openapi-generator

@melloware
Copy link
Copy Markdown

OK you rock this Quarkiverse plugin looks like exactly what I am looking for.

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.

[REQ] Java MicroPofile Rest client with Jackson serialization?

3 participants