How to generate Swagger/OpenAPI specification for Phoenix REST

Hey folks! I’m trying to find a library to generate swagger/openapi specification based on elixir code (typed structs or type definitions). Unfortunately I can’t find anything…

I’m new in elixir and phoenix. I want to generate swagger/openapi describing REST API. This should be a common problem, I’m wondering how others tackle it.

Hey @ddoronin

Take a look at GitHub - open-api-spex/open_api_spex: Open API Specifications for Elixir Plug applications

1 Like

if you’re willing to wait a few weeks, my company is releasing an open-source framework for OpenAPI that takes a document-centric view (it uses the OpenAPI schema as a central source of truth and there are no additional DSLs to learn).

We just pushed it to a private repo for one release worth of validating in prod before fully open sourcing it.

Note that this is not exactly what you are working for, it’s more like how Go and C# developers do it… But I’m convinced that going from the schema to code is the “correct way” of doing things, instead of going from code (comments, annotations, etc) to schema.

7 Likes

@ityonemo I agree that the schema to code approach is better, because documentation/schema becomes a single source of truth for both back-end and front-end! I would love to see your solution! Feel free to publish a link to your library here, or DM me https://www.linkedin.com/in/ddoronin/

I’ll post it here in addition to a general announcement on the board.

1 Like

@ityonemo any updates about your OpenAPI framework??

1 Like

As far as I’m concerned it’s ready, but my now former boss has to approve some licensing things, I think. It’s in his best interest to do it, because I imagine he’ll get free support on the library if he open-sources it :man_shrugging: .