malomohq / accent Goto Github PK
View Code? Open in Web Editor NEWDynamically convert the case of your JSON API keys
License: MIT License
Dynamically convert the case of your JSON API keys
License: MIT License
Why is it that using Accent.Transformer.PascalCase
converts the first letter of key to small and Accent.Transformer.CamelCase
with capital? It should be the other way around I think.
There is an extra underscore added which is unexpected.
iex(1)> Accent.Case.Snake.call("address2")
"address_2"
iex(2)> Accent.Case.Snake.call("address_2")
"address__2"
I believe there should be a check around this line https://github.com/malomohq/accent/blob/master/lib/accent/case/snake.ex#L28
Hi
Why are we only performing conversion for requests with content-type? Often times GET request does not contain a content-type header, but in these cases, I'd still like to convert response payload to different casing.
There seems to be an issue with Plug.upload.
Following the guide on file upload, shows error
This is whats on my router.ex
pipeline :api do
plug :accepts, ["json"]
plug Plug.Parsers,
parsers: [:urlencoded, :json],
pass: ["*/*"],
json_decoder: Jason
plug Accent.Plug.Request # Removing this line will fix the issue
plug Accent.Plug.Response,
default_case: Accent.Case.Camel,
header: "x-accent",
supported_cases: %{"pascal" => Accent.Case.Pascal},
json_codec: Jason
end
Hi
It would be nice to allow setting a default casing for response payloads, even without the client setting the accent
header.
In my situation I'd like to always send all responses as camelcase
Just wondering, responses.ex on before_send_callback
Should this be a
get_req_header("content-type")
As on the do_call?
uses get_req_header("content-type")
on https://github.com/sticksnleaves/accent/blob/9f5011677827d98e2cedf976f4120132b719004c/lib/accent/plugs/response.ex#L99
I've tried to change it and all the tests are passing.
Would it be possible to apply the Accent.Plug.Response
without having a request with Content-Type: application/json
header.
For file upload uses cases, the request header has Content-Type: multipart/form-data
, I should expect the result be transform into json in camel case.
A configuration would look like this:
pipeline :uploads do
plug Accent.Plug.Response,
default_case: Accent.Case.Camel,
json_codec: Jason
end
scope "/uploads", StackedWeb do
pipe_through :uploads
resources "/files", FileController, only: [:create, :show]
end
I've been using propercase, and it does handle this kind of use case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.