-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Recursive rendering needs work #3325
Comments
@julienkosinski thanks, I'll get this triaged on Monday 😄 |
Here's a screenshot of another example I was testing (screenshot was made using v3.3.1). The structure of the schema object for the “containingFolder” attribute for “Folder” is similar to the one for “resourceFork” for “File”; I’m guessing the reason that it’s not shown that “containingFolder” is another “Folder” is due to the circularity. Here’s the OpenAPI object:
|
I'm not sure if there's a way to combine |
@hkosova, I had missed that, thanks for pointing it out!
I’m not sure that adding
|
@Rinzwind can't think of a different way to express it. |
Thanks for the feedback. I’ve posted an issue for it at the OpenAPI Specification repository. |
Could you also use "allOf" . ? If so, would there be a difference between using the `anyOf`` method?
|
|
@webron: I am not sure whether the example given by @jonschoning has the intended semantics. The section on “allOf” in the JSON Schema Validation proposal says: “An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.” As far as I understand,
In other words, in @jonschoning's example, |
@Rinzwind at the same time that allOf is interpreted the ref is dereferenced, so the net effect results in the nullable being a part of the refs definition. You can check this understanding by considering how allOf works with appending properties to a ref with allOf |
Actually, @Rinzwind's point is correct, and that won't work. However, using |
@webron I have a hard time finding a working example of how nullable works as it's not present in https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v3.0 |
If you find that an example is missing, feel free to open an issue on that repo. Not really sure what's not clear about it though. |
@jonschoning As far as I understand, the following is meant by “Allows sending a Rewording the definition according to the terminology employed in JSON Schema Validation (using in particular the wording for “uniqueItems” as inspiration):
I hope that helps. Keep in mind though that this is not a direct quote from the specification, but just my understanding of it. Edit: I'm not quite sure whether my rewording in JSON Schema Validation terms is correct. It seems it would not imply that |
Ok, I understand how, thank you. It seems one cannot simply specify a ref should be nullable then with anyOf or allOf without also changing what validates per Ron's comment |
Indeed, as far as I understand, a schema like |
Hi, api spec
Reply property in above spec is shown in swagger ui like - Any update on this issue? |
@StenCalDabran Interesting detail about your example: I just took this to the Swagger Editor (https://editor.swagger.io/) to see if it would resemble a similar issue I am having. I noticed the 'components' part was written before the 'paths' part. When I switched the order of those two (parts before components) it would render correctly in both places. |
@vanDarg Very interesting indeed, thanks for pointing that out. I opened an issue in the nestjs/swagger repository (nestjs/swagger#1369), maybe it is possible to automatically generate the document in the other order in the first place - which of course would only mitigate the actual problem. |
Ensure that the paths property comes before the components property, as this may lead to several strange display bugs in swagger-ui. See swagger-api/swagger-ui#5972 or swagger-api/swagger-ui#3325 (comment) Closes nestjs#1369
4 years have already gone by, guys/gals any progress with this issue? |
Yeah, appears to still be an issue... created small reproduction based on example in first comment: https://gist.github.com/ponelat/e3e7e3e55247ef6d2cd09926bbeb4241 |
This issue may have been fixed? I was going to attempt a fix, but checking out the latest swagger-ui it wasn't reproducible. |
At least the example I built (see my previous reply) still does not work with the swagger editor, which seems to use the latest swagger-ui. If the original issue is indeed resolved, I could open a new issue, but they seem to have similar root problems. |
Hello, |
This is still a problem in 4.5.0. Here's a minimal OAS that reproduces it. {
"openapi" : "3.0.1",
"info" : {
"title" : "Recursive Failure",
"version" : "1.0"
},
"paths" : {
"/test" : {
"get" : {
"responses" : {
"200" : {
"description": "Recursive example",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/test-response"
}
}
}
}
}
}
}
},
"components" : {
"schemas" : {
"test-response": {
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"bar": {
"$ref" : "#/components/schemas/test-response"
}
}
}
}
}
} Here's what I see in swagger ui when I expand the Here's how the example is rendered: {
"foo": "string"
} And here's how the schema is rendered when expanded: |
Recursive schemas are still rendered incorrectly as |
Hi, |
Just to put it outhere, some of the schemas from this bug report do render correctly, namely the initial bug report seems to be solved. Some are still not rendered correctly. I am using https://editor-next.swagger.io/ to test. |
Hello,
|
Hello, I'm facing similar issues like described here #3325 (comment) is there solution for it? |
still no solutions here? |
This is still unsolved. |
+1 Same story and it's strange situation, when we use swagger-ui it's throw this error... BUT... when we use same swagger definition with this https://springdoc.org/ no error... Please fix this, since it's create unnecessary questions/confusion for developers that use it. I hope maintainers of this project very deep in context and able to find reasons for it as same as fix |
In my experience Redoc and RapiDoc does not have this issue and also works with OAS 3.1 which swagger ui does not. So we use those instead. |
+1 we need to render inheritance structure like this: public class TimelineHolidayQueryModel : TimeLineQuery after second inheritance, codegen to get Typescript interfaces, stops rendering |
Hi, I have run into the same issue (thanks to different lib using swagger-ui). After some investigation I found out this issue was resolved in v5.11.8. |
## Description This PR updates the [swagger-ui](https://github.com/swagger-api/swagger-ui) to latest version (5.18.1). Provided version of swagger-ui cannot render recursive objects properly (they are rendered as empty objects). This bug was resolved in v5.11.8 (more context can be found here: swagger-api/swagger-ui#3325). I have tested this update in our projects and it seems to be OK 🤞. Cheers! ## What type of PR is this? (check all applicable) - [x] Bug Fix - [ ] Feature - [ ] Refactor - [ ] Deprecation - [ ] Breaking Change - [ ] Documentation Update - [ ] CI ## Checklist - [ ] I have made corresponding changes to the documentation (`docs/`) - [ ] I have made corresponding changes to the changelog (`CHANGELOG.md`)
## Description This PR updates the [swagger-ui](https://github.com/swagger-api/swagger-ui) to latest version (5.18.1). Provided version of swagger-ui cannot render recursive objects properly (they are rendered as empty objects). This bug was resolved in v5.11.8 (more context can be found here: swagger-api/swagger-ui#3325). I have tested this update in our projects and it seems to be OK 🤞. Cheers! ## What type of PR is this? (check all applicable) - [x] Bug Fix - [ ] Feature - [ ] Refactor - [ ] Deprecation - [ ] Breaking Change - [ ] Documentation Update - [ ] CI ## Checklist - [ ] I have made corresponding changes to the documentation (`docs/`) - [ ] I have made corresponding changes to the changelog (`CHANGELOG.md`) (cherry picked from commit b79abc1)
Hello,
I have the following model definitions spec:
In the
Feature
model, theEquipments
property is defined as an array ofEquipment
models, but Swagger UI 3.x renders it as an empty array[]
. EverywhereFeature
model is used, like as examples forPOST
method inFeature
I have this kind of display.We think it may be a bug caused by circular references. Thanks to Helen.
Thank you very much!
The text was updated successfully, but these errors were encountered: