Skip to content

@Schema does not provide a property for: Properties[] properties #3433

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

Closed
stefan-huettemann opened this issue Jan 31, 2020 · 3 comments
Closed

Comments

@stefan-huettemann
Copy link

stefan-huettemann commented Jan 31, 2020

Hi.

I am using swagger-annotations:2.1.1.

According to swagger.io specs a configuration for a multipart file-upload would be:

"requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file_a": {
                    "type": "string",
                    "format": "binary"
                  },
                  "file_b": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }

This - in fact - would work and shows two file upload buttons in swagger-ui and sends a correct multipart-request to my server.

I cannot find any property in @Schema annotation to provide a properties section. What I came up with so far is:

@Operation(
            requestBody = @RequestBody(
                    content = @Content(
                            mediaType = MediaType.MULTIPART_FORM_DATA_VALUE,
                            schema = @Schema(
                                    type = "object"
                                    // -> properties[] is missing !!!
                            )
                    ))
    )

Why does @Schema not provide any means to add the properties section?

Best,
-Stefan

@Wizzercn
Copy link

Same question . Now Form parameters cannot be defined.

@Axiloom
Copy link

Axiloom commented Oct 14, 2021

Has there been any updates on this? My current workaround is to create a separate wrapper class like the following

requestBody = @RequestBody(
    content = @Content(
        schema = @Schema(implementation = <RequestBodyWrapperClass>.class)
    )
)

...

static class Example {
    @Schema(required = true, description = "<request body parameter description>", format = "binary")
    public File <request body parameter name>
}

@frantuma
Copy link
Member

#4129 introduces support to define Schema properties via annotations. Please see this and this examples for usage scenarios.

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

No branches or pull requests

4 participants