-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Swagger and Redoc docs does not work for Litestar 2.12.1 #1086
Comments
Interesting. Is that our custom Swagger docs from Piccolo API, or just the built in Swagger docs for Litestar? |
Our custom Swagger docs and Admin (FastAPI app) work as expected. The error is only in the |
From the answer above (from Litestar issue), this problem will not be solved in Litestar because they are strict about def create_pydantic_model():
...
field = pydantic.Field(
json_schema_extra={"additional_properties": extra},
**params,
)
...
json_schema_extra_["additional_properties"]["help_text"] = table._meta.help_text Litestar Swagger docs works, but I haven't tried other frameworks. Also Piccolo Admin doesn't work because we will have to change all |
Thanks for investigating. I looked into a bit, but the docs aren't the easiest to understand. Here's one example where someone added extra properties: https://redocly.com/docs/api-reference-docs/spec-extensions In Piccolo v1, I namespaced all of our custom properties under Like you say, we will have to update Piccolo Admin too. |
Unfortunately, |
I'm not sure. I don't fully understand the purpose of Even though it stops Litestar from complaining, from the description here it sounds like it's used for declaring optional return types: https://www.apimatic.io/openapi/additionalproperties There's also a I think our options are:
|
I absolutely agree with you. I also don't fully understand that OpenAPI 3.1 spec. I really don't know which property field to use as a replacement for
We can try to use that, but from what I understand nothing will work for Litestar if it is not specified in their Schema. Any schema keys that are not in that schema will raise a ValueError and the Swagger docs will not be rendered. That's the main reason why I was trying to use
I agree with you. I don't know how much work that change requires, but it would be much more practical and less dependent on other people's work (changes in dependencies)
👍 |
OK, lets do option 3 for now then. It seems like option 1 might not even be possible. Which leaves us with option 2 as the long term fix. We could either:
I'm not sure which is least effort / cleanest. |
We have another option for Litestar. Since we are scaffolding a simple asgi application, we don't need to use |
@sinisaos Yes, that makes sense. We could add a small comment in the file for now saying that |
It's not a big change and I can include it in the same PR with the fix for Esmerald. Or should I do a separate PR for it? |
Do them as separate PRs if you don't mind - it makes it easier for tracking. |
I'm going to do a PR for Esmerald now, and I'll do another PR tomorrow. Is that okay? |
Yes, that's great - thanks. |
@sinisaos Do you think we should re-open this? I know we have kind of fixed it for now, but long term it might need more work? |
Or maybe we just open a new issue in Piccolo Admin linked to this one. |
@dantownsend Feel free to re-open this issue, but I don't know how to solve that problem with Litestar, except to replace the
I think that's a better idea since we talked about removing OpenAPI from admin. In Litestar Piccolo Admin works as expected, the issue was rendering of openapi docs generated from |
OK, I'll open a related issue in Piccolo Admin. |
Swagger
andRedoc
docs does not work with the latest version of Litestar. For now we can pin the version toLitestar==2.11.0
(latest working version). I will open an issue in the Litestar repo.The text was updated successfully, but these errors were encountered: