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 Spec wrong for "FileUpload" #40058

Closed
jackovsky8 opened this issue Apr 13, 2024 · 3 comments
Closed

Openapi Spec wrong for "FileUpload" #40058

jackovsky8 opened this issue Apr 13, 2024 · 3 comments
Labels

Comments

@jackovsky8
Copy link

jackovsky8 commented Apr 13, 2024

Describe the bug

If I use the class FileUpload in a Rest Service, it somehow overwrites the generated Openapi Specs.

I have a quarkus application where I defined a resource with two files in a multipart/form-data upload:

    @Path("v1")
    public interface IMultiPartResource {
    @POST
    @Path("/multipart")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_JSON)
    Object multipart(
        @RequestBody(
            description = "The multipart data.",
            required = true,
            content = @Content(
                mediaType = MediaType.MULTIPART_FORM_DATA,
                schema = @Schema(
                    type = SchemaType.OBJECT,
                    properties = {
                        @SchemaProperty(name = "data1", type = SchemaType.STRING, format = "binary"),
                        @SchemaProperty(name = "data2", type = SchemaType.STRING, format = "binary"),
                    }
                )))
        @NotNull @RestForm("data1") FileUpload data1,
        @RestForm("data2") Optional<FileUpload> data2,
    }

My Problem is, that the generated openapi spec is not correct. It produces something like:

    ---
      ...
      /clv-api/v1/importer/gino-production-data:
        post:
          requestBody:
            description: "The multipart data."
            content:
              multipart/form-data:
                schema:
                  type: object
                  properties:
                    data1:
                      $ref: '#/components/schemas/FileUpload'
                    data2:
                      $ref: '#/components/schemas/FileUpload'
            required: true
      ...
    components:
      schemas:
        FileUpload:
          type: object

But I expect something like that:

    ---
      ...
      /clv-api/v1/importer/gino-production-data:
        post:
          requestBody:
            description: "The multipart data."
            content:
              multipart/form-data:
                schema:
                  type: object
                  properties:
                    data1:
                      type: string
                      format: binary
                    data2:
                      type: string
                      format: binary
            required: true
      ...
    components:
      schemas:
        FileUpload:
          type: object

It works correctly, if a use the class "File".

Expected behavior

For it to not overwrite the Openapi Specs, like how it is supposed to work.

Actual behavior

See above.

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

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

mvn --version
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)

Additional information

No response

@jackovsky8 jackovsky8 added the kind/bug Something isn't working label Apr 13, 2024
Copy link

quarkus-bot bot commented Apr 13, 2024

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

@ramiswailem
Copy link

#39950

@phillip-kruger
Copy link
Member

Closing here. Duplicate

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

No branches or pull requests

3 participants