-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
Missing description when using $ref #795
Comments
@jean-michelet Would you be willing to help me with this issue? To briefly explain the issue. You can use Fastify with swagger as you know, using schemas. So I'm using
However, for some reason when going to the Fastify Swagger docs, the response description is not copied correctly and all the shared schemas will just show "Default Response" no matter what.. The reason you didn't saw this problem in your demo repo is because you aren't using the The same issue appears both in Swagger as well as Scalar. I suspect it's using the same code. |
Should we use |
If not, I don't know if I have time to fix this. Fastify mainteners usually don't fix bugs that don't affect them directly, expect security issues I guess. Can you push a PR with unit tests? |
Maybe not a bad idea.. It's a good example how you could re-use schemas in Fastify. |
I just went ahead and opened a PR to solve this - Hopefully it helps! 🎉 #826 |
Thanks @Nelspike! |
Prerequisites
Fastify version
4.26.2
Plugin version
8.14.0
Node.js version
20.11.1
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Linux Mint 23.1
Description
When adding shared schemas via
fastify.addSchema()
for response objects and using the id to access the schema like so:422: { $ref: 'internalServerErrorResponse#' }
, result in a missing description.Instead of the description displayed from the added schema, you will keep seeing "Default Response". When not using shared ref schemas, but adding the schema to the route schema, the description is taking into account. So it only doesn't work when using ref.
Steps to Reproduce
Using this schema by ID:
Going to the
/docs
for swagger, you will see:Expected Behavior
The description of the schema should be put in the response description as well, instead of showing "Default Response" (which is the fallback description text).
Code
I don't know the codebase, and
utils.js
is quite complex code. But I suspect to look around there:fastify-swagger/lib/spec/openapi/utils.js
Line 342 in fedf75c
The text was updated successfully, but these errors were encountered: