Only last schema is used for endpoints with multiple mimetypes
See original GitHub issueOnly last schema is being used for endpoints with multiple mimetypes: https://github.com/seriousme/fastify-openapi-glue/blob/a0269cfd605796baaf0d510b94e281b610346e75/lib/parser.v3.js#L71-L80
which contradicts the spec stating that Schemas can vary by media type.
Therefore, following sample spec will not consume text/plain
requests by throwing
{
"statusCode": 400,
"error": "Bad Request",
"message": "body should be object"
}
Sample spec:
openapi: 3.0.0
info:
version: 1.0.0
title: Test
paths:
"/test":
post:
summary: Multiple mimetypes payload
operationId: test
requestBody:
content:
text/plain:
schema:
type: string
application/json:
schema:
$ref: "#/components/schemas/TestMessage"
responses:
"200":
description: Message received
components:
schemas:
TestMessage:
type: object
nullable: true
properties:
id:
type: number
description: Id
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Investigate multiple schema case (different mime types) in ...
This feels wrong because when multiple Mime types are defined (like application/json or application/xml ) different Schemas can be returned.
Read more >MIME Types - Swagger
You can use the consumes and produces keywords to specify the MIME types understood by your API. The value of consumes and produces...
Read more >How many custom MIME types in a RESTful web API?
For example, GET "/customers/5" should only produce data that was serialized from your Customer entity.
Read more >What's the Difference Between OpenAPI Types 2.0, 3.0, and ...
A deep look into different OpenAPI versions starting from 2.0 to the latest release candidate.
Read more >MIME types (IANA media types) - HTTP - MDN Web Docs
MIME types are case-insensitive but are traditionally written in lowercase. The parameter values can be case-sensitive.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have just added a note to the README to clarify the topic.
Thanks for the input.
Kind regards, Hans
Thank you for the quick turnaround and support on the matter! I consider this case closed at the time.