anthonator

anthonator

Hey everyone,

I published a new package yesterday that allows a client to request the case it prefers to see the keys of a JSON response in. For example, a JavaScript client may prefer a JSON response to be in pascalCase.

The main goal of the project was to provide the client the ability to make the choice of which case they prefer rather than hard coding a snake_case to pascalCase (or whatever) conversion.

By default, a client can send an Accent header to the server with the case they prefer. Out of the box, we support pascal, camel and snake as options. Both the header used and the supported cases can be customized.

Conversion works both ways. A client can request a response be formatted with a specific case and the server can convert an incoming request to a specific case as well.

Would love to hear your thoughts!

Hex: accent | Hex
Documentation: API Reference — accent v1.1.1

Showing Posts 1 to 4

OvermindDL1

OvermindDL1

Huh, very use-case specific but very cool!

I’m guessing they did not want to use the GraphQL protocol or so? ^.^

A couple notes if you are curious, Elixir has snake_case / camelCase / UpperCamelCase conversion functions somewhere as I recall, can use those instead of duplicating the work as they are very well tested (since they are used in codegen). Also could add docs on the main README.md on example usage of :supported_cases. :slight_smile:

Looks well written. :slight_smile:

anthonator

anthonator OP

Thanks for the feedback!

I’m surprised you think that the use-case is very specific. We have a lot of clients for the web services we create that prefer either pascal or camel case. I think most companies use a RESTful API as opposed to GraphQL. Glad to hear your thoughts though!

I didn’t use Elixir’s implementation because they are not Unicode compliant. They only support ASCII. They say so as much in the Macro docs.

Thanks for the documentation suggestion! I’ll definitely do that.

Thanks again! I really appreciate the time you took take a look! :smile:

anthonator

anthonator OP

These are the two non-Unicode camelize and underscore functions. Let me know if you were thinking of something else.

Thanks again!

OvermindDL1

OvermindDL1

Nah I bet that was them, I’m surprised they are not unicode compliant, that sounds like a pending PR if they would take it, though considering its built for ‘elixir identifiers’, maybe not… ^.^

— All posts loaded —

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

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
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews