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

Support inheritance for BeanParam and MultipartForm #239

Closed
SetoKaiba opened this issue Dec 24, 2019 · 14 comments · Fixed by #287
Closed

Support inheritance for BeanParam and MultipartForm #239

SetoKaiba opened this issue Dec 24, 2019 · 14 comments · Fixed by #287
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@SetoKaiba
Copy link

SetoKaiba commented Dec 24, 2019

I have forms for resteasy. The token and os is missing in the openapi and swagger-ui.
The json schema is without problem. But the forms isn't.
What should I do to make it correct in the openapi?

public class Verify {
    @FormParam("token")
    public String token;
    @FormParam("os")
    public String os;
}

public static class UploadIconForm extends Verify {
    @FormParam("icon")
    public byte[] icon;
}
@MikeEdgar
Copy link
Member

Hi @SetoKaiba - please post the JAX-RS method where the Verify or UploadIconForm is used. Please also post the resulting OpenAPI JSON that is incorrect.

@MikeEdgar MikeEdgar added the question Further information is requested label Dec 24, 2019
@SetoKaiba
Copy link
Author

I found out the problem. When I use @Form, the params from the parent is there. When I use @MultipartForm from, the params from the parent is missing.

@SetoKaiba
Copy link
Author

SetoKaiba commented Dec 24, 2019

Change the @MultipartForm to @Form, it will contain the token and os from Verify. But then it doesn't support multipart form data.

    @Path("/uploadUserAvatar")
    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Result uploadUserAvatar(@MultipartForm UploadIconForm form) {
    "/rest/user/uploadUserAvatar" : {
      "post" : {
        "requestBody" : {
          "content" : {
            "multipart/form-data" : {
              "schema" : {
                "type" : "object",
                "properties" : {
                  "icon" : {
                    "type" : "array",
                    "items" : {
                      "format" : "byte",
                      "type" : "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "description" : "OK",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Result"
                }
              }
            }
          }
        }
      }
    },

@MikeEdgar
Copy link
Member

@SetoKaiba - the OpenAPI parameter scanner currently does not support inheritance on types annotated with @BeanParam or @MultipartForm. Please try to annotate your JAX-RS method with @RequestBody(content = @Content(schema = @Schema(implementation = UploadIconForm.class))) to get the desired output.

We can leave this issue open as a task to enhance the scanner to support inheritance on those types of requests in the future.

@MikeEdgar MikeEdgar changed the title Form inheritance problem? Support inheritance for BeanParam and MultipartForm Dec 27, 2019
@MikeEdgar MikeEdgar added enhancement New feature or request and removed question Further information is requested labels Dec 27, 2019
@SetoKaiba
Copy link
Author

Thank you. It does help. At least, it's correctly show the openapi and swagger-ui now,

@phillip-kruger phillip-kruger self-assigned this Feb 12, 2020
@sean-scott-lr
Copy link

sean-scott-lr commented Apr 5, 2020

@MikeEdgar I believe that mislabelling this as an enhancement has caused this issue to not receive the appropriate priority. @BeanParam supports inheritance and the APIDoc does not appropriately reflect the inherited parameters.

Also, I am using @QueryParam and the suggested workaround for this issue does not seem to work for me. Should it? If not, is there another workaround I can use for @QueryParam?

Thank you

@MikeEdgar
Copy link
Member

@sean-scott-lr, I understand your point, but from an annotation scanning perspective it is an unimplemented feature rather than one that is just not working properly. Granted, it is not working as users expect.

@FormParams are treated slightly differently by the scanner, which is the reason the work-around mentioned earlier will not work for the other types of JAX-RS parameters.

@phillip-kruger, where does this issue fall in your list of priorities? I'm happy to take a deeper look at it also if you want to reassign it to me.

@phillip-kruger
Copy link
Member

Thanks @MikeEdgar !

@MikeEdgar
Copy link
Member

Based on the uncertainty around how downstream servers will be incorporating the next major MP version, I think it makes sense for this change to be made to both master and 1.x. I anticipate having these changes ready in the next couple of days.

@SetoKaiba
Copy link
Author

Thank you so much.

@sean-scott-lr
Copy link

@MikeEdgar Thank you for fixing. I see its been merged to 1.x, When can we expect this to be in a release?

@MikeEdgar
Copy link
Member

@phillip-kruger - do you think it's time for a 1.x release? I think it would be good to make the latest fixes on 1.x generally available.

@phillip-kruger
Copy link
Member

Sure ! Let's do it.

@sean-scott-lr
Copy link

Great, thank you. Hopefully Quarkus can pull it into 1.4.0

@MikeEdgar MikeEdgar added this to the 1.2.2 milestone Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants