Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

feat: upgrade to openapi-generator v7.0.0 #146

Merged
merged 2 commits into from
Oct 4, 2023
Merged

Conversation

ctreatma
Copy link
Contributor

@ctreatma ctreatma commented Sep 14, 2023

The new version of openapi-generator includes a number of features that improve the quality of generated code and give more control over how the generator works with the given OpenAPI spec. For example, with v7.0.0+ we can tell the generator to generate inline enums as separate models; this is less compelling in Java--where inline enums can be defined as nested classes--than in Go, but it is nonetheless worth exploring, and there are additional options (inline schema naming , among others, that might help us make a better Java SDK.

@ctreatma ctreatma force-pushed the upgrade-generator branch 2 times, most recently from e797863 to 0bf71ac Compare September 14, 2023 18:38
@@ -11,7 +11,7 @@
|**description** | **String** | | [optional] |
|**facility** | [**Href**](Href.md) | | [optional] |
|**id** | **UUID** | | [optional] |
|**metro** | [**InterconnectionMetro**](InterconnectionMetro.md) | | [optional] |
|**metro** | [**Metro**](Metro.md) | | [optional] |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the v7.0.0 features that is enabled by default is a schema simplification that recognizes that InterconnectionMetro is really just a Metro

@@ -16,7 +16,6 @@
import java.util.Map;
import java.util.List;

import javax.ws.rs.core.GenericType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bunch of the generated changes are like this, removing an import javax.ws.rs.core.GenericType that doesn't appear to have been used in most files anyway.

public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!AttributeData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
Copy link
Contributor Author

@ctreatma ctreatma Sep 14, 2023

Choose a reason for hiding this comment

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

This is another repeated change here, validateJsonObject changing to validateJsonElement. Internally it seems to be non-impacting, but since it's a public method it's technically a breaking change; I'm not clear if this is something SDK consumers would/should use directly.

@@ -46,7 +45,7 @@ public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
*
* @return an instance of the actual schema/object
*/
public abstract Map<String, GenericType> getSchemas();
public abstract Map<String, Class<?>> getSchemas();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a place where import javax.ws.rs.core.GenericType and it does require an additional code change, but even with this larger impact it's a small change.

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Arrays;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, moving this import is just unnecessary (and probably stylistically worse), but OK.

@displague displague merged commit 249769a into main Oct 4, 2023
@displague displague deleted the upgrade-generator branch October 4, 2023 11:05
@github-actions
Copy link
Contributor

This PR is included in version 0.8.0 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants