vipes

vipes

Generate Elixir API from Swagger / OpenAPI 3.0

Hi all. I’ve seen plenty of information about generating Swagger docs from a pre-existing Phoenix API. Has anyone come across a tool that has the ability to generate a Phoenix API from a Swagger / OpenAPI 3.0 specification? I’ve had a look at Swagger’s Codegen tool but it doesn’t support building server stubs for Elixir. Thank you :slight_smile:

First Post!

bryanhuntesl

bryanhuntesl

I’ve done quite a lot of research in this area - to the best of my knowledge no such tool exists. It would be very useful for migrating an implementation written in JavaScript, Scala, Python or whatever to Elixir.

Strikes me it wouldn’t be the hardest thing in the world to write. Parse openapi definition, generate the structs and stubs required by openapispex then fill in the blanks. @moxley might have some thoughts

Most Liked

ityonemo

ityonemo

Update:. The library is on its way. I’m currently refactoring the JSONschema stuff to be easier to debug

ityonemo

ityonemo

I’m still stuck on unevaluatedProperties, but I’m very close. UnevaluatedItems should fall soon after. Sorry, this is an incredibly hard part of JSONschema to compile correctly.

But as a teaser, this is the performance improvement for one of the JSONschema tests ($ref)

Eiamnacken

Eiamnacken

To give some perspective. It is also difficult to keep this in sync with the openapi spec over time. Also, the generators get old very fast. From my experience from using this in java. We had more trouble with the generator. Instead, we built it manually and programmed unit tests to check that the implementation is in sync with the openapi spec.

And also the spec is quite complex as this is using all features json-schema has to offer.

Last Post!

niccolox

niccolox

so, I actually think this is a solution

JSON API > Ash Json API wrapper > Ash Resources > Ash Postgres > Ash Phoenix > Phoenix Liveview

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New

We're in Beta

About us Mission Statement