How to transform camelCase requests to snake_case used by OpenApiSpex

Hey folks! I’m using OpenApiSpex to generate documentation and validate schemas.
The documentation is saying:

The names of the OpenAPI fields follow snake_case naming convention instead of OpenAPI’s (and JSON Schema’s) camelCase convention.

I’m wondering if there is an option or configuration that can keep snake_case for elixir code, but expose OpenAPI schemas in camelCase. I would expect this library to do these transformations automatically.

Phoenix.Naming has a bunch of functions that might help. If not, the source code will be an inspiration to build your own, and can be found here: phoenix/naming.ex at master · phoenixframework/phoenix · GitHub

How and where you tie it in, I’m not sure…

1 Like