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

openapi for RestResponse<Stream<T>> not automaticly documenting T #30248

Closed
Postremus opened this issue Jan 9, 2023 · 1 comment · Fixed by #31671
Closed

openapi for RestResponse<Stream<T>> not automaticly documenting T #30248

Postremus opened this issue Jan 9, 2023 · 1 comment · Fixed by #31671
Labels
area/openapi area/smallrye env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Describe the bug

The openapi for a resteasy-reactive resource like this is incorrect:

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public RestResponse<Stream<SomeObject>> hello() {
        return null;
    }

It documents the Stream class itself.

Expected behavior

I would expect the documentation to be generated as a List of SomeObject, i.e. the inner type of Stream.
This is also what the resource returns.

As workaround, I can annotate the method as follows, which produces the expected result:

@GET
    @Produces(MediaType.APPLICATION_JSON)
    @APIResponse(name = "200", content = @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = SomeObject.class)))
    public RestResponse<Stream<SomeObject>> hello() {
        return null;
    }

Which correctly produces:
image

However, always having to add type and implementation (and not forgetting them / making copy & paste mistakes) becomes a bit cumbersome.

Can Stream please be automaticly detected?

Actual behavior

image

How to Reproduce?

Reproducer:
restresponse-openapi.zip

  1. mvn quarkus:dev
  2. Go to http://localhost:8080/q/swagger-ui
  3. Look at the responses of the /hello resource - looks correct since the workaround is active
  4. Now go to class GreetingResource and remove the APIResponse annotation
  5. Go to http://localhost:8080/q/swagger-ui
  6. Look at the responses of the /hello resource - looks wrong

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.2364]

Output of java -version

openjdk 17.0.4 2022-07-19 OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8) OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\eclipse\tools\java\maven Java version: 17.0.4, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\17 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Postremus Postremus added the kind/bug Something isn't working label Jan 9, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 9, 2023

/cc @EricWittmann(openapi), @MikeEdgar(openapi), @phillip-kruger(openapi)

MikeEdgar added a commit to MikeEdgar/quarkus that referenced this issue Mar 7, 2023
- Handle method-level `@RolesAllowed` that override class-level
`@RolesAllowed` values, fixes quarkusio#30997
- Render `BaseStream<T, S>` as array of `T` in OpenAPI document,
fixes quarkusio#30248 (via smallrye-open-api 3.3.0)
- Do not place scopes in OpenAPI security requirements unless the
security scheme is OAuth2 or OIDC, fixes quarkusio#27373
- Include only OIDC discovery URL in OpenAPI when auto-security is
active, fixes quarkusio#21126

Signed-off-by: Michael Edgar <[email protected]>
MikeEdgar added a commit to MikeEdgar/quarkus that referenced this issue Mar 8, 2023
- Handle method-level `@RolesAllowed` that override class-level
`@RolesAllowed` values, fixes quarkusio#30997
- Render `BaseStream<T, S>` as array of `T` in OpenAPI document,
fixes quarkusio#30248 (via smallrye-open-api 3.3.0)
- Do not place scopes in OpenAPI security requirements unless the
security scheme is OAuth2 or OIDC, fixes quarkusio#27373
- Include only OIDC discovery URL in OpenAPI when auto-security is
active, fixes quarkusio#21126

Signed-off-by: Michael Edgar <[email protected]>
@gsmet gsmet closed this as completed in b11fae5 Mar 9, 2023
@quarkus-bot quarkus-bot bot added this to the 3.0 - main milestone Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/openapi area/smallrye env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant