Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,16 @@ public void setParameterExampleValue(CodegenParameter p) {
innerExample = p.items.defaultValue;
}
example = "Arrays.asList(" + innerExample + ")";
if (p.uniqueItems) {
example = "new LinkedHashSet<>(" + example + ")";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
example = "new LinkedHashSet<>(" + example + ")";
example = "Set.of(" + example + ")";

Copy link
Contributor Author

@robinmarechal robinmarechal Mar 7, 2026

Choose a reason for hiding this comment

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

afaik, Set.of(Arrays.asList(xxx)) will create a Set<List<Xxx>>, not a Set<Xxx>.
So this change would generate an invalid syntax.

Also, the reason for the LinkedHashSet instead of Set is to keep insertion order. But yeah, in those examples the element order doesn't really matter.

I can use Set.of() for the empty set, but not here

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, ordering in Sets is an interesting topic. I'm not sure if there is an established standard set in either OpenAPI or openapi-generator 🤔 (I just realized that LinkedHashSet is THE standard used in openapi-generator, so this is a non-issue)

Yeah, I did not know what the type of example was, that would indeed be incorrect 😄


I left my comment a bit open-ended, because I wasn't completely sure, but now I'm convinced this is the correct solution 👍 Thanks for the patience @robinmarechal 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

How come I cannot resolve my own comments @wing328, is that an admin feature? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

i've no idea either.

}
} else {
example = "Arrays.asList()";
if (p.uniqueItems) {
example = "new LinkedHashSet<>()";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
example = "new LinkedHashSet<>()";
example = "Set.of()";

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not relevant, and may be marked as "resolved" 👍

}
else {
example = "Arrays.asList()";
}
}
} else if (Boolean.TRUE.equals(p.isMap)) {
example = "new HashMap()";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/jersey2-java8/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/restclient/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/resteasy/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/resttemplate/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/retrofit2/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/retrofit2rx2/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/retrofit2rx3/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/vertx/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/webclient/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Example {
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
try {
Set<Pet> result = apiInstance.findPetsByTags(tags);
System.out.println(result);
Expand Down
Loading