# Spectral - Type-driven JSON encoding/decoding, validation, and OpenAPI generation

**URL:** <https://forum.elixirforum.com/t/spectral-type-driven-json-encoding-decoding-validation-and-openapi-generation/74902>\
**Category:** Announcing\
**Tags:** library, validation, json, types, serialization\
**Created:** [April 6, 2026, 10:40am UTC](https://forum.elixirforum.com/t/spectral-type-driven-json-encoding-decoding-validation-and-openapi-generation/74902 "2026-04-06T10:40:26Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![andreashasse](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/andreashasse/32/40185_2.png) [@andreashasse](https://forum.elixirforum.com/u/andreashasse)\
**Post date:** [April 6, 2026, 3:56pm UTC](https://forum.elixirforum.com/t/spectral-type-driven-json-encoding-decoding-validation-and-openapi-generation/74902/10 "2026-04-06T15:56:50Z")

</div>

Hi Asd,

I started out gathering up all type information at compile time (as you suggest), but when you reference types from modules that don’t use the Spectral macro, you still need to figure out the types from those modules somehow. The cache (which is turned off by default, so it shouldn’t have bothered you when developing) is documented here: [Configuration](https://hexdocs.pm/spectral/0.9.2/readme.html#configuration) If you are doing hot code reloading in production, then I can expose primitives for cleaning the cache.

In the documentation there is an example that defines a “point type”, which is a 2-tuple. Imho, there is no good _general_ way to convert tuples to JSON, when you have such a type you have to create your own codec: [Custom codecs](https://hexdocs.pm/spectral/0.9.2/readme.html#custom-codecs). My hope is that you should be able to create elixir types that map to most things OpenAPI has support for. With the codec “escape hatch” you should be able to do whatever you want 😉

It is correct that the types currently need to be expressed in a beam file that is compiled with debug\_info, this is a current limitation of the library. If this is hindering developers from using the library, then I think it can be solved.

I’m happy to hear about those other issues.

All the best

---

_[View the full topic](https://forum.elixirforum.com/t/spectral-type-driven-json-encoding-decoding-validation-and-openapi-generation/74902)._
