belgif / rest-guide

REST Guidelines of Belgian government institutions
https://www.belgif.be/specification/rest/api-guide/
Apache License 2.0
24 stars 4 forks source link

Multiple and mixed media type guidelines #131

Open pvdbosch opened 1 year ago

pvdbosch commented 1 year ago

Elaborate guidelines on media types:

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>