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 generation content-type mismatch #34700

Closed
cescoffier opened this issue Jul 12, 2023 · 13 comments · Fixed by #36198
Closed

OpenAPI generation content-type mismatch #34700

cescoffier opened this issue Jul 12, 2023 · 13 comments · Fixed by #36198
Assignees
Labels
kind/bug Something isn't working triage/quarkus-3
Milestone

Comments

@cescoffier
Copy link
Member

Describe the bug

Let's consider the following endpoint (using spring compatibility, but it should not matter):

    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

The generated OpenAPI document has the following content:

---
openapi: 3.0.3
info:
  title: fortune-demo API
  version: 1.0.0-SNAPSHOT
paths:
  /hello:
    get:
      tags:
      - Hello Controller
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: string
components:
  securitySchemes:
    SecurityScheme:
      type: http
      description: Authentication
      scheme: basic

Two issues:

  1. I didn't setup anything related to security - so why it's there?
  2. the content type is wrong, it should be plain text in this case

(2) leads to be unable to use the Swagger UI as it gets a 405 HTTP response.

Expected behavior

It should provide the right content type and no security description.

Actual behavior

See description.

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

@cescoffier cescoffier added kind/bug Something isn't working triage/quarkus-3 labels Jul 12, 2023
@manofthepeace
Copy link
Contributor

sorry for the ping; @MikeEdgar @phillip-kruger would be nice if that could be looked into. This issue is still present in quarkus 3.4.1

@phillip-kruger
Copy link
Member

I think the default content type is json ? Or is this just for jaxrs? @geoand ?

@phillip-kruger
Copy link
Member

I'll have a look at this a.s.a.p

@geoand
Copy link
Contributor

geoand commented Sep 26, 2023

It's json in Quarkus when the return type is a POJO (or similar)

@phillip-kruger
Copy link
Member

Right, so the content type is correct even when using spring API we do this . The security is an issue though, I'll look at that

@phillip-kruger
Copy link
Member

O wait, only when pojo, not string. So this is an issue? Might event be an issue in jaxrs?

@phillip-kruger phillip-kruger self-assigned this Sep 26, 2023
@phillip-kruger
Copy link
Member

This is also an issue for jax-rs. I am looking at a fix

@rsvoboda
Copy link
Member

rsvoboda commented Oct 2, 2023

@cescoffier @phillip-kruger what about Uni<String>? Should it be treated as JSON or text?

@phillip-kruger
Copy link
Member

Probably yes. Same for Optional I guess

@rsvoboda
Copy link
Member

rsvoboda commented Oct 3, 2023

Probably yes

Yes for JSON?

@phillip-kruger
Copy link
Member

Sorry, no I mean text.

@rsvoboda
Copy link
Member

rsvoboda commented Oct 3, 2023

It's JSON now ... Will you create a PR to adjust that?

@phillip-kruger
Copy link
Member

Yes I will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/quarkus-3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants