Open teamon opened 2 years ago
@teamon I was trying to achieve something similar (it is by no means finished). Maybe you'll find some inspiration?
this looks like a wonderful feature, I have been using openapi-generator before and encountered the same issues you have raised. watching with interest :)
Hey ! As a user of the openapi generator I must say that I really like your idea. Do you plan to generate documentation along with the generated module functions ? I'll try to make a few experiment in the next days, if they are interesting what would be a good place to share them?
@teamon how are you thinking to deal with $ref
and remote $ref
in schemas and multiple files to define the spec?
What is this all about?
Generate full tesla-based API client based on Open Api specification file, like this:
Tweet that started it all.
Why?
We already have the great open_api_spex library to generate API spec from Phoenix apps. We should also have an easy way to use this spec from another Elixir app, as an API client.
Why not use existing OpenAPI generators?
Existing generators have quite big dependencies (like docker or java). In case of Elixir, they generate a separate mix package with many files. This is suboptimal, as for every spec change one must regenerate and release a new package.
Here, I propose an alternative, where there are no client API packages at all. The client application can simply depend on tesla and define its own API client module, with customized adapters and middleware. The client is generated on the fly, during regular compilation.
Current To-Do list
"additionalProperties": true
formData
operation parameterswith
statements (get rid of{:ok, x} <- {:ok, data["x"]}
or{:error, _} <- {:ok, ...}
patterns)Try it today
Warnings & Notes
This is a very early few-hours-old idea and PoC. We'll see where it goes, if it makes sense, will it be part of tesla or not, etc.
In any case, if you have any ideas or comments, do not hesitate to post them here.