Skip to content

Multipart/form-data server stub #1333

@kerner1000

Description

@kerner1000

Tell us the extension you're using

Server

I tried this:

I am trying to generate a server stub for a file upload endpoint. The contract looks like this:

/file/upload:
   post:
     tags:
       - file
     operationId: uploadFile
     requestBody:
       content:
         multipart/form-data:
           schema:
             type: object
             properties:
               file:
                 type: string
                 format: binary
               filename:
                 type: string
               description:
                 type: string
               categoryId:
                 $ref: '#/components/schemas/Id'
             required:
               - file
               - filename
     responses:
       '201':
         description: File successfully uploaded
         content:
           application/json:
             schema:
               type: object
               properties:
                 id:
                   $ref: '#/components/schemas/Id'
                 name:
                   type: string
                   description: The name of the file.
                   example: test.txt
                 description:
                   type: string
                   description: A description of the file.
                   example: A sample file
                 mimeType:
                   type: string
                 category:
                   $ref: '#/components/schemas/Id'

This happened:

The generated resource looks like this:

@Path("/file")
public interface FileResource {
  @Operation(operationId = "uploadFile")
  @Path("/upload")
  @POST
  @Produces("application/json")
  @Consumes("multipart/form-data")
  Response uploadFile(@NotNull InputStream data);
}

I am missing the additional properties, that are defined in the contract, i.e., filename, description, ...

I expected this:

I would expect the generated interface to look like this:

@Path("/file")
public interface FileResource {
  @Operation(operationId = "uploadFile")
  @Path("/upload")
  @POST
  @Produces("application/json")
  @Consumes("multipart/form-data")
  Response uploadFile(@NotNull InputStream data, String filename, String description, Long categoryId);
}

Is there a workaround?

No response

How can we try to reproduce the issue?

No response

Anything else?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus OpenApi version or git rev

No response

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

No response

Additional information

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.name: Bug Report 🐞

Metadata

Metadata

Assignees

Labels

area:serverThis item is related to the server extension

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions