Skip to content

How Can Swagger Identify Object Requests Containing Files #10392

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

Open
Mathias02 opened this issue Mar 31, 2025 · 0 comments
Open

How Can Swagger Identify Object Requests Containing Files #10392

Mathias02 opened this issue Mar 31, 2025 · 0 comments

Comments

@Mathias02
Copy link

Content & configuration

Swagger/OpenAPI definition:

# your YAML here

paths:
 /upload:
   post:
     summary: Upload indexed files
     requestBody:
       content:
         multipart/form-data:
           schema:
             type: object
             properties:
               files:
                 type: array
                 items:
                   type: object
                   properties:
                     file:
                       type: string
                       format: binary
                     title:
                       type: string
     responses:
       "200":
         description: Files uploaded successfully

Swagger-UI configuration options:

SwaggerUI({
  // your config options here
 url: "https://my-api.com/openapi.json",
 dom_id: "#swagger-ui",
 presets: [SwaggerUI.presets.apis],
 layout: "BaseLayout"
})
?yourQueryStringConfig
?defaultModelsExpandDepth=-1

Is your feature request related to a problem?

Yes!

Swagger UI does not support indexed form fields in multipart/form-data requests but many backend frameworks can handle form data with indexed object keys such as spring Boot etc. Currently, Swagger UI does not generate these indexed form fields, making it difficult to test APIs directly from the UI.

Describe the solution you'd like

Swagger UI should support indexed naming for form fields in multipart/form-data;
A. By allowing OpenAPI schemas to generate indexed form fields,
B. Ensure that these indexed fields are properly serialized in requests,
C. Improve the UI to handle dynamic form entries. e.g , "Add More" which should be a button to add new indexed fields).

Describe alternatives you've considered

1.Writing a custom frontend to handle indexed form requests.
2. Manually renaming fields (file_0, file_1), but this is not a real array,
3. Using Postman instead of Swagger UI for testing.

  • None of these solutions are ideal, as they require workarounds instead of a native Swagger UI implementation

Additional context

  • This feature would improve Swagger UI’s usability for APIs handling file uploads with metadata,
  • Many users have requested better support for multipart form arrays in OpenAPI,
  • This would eliminate the need for external tools like Postman when testing APIs.
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

1 participant