reta commented on a change in pull request #14: The AnnotationProcessor should
be able to deduct the parameter name from JAX-RS annotations
URL: https://github.com/apache/geronimo-openapi/pull/14#discussion_r272987808
##########
File path:
geronimo-openapi-impl/src/main/java/org/apache/geronimo/microprofile/openapi/impl/processor/AnnotationProcessor.java
##########
@@ -881,18 +882,32 @@ private Encoding mapEncoding(final
Supplier<org.eclipse.microprofile.openapi.mod
}
if (annotatedElement != null) {
if (annotatedElement.isAnnotationPresent(HeaderParam.class)) {
+ final HeaderParam annotation =
annotatedElement.getAnnotation(HeaderParam.class);
impl.in(org.eclipse.microprofile.openapi.models.parameters.Parameter.In.HEADER);
+ mapParameterName(impl, annotation.value());
} else if
(annotatedElement.isAnnotationPresent(CookieParam.class)) {
+ final CookieParam annotation =
annotatedElement.getAnnotation(CookieParam.class);
impl.in(org.eclipse.microprofile.openapi.models.parameters.Parameter.In.COOKIE);
+ mapParameterName(impl, annotation.value());
} else if (annotatedElement.isAnnotationPresent(PathParam.class)) {
+ final PathParam annotation =
annotatedElement.getAnnotation(PathParam.class);
impl.in(org.eclipse.microprofile.openapi.models.parameters.Parameter.In.PATH);
+ mapParameterName(impl, annotation.value());
} else if (annotatedElement.isAnnotationPresent(QueryParam.class))
{
+ final QueryParam annotation =
annotatedElement.getAnnotation(QueryParam.class);
impl.in(org.eclipse.microprofile.openapi.models.parameters.Parameter.In.QUERY);
+ mapParameterName(impl, annotation.value());
}
}
return impl;
}
+ private void mapParameterName(final ParameterImpl impl, final String name)
{
+ if (StringUtils.isEmpty(impl.getName()) && !StringUtils.isEmpty(name))
{
Review comment:
Yes, name could be empty, one of legitimate examples is `@QueryParam("")`
when binding to the bean class is used.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services