Skip to content
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

Unqork #2278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Unqork #2278

wants to merge 1 commit into from

Conversation

upgradingdave
Copy link

Description

Allow for parsing integers found in ENUM section of open api specs

See issue #2277 for more details. This patch addresses that issue.

Related issues

closes #2277

@upgradingdave upgradingdave requested a review from a team as a code owner March 29, 2024 00:09
Copy link
Contributor

@johnBgood johnBgood left a comment

Choose a reason for hiding this comment

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

Nice improvement thank you!
Would be nice to have a UT to illustrate this new behavior (maybe in HttpOutboundElementTemplateBuilderTest).

Last thing, did you test the generated template with a request using an Integer param? Just to be sure :)

Thank you again!

return new HttpOperationProperty(id, target, description, required, Type.ENUM, choices, null);
String id, Target target, String description, boolean required, List<Object> choices) {

List<String> strChoices = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

What about:
List<String> strChoices = choices.stream().filter(Objects::nonNull).map(Object::toString).toList();

@@ -117,7 +117,7 @@ static HttpOperationProperty fromSchema(String name, Schema<?> schema, Component

if (schema.getEnum() != null) {
return HttpOperationProperty.createEnumProperty(
name, Target.BODY, schema.getDescription(), true, (List<String>) schema.getEnum());
name, Target.BODY, schema.getDescription(), true, (List<Object>) schema.getEnum());
Copy link
Contributor

Choose a reason for hiding this comment

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

we can delete this cast

@@ -73,7 +73,7 @@ private static HttpOperationProperty fromSchema(Parameter parameter, Components
targetMapping.get(parameter.getIn()),
parameter.getDescription(),
parameter.getRequired() != null && parameter.getRequired(),
(List<String>) schema.getEnum());
(List<Object>) schema.getEnum());
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -33,8 +34,19 @@ public static HttpOperationProperty createStringProperty(
}

public static HttpOperationProperty createEnumProperty(
String id, Target target, String description, boolean required, List<String> choices) {
return new HttpOperationProperty(id, target, description, required, Type.ENUM, choices, null);
String id, Target target, String description, boolean required, List<Object> choices) {
Copy link
Contributor

Choose a reason for hiding this comment

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

List choices => List<?> choices, then we can delete the casts (see my next comments)

@johnBgood johnBgood added the kind:bug Something isn't working label Mar 29, 2024
@upgradingdave
Copy link
Author

Thanks for your review @johnBgood! I'll go thru and update the code per your suggestions asap.

I was able to import the element template json into Camunda Web Modeler 🎉

Next step is to test it out in an actual process ... I'll keep you posted 🙂

@johnBgood
Copy link
Contributor

Hey @upgradingdave ✋ Just following-up, did you have any chance to test the changes in a process?
Maybe could we address the comments and merge the PR so that our users can enjoy this fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to parse integers found in enums in unqork open api spec
2 participants