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

Multiple and mixed media type guidelines #131

Open
pvdbosch opened this issue Jul 13, 2023 · 0 comments
Open

Multiple and mixed media type guidelines #131

pvdbosch opened this issue Jul 13, 2023 · 0 comments

Comments

@pvdbosch
Copy link
Contributor

pvdbosch commented Jul 13, 2023

Elaborate guidelines on media types:

  • multiple media types (with different schemas) in OpenAPI request/response: do we support it? See generator problems below.
  • list supported media types instead of generic */*
  • example with multipart/form-data
    • considerations: better efficiency than inline base64 binary
    • recommend to put all structured data in a JSON (instead of separate parts at root level)
    • specify encoding https://spec.openapis.org/oas/v3.0.3#encoding-object for non-default media type mappings
    • this is probably the most used multipart type. multipart/related can also be used but is less common; it supposed to be a root document which references annexes

Note that different schemas per media type aren't well supported by code generators (openapi generator). It just generates for the first specified media type and doesn't seem to take encoding spec into consideration.

Multiple schemas in input (JAX-RS):

     requestBody:
       required: true
       content:
         application/json:
           schema:
             $ref: "#/components/schemas/Request"
         application/octet-stream:
           schema:
             type: string
             format: binary

[WARNING] Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[WARNING] Multiple MediaTypes found, using only the first one

for response:

multipart/form-data response in spring generates the POJO with a schema and application/json Content-Type. To workaround:

          <schemaMappings>
                                <schemaMapping>Logo=org.springframework.util.MultiValueMap</schemaMapping>
                            </schemaMappings>
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