-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Swagger Docs generated do not show added schemas as models #225
Comments
How should the model be included in swagger file? We are literally doing nothing about those right now. |
Yes, I would propose a path to mapping those to “definitions”. Sounds like a good chance for me to dive in, I’ll get started and see what I can come up with, |
awesome!
Il 13 feb 2020, 14:11 +0100, John Wolfe <notifications@github.com>, ha scritto:
… Yes, I would propose a path to mapping those to “definitions”. Sounds like a good chance for me to dive in, I’ll get started and see what I can come up with,
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Okay, so upon initial inspection, I definitely see a path to this by hooking into the After looking through the code, I missed something super obvious that could possibly just be covered in a slight documentation update (Swagger gurus - not me 🤣 probably would never need it). The update (at least in my mind) would be to simply mention that the It definitely solves the issue I'm having as models would not need to be dynamic (at least not that I can think of), and the implementation of this feature could even lead to confusion as to why it's necessary in the first place. I realize you may have known all of this already, and might think there is value in this feature still. If so, I would love to do it! If you would let me know your thoughts when you have a chance, that would help a lot. If we decide the feature may not be worth it, I might try to make a small PR to include an example definition in the documentation. |
I don't know really, if you'd like to contribute this, we can definitely do it behind an option. |
Okay, I'm going to think on the use case a bit more and circle back to this. In the meantime, I'll separately submit a PR to add an example |
thanks!
Il giorno gio 13 feb 2020 alle ore 16:43 John Wolfe <
notifications@github.com> ha scritto:
… Okay, I'm going to think on the use case a bit more and circle back to
this. In the meantime, I'll separately submit a PR to add an example
definitions to the readme.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#225?email_source=notifications&email_token=AAAMXY2OTNN5NTNPQJVR2LLRCVTAXA5CNFSM4KUH725KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELVPF7Y#issuecomment-585822975>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMXY273QSF2M4GHHO7CALRCVTAXANCNFSM4KUH725A>
.
|
@wolfejw86 |
Yeah I agree, it's a little more work to get it back to the definitions configuration, but not much. My 2 cents is that this issue could be closed since it's relatively easy to achieve the desired outcome with the code as is. |
I am having huge problems referencing a model saved in definitions. definitions: {
user: {
type: 'object',
properties: {
surname: {type: 'string'},
lastname: {type: 'string'},
birthday: {type: 'string', format: 'date'},
email: {type: 'string'},
street: {type: 'string'},
city: {type: 'string'},
zip: {type: 'number'},
phone: {type: 'string'},
mobile: {type: 'string'},
password: {type: 'string'}
}
}
} How do I reference this model from my route?
'Failed building the validation schema for POST: /users, due to error can't resolve reference #/definitions/user from id #' |
Any news on this issue? |
Setting definitions in swagger options works for simple schemas but when you have |
Similar issue here, although it's nearly working. When you use the |
Looks like the |
It is, but I don't have a timeframe to work on that feature right now If you would like to revamp that PR it is appreciated |
I'm a bit late here. Anyway to explain: if you define schemas in your swagger options, fastify is not aware of them so you can't use in your route's schema. For sure, it is doable to arrange a PR to call:
Working on it. {
$id: "User",
title: "SHOW ME ON SWAGGER UI", // <-------- here
type: "object",
required: ["id", "firstName", "lastName", "email"],
properties: {
id: { type: "string", format: "uuid" },
firstName: { type: "string" },
lastName: { type: "string" },
email: { type: "string", format: "email" }
}
} |
@brandondoran I've been tripped up by this behavior as well. Did you manage to find a solution? |
Feature Request
While fastify-swagger is great for schemas attached to routes, I also would expect to be able to leverage it for displaying the models independent of the routes (usually shown at the bottom of the generated swagger-ui). When I call
fastify.addSchema
on one of my reusable schemas, I would expect it to show up as a model.To Reproduce
Steps to reproduce the behavior:
fastify-cli
Paste your code here:
2. change the
app.js
file to the following (basically copy / pasted from fastify-swagger + my example of trying to use the schema to display a modelExpected behavior
I would expect the added schema would show up as a model at the bottom of the generated swagger-ui
Paste the results here:
Your Environment
The text was updated successfully, but these errors were encountered: