-
Notifications
You must be signed in to change notification settings - Fork 125
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
SOAR-0009 - Typesafe multipart with streaming #369
Conversation
This is now in review and will run until Nov 15th. Forum link: https://forums.swift.org/t/proposal-soar-0009-type-safe-streaming-multipart-support/68331. |
Sources/swift-openapi-generator/Documentation.docc/Proposals/SOAR-0009.md
Outdated
Show resolved
Hide resolved
+1 It would be an enrichment to have the multipart generator merged in a timely manner. Good work! |
@nkarczmarzyk Just to keep you reassured, the work has already begun and several PRs have been landed into the runtime package to provide the necessary support. The generator PR will follow. |
@nkarczmarzyk As Si said, this work is already ongoing. I'm glad you're looking forward to it, it's a large feature with substantial changes in the generator, so once we release 1.0.0-alpha.1 next week, it would be great if you could give it a try in your project - we want to catch any final issues before publishing 1.0.0 two weeks later. @simonjbeaumont - can you update the review please? It already finished, so this and the forums post can be updated. |
I am looking forward to it. I also took a look on the feature (wip) PR #366 . Great work in there! Seems like a very complex topic. When it is ready for testing, I will give it a try and give feedback. Until then I am trying to implement a workaround. |
I just got everything working end to end, so you can try the |
@czechboy0 I have found https://github.com/czechboy0/swift-openapi-generator/tree/hd-multipart for the generator. Could you please give me an hint where to find hd-multipart-converter-methods for the runtime? |
Since I wrote that comment, we already landed it all on main - so you can use that branch. |
I really don't want to blow up this pr but currently it seems like something is broken. Using latest of your forked generator (hd-multipart branch) and latest runtime I am getting the following result. open-api.yaml (v3.0.1):
Generated type:
It is also possible that I am doing something wrong. I am quite new to the world of swift. |
@nkarczmarzyk Try to remove the |
Also, the request body must be marked as required, multipart bodies cannot be optional (which is the default). |
One more question, is the generator emitting any diagnostics when running? That could hint at why it's skipping the content. |
@nkarczmarzyk I verified in your example, that you just need to add |
@czechboy0 Thanks for the advice. Setting |
Hey @czechboy0 hope you had a great weekend. I am off testing again. Currently its very complicated to initialise the components in the correct way but I will report if I got more results. Currently my code looks like this:
|
@czechboy0 I just found out that you are not passing the correct parameter type in https://github.com/apple/swift-openapi-generator/blob/main/Sources/swift-openapi-generator/Documentation.docc/Proposals/SOAR-0009.md. Instead of: It should be: |
@czechboy0
Couldn't I just pass any HTTPBody as payload, which is independent of the OpenAPI definition type? |
Streaming types, such as raw strings and raw bytes are represented by the HTTPBody type. If you instead had, for example, a JSON object as a multipart part, you'd get a fully typesafe Codable struct generated. |
Right, I'd probably write it like this instead:
|
Motivation
Ready for a review, see rendered at: https://github.com/czechboy0/swift-openapi-generator/blob/hd-soar-0009/Sources/swift-openapi-generator/Documentation.docc/Proposals/SOAR-0009.md
Modifications
N/A
Result
N/A
Test Plan
N/A