wmnnd

wmnnd

Hey folks,

this is an open question to all of you out there creating web applications with APIs. How do you go about documenting your APIs?

Do you generally prefer to use frameworks such as Open API/Swagger or API Blueprint, or do you typically go with something completely different?

And how do you go about it in Elixir/Phoenix specifically? Are you using any additional Elixir libraries such as PhoenixSwagger, BlueBird, or Bureaucrat? What has your experience with them been?

I’m looking forward to hearing about your experiences :slight_smile:

Showing Posts 1 to 10

karlosmid

karlosmid

Hi, here is PhoenixSwagger example in production:
https://testivator.com/api/doc/index.html

ityonemo

ityonemo

Imo you should write out your openApi specs, document that, and generate a Phoenix router from the spec. Currently there is no publically available library for this, but I am currently testing this out at work and we have plans to open source it once we are in prod, which is soon.

Sebb

Sebb

I’ve never created an API with Phoenix, but I’ve created a MQTT API that is documented with https://www.asyncapi.com which is great. What I was missing when I made that was a way to automatically check the payloads coming in (JSON) vs a schema. So I wrote that myself and it works really fine. The thing gets the payload schema from the asyncapi spec for the incoming MQTT-topic and automatically validates the payload. Is there something like this for Phoenix?

ityonemo

ityonemo

@sebb disclaimer: self-promotion if you want (almost complete) JSONschema validations you can use Exonerate - JSONschema validator for elixir. As far as I know this is the only library that codegens the validation logic at compile time and thus doesn’t have a huge footprint on your delivered package and also is very fast.

yurko

yurko

APIDOC has Elixir support, works for us https://apidocjs.com/

krasenyp

krasenyp

I’m with you on this one. I’ve done spec-first and it has worked great. Putting the benefits of early feedback to the side, you can use a JSONSchema validation library and actually share object definitions between the schema and the application and use them in contract tests.

mbuhot

mbuhot

At a previous company we used PhoenixSwagger + Bureaucrat with a custom formatter that would output markdown which finally fed into a static site generator.

I find realistic examples in the docs much more helpful than schemas alone. A postman collection with working examples is also nice to have.

dimitarvp

dimitarvp

How do you do contract tests?

ambrish-sinha

ambrish-sinha

Hi

I have been working with your open API library on an application in our company. So far I really like it.

One thing I wanted to ask you was if it’s wise to carry the open API %Schema{} struct around from the application layer (controller) into the business layer (lib).

My inquiry is prompted based on reading an existing application written by another team which I am now the owner of, and finding really awkward to not able to add data to these schemas inside the business layer.

I like the idea of having structures in the application layer to document the intake and output of an API to the external world, but beyond that, once the request lifecycle flow reaches inside the business layer, it seems like these schemas should no longer be used since they have served their purpose, and only in application’s view layer should the output schemas be prepared before finally dispatching the response.

Would love to read your take on this.

Thanks.

wmnnd

wmnnd OP

In my application, the business and the API layer are fully separated. The Open API schema is part of the MyAppWeb namespace is not used in any way in the business layer.
You can take a look at how this is done in Keila here: keila/lib/keila_web/api at main · pentacent/keila · GitHub

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews