-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support APIReponse on resource class #1122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @MikeEdgar please also have a look :)
I think this looks good also. This can target |
I've pushed another commit to support I had a question while writing this: what's your approach for handling when the user does something invalid or ambiguous? In this case it's possible to put |
Typically in situations like that, one of the options is the one that is more "specific". Although in this case putting the annotation on the class is more in alignment with |
I hadn't considered that but I guess there's no reason an |
df2615a
to
10f10b6
Compare
I've rebased this on |
Thanks @Azquelt . Once the MP 3.1 snapshot includes this, we can double-check here that they pass before merging. |
10f10b6
to
b10a7e0
Compare
if (!this.responseCodeExistInMethodAnnotations(context, exMapperApiResponseAnnotation, | ||
methodApiResponseAnnotations)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we would allow an exception mapper to override class-level responses, but not method responses. This makes sense I think 👍
// public static AnnotationInstance getResponseAnnotation(final ClassInfo classInfo) { | ||
// return classInfo.classAnnotation(ResponseConstant.DOTNAME_API_RESPONSE); | ||
// } | ||
// | ||
// public static AnnotationInstance getResponseAnnotation(final MethodInfo method) { | ||
// return method.annotation(ResponseConstant.DOTNAME_API_RESPONSE); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove entirely?
Scan for APIResponse annotations on resource classes and merge any responses with those on the method. APIResponse annotations on the method override APIResponse annotations on the resource class with the same response code.
Read APIResponse annotations from ExceptionMapper classes as well as from their toResponse methods.
If the APIResponse annotation is used more than once on an exception mapper, use all annotations to generate responses rather than just the first one.
b10a7e0
to
8d60342
Compare
New |
@Azquelt I think this may be good to merge as-is. Let me know if you're planning any other updates on this one. |
Scan for
APIResponse
annotations on resource classes and merge anyresponses with those on the method.
APIResponse
annotations on the method overrideAPIResponse
annotationson the resource class with the same response code.
Implementation for eclipse/microprofile-open-api#524 I've opened this as a draft against the
jakarta
branch because it requires API updates planned for MP OpenAPI 3.1.