-
Notifications
You must be signed in to change notification settings - Fork 20
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
Resolver error with fastify v3 #30
Comments
other downstream libs probably also need some changes: fastify/fastify-static#127 |
The /documentaiton/json in fastify v2 looked like this: and with fastify v3 (+ $ref) it looks like this: maybe @Eomm can help? Seems like 'uuid#' in v2 was resolved before the |
@adrai It didn't resolved in on route hook, it resolved after, when Here are some links where you can find more details: Maybe we just need a method in fastify that will allow to get schema object by id. Actually there's already https://github.com/SkeLLLa/fastify-oas/blob/master/lib/openapi/index.js#L5 that allows to get all schemes, but in fastify v2 it works only if schema was added via PS: also fixing this could be copy-pasted to fastify-swagger module, cause it uses absolutely the same approach. |
ok, nevertheless... this is not getting resolved anymore...
hehe so if fastify-oas or fastify-swagger get's fixed for v3 the other get's fixed too ;-) |
I don't know exactly the problem here for oas. In fastify-swagger all the schemas added with |
I don't understand this issue unfortunately :(.
I do not understand what the problem is and what the fix will be. |
Added a test in my fastify fork: for v3 this changed: I don't know if this is an issue or "by design" |
That's by design and part of some of the changes @Eomm made. I would recommend to open an issue on the fastify tracker to discuss. I think fastify/fastify#2166 is supposed to fix that. |
I'll try to explain what is happening
this
this code "by design" we remove the non standard "replace schema feature", here all the details fastify/fastify#2023 solutions for @adrai :
|
@Eomm thank you for the explanation. |
Some ideas. @adrai. I had an idea to make behaviour that "addModels" do default, so if you use addSchema, then it will appear in OpenAPI spec. But when schema is added it's hard to determine in which place it should be stored ( Instead of adding schemas when they are registered, we can add schemas when we find
3.1.1 If parsing body, then store in 3.2.
3.2.1 Data models should be added to Also there's other option that could replace [2]. When each instance is registered, this plugin should add a route that will expose schemas that it adds. And use "Remote Reference". If we have some "service" that's registered via
|
any updates? |
@SkeLLLa after I update |
In order to get this work with fastify v3, you'll need to setup fastify-oas@next. |
Hi @SkeLLLa This is probably a noob question. What do you mean The browser console shows an error message like this
at index.html:38:1 And index.html:38:1 points to the first line below <script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: resolveUrl('./json'),
validatorUrl: null,
oauth2RedirectUrl: resolveUrl('./oauth2-redirect.html'),
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region
window.ui = ui
function resolveUrl (url) {
const anchor = document.createElement('a')
anchor.href = url
return anchor.href
}
}
</script> |
@fyang1024 it looks like swagger-ui + browser bug. swagger-api/swagger-ui#3370. You can disable CSP in your browser. |
Indeed, I disabled csp and it shows the doc now, thank you. But that does not really solve the issue. It seems Swagger UI team does not want to address this issue. I see Java provides such a solution swagger-api/swagger-ui#3370 (comment). I wonder if |
Bump, still a problem for me. |
made a quick test....
changed
fastify: '>=2.0.0 <2.12.0 || >=2.12.1 <4.0.0'
when opening swagger ui, and clicking on any route having a
$ref
in the schema:example:
fastify changes: https://github.com/fastify/fastify/blob/master/docs/Migration-Guide-V3.md#changed-schema-substitution-2023
The text was updated successfully, but these errors were encountered: