The primary purpose of this project is to illustrate how to properly create multipart/form-data POST requests with an api client, as generated from an openapi document using the swift-openapi-generator
library. This project isn't necessarily useful inandof itself, but it should serve as a helpful starter to building client libraries that can POST efficiently.
This project is currently configured to use a sample glitch backend:
- Running project:
https://swift-openapi-generator-multipart-formdata.glitch.me
- Server code:
https://glitch.com/edit/#!/swift-openapi-generator-multipart-formdata
To run:
swift run MultipartCli --image "path/to/image" --description "File description"
There is an optional additional parameter --endpoint
, which allows the setting of an arbitrary endpoint. This is useful for testing against localhost or another backend besides the above sample glitch.com host.
Prior art:
- swift-openapi-generator ContentTypesClient example
- runway's great article talking about generating clients
- brightdigit's blog post which clearly illustrates the value of curated responses
- Simon Støvring's blog post on how shape.dk has adjusted to using clients, and the challenges of auto-generation
- Denis Dzyubenko's multipart example of posting to Lemmy's backend, pointing to his sample repo.