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

Open API isn't handling arrays correctly #779

Closed
felipewind opened this issue Apr 14, 2021 · 5 comments · Fixed by #781
Closed

Open API isn't handling arrays correctly #779

felipewind opened this issue Apr 14, 2021 · 5 comments · Fixed by #781

Comments

@felipewind
Copy link

As @MikeEdgar requested in this issue on the Quarkus project, I openned this issue because I believe that Open API isn't handling arrays correctly.

I've created this project to test this situation - smallrye-open-api-test

My endpoint class:

public class ClientEndpoint {

    @GET
    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
    @Operation(summary = "List Clients", description = "List all Clients")
    @APIResponse(responseCode = "200", description = "Clients", content = {
            @Content(mediaType = "application/json", schema = @Schema(implementation = Client[].class)) })
    public Response getClients() {

My Client class that is used as the scheme:

import org.eclipse.microprofile.openapi.annotations.media.Schema;
public class Client {

    public Client(String name, Car car, Address... address) {
        this.name = name;        
        this.car = car;
        this.address = address;
    }

    private String name;

    // @Schema(implementation = Address[].class)
    private Address[] address;

    private Car car;
    // ....
    public static class Address {}
    public static class Car {}
    //...

Without the org.eclipse.microprofile.openapi.annotations.media.Schema annotation above, I receive the following error on the console:

$ mvn quarkus:dev
...
2021-04-14 16:47:06,958 WARN  [io.qua.arc.pro.BeanArchives] (build-43) Failed to index [Lorg.acme.model.Client$Address;: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader
....

And in the swagger-ui:
image

Errors
Resolver error at paths./clients.get.responses.200.content.application/json.schema.items.properties.address.items.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/Address does not exist in document

If I use the org.eclipse.microprofile.openapi.annotations.media.Schema annotation, everything works fine.

Sorry if I did something wrong!

@MikeEdgar
Copy link
Member

Thanks for reporting this. I'm not sure why you received the ARC error, but the OpenAPI scanner part should be resolved with the linked pull requests :)

@felipewind
Copy link
Author

Thanks for reporting this. I'm not sure why you received the ARC error, but the OpenAPI scanner part should be resolved with the linked pull requests :)

Thanks a lot @MikeEdgar :)

Should I close this issue?

@MikeEdgar
Copy link
Member

Should I close this issue?

No need, once the PR is reviewed and merged it will close automatically.

@felipewind
Copy link
Author

Should I close this issue?

No need, once the PR is reviewed and merged it will close automatically.

After this merge, do you know if the next release of Quarkus will have this improvement of the smallrye-openapi?

@phillip-kruger
Copy link
Member

@felipewind it should be in the next Quarkus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants