Skip to content

Commit

Permalink
Merge pull request #868 from jpohlmeyer/fix-tool-required-param
Browse files Browse the repository at this point in the history
Evaluate 'required' attribute of @p annotation in tool for optional parameters.
  • Loading branch information
geoand authored Sep 11, 2024
2 parents 4a9c1a3 + ef73477 commit 6af9cba
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,14 @@ public void handleTools(CombinedIndexBuildItem indexBuildItem,
memoryIdParameter = parameter;
continue;
}
builder.addParameter(parameter.name(), toJsonSchemaProperties(parameter, index));

AnnotationInstance pInstance = parameter.annotation(P);
if (pInstance != null && pInstance.value("required") != null
&& !pInstance.value("required").asBoolean()) {
builder.addOptionalParameter(parameter.name(), toJsonSchemaProperties(parameter, index));
} else {
builder.addParameter(parameter.name(), toJsonSchemaProperties(parameter, index));
}
}

Map<String, Integer> nameToParamPosition = toolMethod.parameters().stream().collect(
Expand Down

0 comments on commit 6af9cba

Please sign in to comment.