Forum Discussion

vinoths's avatar
Frequent Visitor
9 months ago

Documentation Query - Handling Multiple Media Types in Swagger/OpenAPI

Hello Team,

I hope this message finds you well. I'm currently working on documenting an API endpoint that can consume both `multipart/form-data` and `application/json` media types in a single request. I've been using Swagger/OpenAPI for documentation, and I've encountered some challenges in accurately representing this scenario.

To provide some context, here's the situation:

- I have an endpoint that allows clients to either send JSON data or upload a file using `multipart/form-data`.
- I'd like to document this endpoint effectively in Swagger, providing clear instructions on how to structure requests with either media type.

Here are my specific questions:

1. How can I properly represent an API endpoint that consumes both `multipart/form-data` and `application/json` media types using the Swagger/OpenAPI specification?
2. Are there specific annotations or practices I should follow to accurately document such a scenario in my API documentation?
3. Can you provide any examples or guidance on how to structure the Swagger annotations for an endpoint that handles both media types?

I greatly appreciate any assistance you can provide. Clear and accurate documentation is crucial for our API users, and I want to make sure we're representing this scenario correctly.

Thank you in advance for your help and guidance.

Best regards,
Vinoth S

No RepliesBe the first to reply