uplink icon indicating copy to clipboard operation
uplink copied to clipboard

Auto-generete Consumer classes from an OpenAPI/Swagger Specification

Open prkumar opened this issue 5 years ago • 9 comments

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".

prkumar avatar Sep 21 '18 22:09 prkumar

I am working on adding uplink-based client SDK generation to OpenAPITools/openapi-generator.

This is my general plan:

  1. Manually write an uplink-based client based on a minimal spec (the spec does not include all OpenAPI features).
  2. Convert that client into templates for a new generator.
  3. Submit a WIP PR to OpenAPITools/openapi-generator.
  4. 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).

cognifloyd avatar Feb 19 '19 03:02 cognifloyd

any progress on this? I've generated a basic version of doing this that I'm planning on submitting to OpenAPITools/openapi-generator

michaelwiles avatar Jul 27 '21 08:07 michaelwiles

Any progress? Happy to help work on this - I'd suggest a separate python package and then submit usage onto OpenAPI client generator.

ghandic avatar Aug 17 '21 10:08 ghandic

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.

TimoGlastra avatar Aug 17 '21 10:08 TimoGlastra

@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

TimoGlastra avatar Aug 23 '21 12:08 TimoGlastra

Neat! Tbh it would probably be better to stick to using openapi-generator, that way you have more control of versioning etc

ghandic avatar Aug 23 '21 13:08 ghandic

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

TimoGlastra avatar Aug 23 '21 13:08 TimoGlastra

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

ghandic avatar Aug 23 '21 21:08 ghandic

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.

KDanisme avatar Jan 31 '23 15:01 KDanisme