uplink
uplink copied to clipboard
Auto-generete Consumer classes from an OpenAPI/Swagger Specification
I've read a few posts of feedback (such as this Reddit comment) mentioning or asking for this support, so I've decided to open an issue to track the request.
Ideally, we would avoid adding this responsibility to this repository, to prevent "bloat". Rather, this should be the job of another library, which would (at least) depend on uplink
and some OpenAPI Specification "parser".
I am working on adding uplink-based client SDK generation to OpenAPITools/openapi-generator.
This is my general plan:
- Manually write an uplink-based client based on a minimal spec (the spec does not include all OpenAPI features).
- Convert that client into templates for a new generator.
- Submit a WIP PR to OpenAPITools/openapi-generator.
- Update the templates to support the petstore example.
I looked for a parser in python that parses both Swagger 2.0 and OpenAPI 3.0, but the libraries I found only supported one or the other. If there's a good parser that would allow me to skip using Java, then that would be great (to a point - for the project I'm working on, I also have to build server stubs in Java, so I can't escape it entirely).
any progress on this? I've generated a basic version of doing this that I'm planning on submitting to OpenAPITools/openapi-generator
Any progress? Happy to help work on this - I'd suggest a separate python package and then submit usage onto OpenAPI client generator.
On It! (I'm finishing the work @michaelwiles started). I have an initial version working, but still needs a lot of finishing touches for edge cases and making it ready for a PR.
I'd welcome contributions from your side. I'll push my latest changes and ping you when ready to see how we can collaborate.
@ghandic I've pushed an initial version over here: https://github.com/didx-xyz/openapi-generator/tree/feature/new-uplink-generator
It generates a working client but doesn't include the files you'd want to publish it as a package. Maybe that is something you can look at?
You can run it for the pet store example using a new python-uplink sample:
./bin/generate-samples.sh ./bin/configs/python-uplink.yaml
Neat! Tbh it would probably be better to stick to using openapi-generator
, that way you have more control of versioning etc
How would you handle the pusblishing of the generated client? Would you do that manually? Just curious
Currently how I use the generated code is I copy it to another project that has a requirements.txt with needed dependencies and consume it. Looking at the other generator sthey often add a generated requirements.txt, setup.py, pyproject.toml, etc... so you can install the generated client as a package into your project
I'd just use the same pattern as yourself. I'll try it out as soon as I can, unfortunately, the API I'm working with at the moment doesn't have a swagger spec... So might be a while
Is anyone on this? or should i have a crack at it? If you have done any progress with i t, it would be great if you could share.