3 ms·
let me give an example of how I wanted to use this. For fun I was working on the backend for Dogehouse (open source clubhouse clone) for a while, and for whate
by dnautics 5y ago
let me give an example of how I wanted to use this. For fun I was working on the backend for Dogehouse (open source clubhouse clone) for a while, and for whatever reason the creator wanted the entire API to go over websockets. Ok, well, sounds like a fun thing to play around with [0]. Maintaining API consistency between the FE and BE was... very challenging, because there was very little discipline in the FE, because it was mostly into/junior programmers with not a lot of experience with API change management and feature discipline, testing, etc. So I really wanted to use AsyncAPI to create a contract between the FE and BE to be able to enforce that discipline - by auto-generating validators that get injected into the code and raise hell if invalid content is pushed by either FE or BE.
It wasn't really ready for that yet at the time, but I think over time AsyncAPI will be the way to go.
[0] in retrospect probably would have been better as a normal MVC app with only the chat and audio parts over ws, but... Again, not my project.
- panabee 5y agowould you mind sharing what you mean by auto-generated validators that get injected into the code?
- dnautics 5y agoI'll be open sourcing one I'm building for openApi at work in a few months, in the meantime, I have compile-time generated jsonschema validators here: https://hexdocs.pm/exonerate/Exonerate.html https://hexdocs.pm/exonerate/Exonerate.html In elixir parlance checking the schemas for REST (or in the case of asyncAPI, ws) transactions will happen based on a "plug" which injects the validation into the processing pipeline.
- panabee 5y agothanks for sharing.