-
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
Detect invalid use of binary properties in JSON object schemas #701
Comments
Discussed offline, examples of how to write multipart requests/responses that include raw bytes and also JSON are here: https://swiftpackageindex.com/apple/swift-openapi-generator/1.5.1/documentation/swift-openapi-generator/soar-0009#Describing-a-multipart-request-in-OpenAPI No bug identified in the generator here, closing. |
So ... we were holding it wrong ... but the generator also did happily produce non-compiling code ... isn't that considered a bug? |
The generator strives to always generate valid Swift code for valid OpenAPI documents. We do want to get as close to 100% as possible on that metric. That's separate from always erroring out on invalid OpenAPI documents, I'd consider that "best effort", but doing that very reliably would require some very sophisticated analysis of the OpenAPI document that we currently don't have, nor does OpenAPIKit provide to us. That said - if you identify a specific scenario that's relatively easy to detect in the generator and always leads to non-compiling code, please do file an issue (or even better, a PR). But it really depends on how much complexity detecting the scenario will add to the generator. If it's relatively localized, then we're likely to take it, but if it requires global knowledge, we might not (based on our third principle). |
@MahdiBM we do some validation (in addition to OpenAPIKit) here:
|
I mean, it doesn't really affect me anymore since I've already encountered this problem and know what to do to resolve it, but it looks to me that the issue should stay open unless the generator is happy with the non-compiling code? I know you're trying to keep the issues list clean, but a valid issue is a valid issue 🤷♂️. This issue also very clearly describes one of the situations that result in non-compiling code. The yaml code above is enough to trigger this behavior. IIRC i did try that exact minified yaml file before filing this issue. |
Sounds good, I've reopened and renamed the issue to track the exact case you reported. A schema that uses a binary property, without a multipart operation using it. That we can investigate emitting a diagnostic for. |
Just to confirm - you didn't get any diagnostic from the generated already, right? No warnings emitted during the build? |
Can't properly recall off-hand but i do think I didn't get any warnings. |
Description
Compiler error for generated code related to binary content encoding.
See below for a quick repro.
the error is:
Reproduction
Package version(s)
generator 1.3.0
runtime 1.5.0
Expected behavior
code should compile
Environment
irrelevant but Swift 6, M-series mac.
Additional information
No response
The text was updated successfully, but these errors were encountered: