-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Edge cases with FormData body conversion #1585
Comments
Minor update: |
Hi @ntjess, are you able to provide the relevant part of your OpenAPI spec? |
Perfect, thank you! |
related #1590 and possible workaround |
Hey @ntjess can you try the build in #1609? It won't actually produce the example value you provided which is why I want you to try it.
This might be difficult to get right for nested structures as different backends might expect different serialization, but let me know! |
You might need to check out that branch locally, the build step for dependencies isn't good enough yet so the new packages didn't get published |
I tried out Does the provided zip template + instructions work for you to verify? I attempted to set it up on StackBlitz but the python backend doesn't support installing FastAPI and I don't have familiarity with node server frameworks |
@ntjess you'll need to install the client locally, openapi-ts doesn't need to be updated, the fix is in the client code. See my previous message about packages not being published properly! You could also copy-paste the updated function into SDK and see if it works with that |
My apologies, I'm not a js/ts dev so this is new for me. I cloned npm i ./openapi-ts Which produced several critical warnings: npm i ./openapi-ts
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
added 527 packages, and audited 529 packages in 3s
132 packages are looking for funding
run `npm fund` for details
3 high severity vulnerabilities
To address all issues, run:
npm audit fix --force
Run `npm audit` for details. I tried to recreate the api with Hopefully I'm just missing something simple, but how do I run the Thanks! |
@ntjess no worries! It will be way simpler if you copy-paste formDataBodySerializer from the pull request and pass it manually to your SDK call. That way you can test if the serialized data gets accepted by your server https://github.com/hey-api/openapi-ts/blob/fix/form-data-body-serializer/packages/client-core/src/bodySerializer.ts Also check out my 2 questions in #1585 (comment) |
axios
All my encountered cases are with 2D lists inside a toplevel dict. The real-world use case is providing x-y polygons to a backend during image segmentation requests. So the payloads are: {
image: "blob",
foreground_xy: [[1,2], [10, 2], ...],
background_xy: [],
} The problems occur when either list contains just one point.
I did this, but the
Again, apologies if this is straightforward; I'm just unfamiliar with the normal procedure |
Description
When hey-api converts a body payload into a form for
multipart/form-data
, nested arrays with one element lose their distinction as nested upon serialization. Instead, they look like the unnested data type. It is due to this code (and its equivalent for other backends):openapi-ts/packages/client-axios/src/utils.ts
Line 498 in 7098555
When only one value exists, the form has no indication to wrap the inner element as a list and instead treats it as a single list
Reproducible example or configuration
repro-heyapi.zip
./run_frontend_backend.sh
and open localhost:5173 in browserTo regenerate the hey-api client api, ensure the fastapi server is running (it provides the openapi file), and run
npx openapi-ts
OpenAPI specification (optional)
3.1.1
System information (optional)
macos
The text was updated successfully, but these errors were encountered: