Skip to content

Commit

Permalink
Fix required #TASK-5914
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfeSanahuja committed Jan 16, 2025
1 parent 0657a2f commit 5840fdc
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ private List<Parameter> extractParameters(java.lang.reflect.Method method, Strin
// Procesar parámetros individuales del método
for (java.lang.reflect.Parameter methodParam : method.getParameters()) {
// Procesar ApiParam
// 4.1 Ignore all method parameters without @ApiParam annotations
Parameter parameter = new Parameter();
ApiParam apiParam = methodParam.getAnnotation(ApiParam.class);
if (apiParam == null || apiParam.hidden()) {
continue;
Expand All @@ -147,37 +149,36 @@ private List<Parameter> extractParameters(java.lang.reflect.Method method, Strin
// Procesar PathParam
PathParam pathParam = methodParam.getAnnotation(PathParam.class);
if (pathParam != null) {
Parameter parameter = new Parameter();
parameter.setName(pathParam.value());
parameter.setIn("path");
parameter.setDescription("Path parameter: " + pathParam.value());
parameter.setDescription(pathParam.value());
parameter.setRequired(true);
parameter.setType(methodParam.getType().getSimpleName().toLowerCase(Locale.ROOT));
parameters.add(parameter);
}

// Procesar QueryParam
QueryParam queryParam = methodParam.getAnnotation(QueryParam.class);
if (queryParam != null) {
Parameter parameter = new Parameter();
parameter.setName(queryParam.value());
parameter.setIn("query");
parameter.setDescription("Query parameter: " + queryParam.value());
parameter.setRequired(false); // Por defecto, no requerido
parameter.setDescription(queryParam.value());
parameter.setRequired(apiParam.required());
parameter.setType(methodParam.getType().getSimpleName().toLowerCase(Locale.ROOT));
parameters.add(parameter);
}

FormDataParam formDataParam = methodParam.getAnnotation(FormDataParam.class);
if (formDataParam != null) {
Parameter parameter = new Parameter();
parameter.setName(formDataParam.value());
parameter.setIn("query");
parameter.setDescription("Query parameter: " + formDataParam.value());
parameter.setRequired(false); // Por defecto, no requerido
parameter.setDescription(formDataParam.value());
parameter.setRequired(apiParam.required());
parameter.setType(methodParam.getType().getSimpleName().toLowerCase(Locale.ROOT));
parameters.add(parameter);

}

parameter.setDefaultValue(apiParam.defaultValue());
parameter.setDescription(StringUtils.isEmpty(parameter.getDescription())?apiParam.value():parameter.getDescription());
parameters.add(parameter);
}

return parameters;
Expand Down

0 comments on commit 5840fdc

Please sign in to comment.