Closed tjmonsi closed 2 years ago
You need to use static
mode, otherwise the paths
are override by @fastify/swagger
.
Hi @climba03003 Thanks for this. But for our usecase, we can't use static mode because the specification becomes too unwieldy if we put everything inside it (Thus, we opted to use import
and export
JS objects, with the occasional repeating of 4xx and 5xx errors on each path to complete the path documentation).
Static mode only accepts json
and yaml
- thus it may not work.
Tried it though on the simple setup that I made and it worked though. Although in relation to I think #667 , it becomes just a raw string input instead of a file upload feature.
Nevertheless, I am just curious as to why paths are being overrided by @fastify/swagger
to just application/json
even when explicitly showed to use multipart/form-data
and why static worked. - this is even if it shows that when using components/requestBodies/[[referenceIdWithMulitpart]]
as a $ref
, and it shows in the json output of the documentation site, it still doesn't show the multipart
What I can say though that the logic is not hampered, unless I put type: "object"
on the schema of the request body, which creates an error.
Your case is not related to #667.
I am just curious as to why paths are being overrided
fastify-openapi-glue
which will helps you create routes based on the specification
.dynamic
mode, @fastify/swagger
will helps you to fill paths
information based on the created
routes and the default requestBody
content-type
is application/json
. You need to use consumes
keyword to specify the requestBody
content-type
in dynamic
mode.By combining the above two situation, it is obvious your routes created fastify-openapi-glue
will override by @fastify/swagger
.
I see.
But there is no consumes
on OpenAPI 3.0 spec. In any case, thanks for letting me know about it
Prerequisites
Fastify version
4.7.0
Plugin version
7.6.1
Node.js version
16.17.1
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
5.15.0-47-generic
Description
When writing an OpenAPI 3.0.0 specification of a request body content on a path, it forces the content-type to
application/json
even if it is set tomultipart/form-data
.specification
Steps to Reproduce
npm i
npm start
http://localhost:8080/docs
multipart/form-data
and only showsapplication/json
even if it is not part of thesrc/specification.js
Expected Behavior
Expected is that the Request Body is not
application/json
on the documentations page butmultipart/form-data
with the corresponding inputs (like file upload)