-
Notifications
You must be signed in to change notification settings - Fork 92
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
Discourse openapi.json generate issue #72
Comments
The details seem to be in the error description on the first line:
This error is coming from OpenAPIKit. |
I see it, the issue is in the OpenAPI doc for discourse. The Might also be worth pasting the doc into an OpenAPI linter first, in case there are other issues. |
Got it. So this should be a upstream issue from discourse_api_docs. I see there are many fix after it. But the fix also include upgrading the OpenAPI version from 3.0.3 to 3.1.0 2 years ago. See Fix spec errors and update search endpoint Hope swift-openapi-generator could support 3.1.x soon. |
The discussion of supporting OpenAPI v3.1.0 is tracked via #39. From #39 (comment), I see v3.1.x was supported in the history of swift-openapi-generator. Is there something we can config to reenable this feature? |
We have never supported 3.1, but it's certainly planned. Please comment in #39 about this use case, to make sure we can refer back to this thread. Otherwise, okay to close this issue in the meantime? |
Tried discourse openapi 3.1 file with my fork branch https://github.com/Kyle-Ye/swift-openapi-generator/tree/openapi_31x Still get the "items" issue. I suspect maybe there is something wrong with the underlying |
Can you try with the YAML file? That seems to have the correct nesting as far as I can see: https://github.com/discourse/discourse_api_docs/blob/main/openapi.yml#L173-L177 |
The JSON file also seems correct from my reading: https://github.com/discourse/discourse_api_docs/blob/main/openapi.json#L170-L176 What's the exact error you're getting? |
I've tried both formats. And they will give me the same error
|
Located the bug to be here https://github.com/mattpolzin/OpenAPIKit/blob/84f6702500fb00476d74420c1a0df64cddd3993e/Sources/OpenAPIKit/Schema%20Object/JSONSchemaContext.swift#L926 If we can't transform the issue(Since the 2 repo are not under the same team), I'll open issue on OpenAPIKit to track this.
items = try container.decodeIfPresent(JSONSchema.self, forKey: .items) // ❌ Throw Error |
Close and transform the issue to mattpolzin/OpenAPIKit#277 |
Thanks – as @mattpolzin mentioned on that issue, I think both Swift OpenAPI Generator and OpenAPIKit are doing the right thing, and the OpenAPI doc is not valid. I don't think we should relax the type strictness, we want issues like this to be surfaced and fixed, rather than ignored and spread to more docs through copy-paste. |
Discourse's openapi doc is generated by https://github.com/rswag/rswag. Maybe that repo is the final right place to report and fix the issue. 😂 |
Context
I'd like to migrate my existing DiscourseKit to use swift-openapi-generator
After I download the latest discourse openapi.json from discourse_api_docs/openapi.json
I found its version is v3.1.0 and the plugin just emits an error telling me only 3.0.x is supported.
Then browsing the history of the git repo, I tried to use the latest openapi.json with v3.0.3
from this commit discourse_api_docs/openapi.json
But the result still gives me an error message saying "The given data was not valid YAML."
Is there anything wrong with the upstream data? Or maybe there is a bug in swift-openapi-generator.
Reproduce code
Minimal reproduce code 👇
DiscourseKit.zip
The text was updated successfully, but these errors were encountered: