JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Meta key_format setting
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Right now (in 0.8.0-beta2) we can use the configuration option of json_key_format to change the style of the attribute key names (dasherized, camelized, etc) but there is no way to do so for meta data!
I am suggesting we add a similar configuration option for formatting the key names of meta data. Something along the lines of json_meta_key_format.
Here is an example:
# using: config.json_key_format = :camelized_key
class UserResource < JSONAPI::Resource
attributes :first_name, :last_name
def meta(_options = {})
{
formal_name: "#{@model.last_name}, #{@model.first_name}"
}
end
end
Will return something like this currently:
"data": {
"attributes": {
"firstName": "foo",
"lastName": "bar"
},
"meta": {
"formal_name": "bar, foo"
},
...
}
What I propose is a json_meta_key_format configuration, which, for example sake would return with the following when using config.json_meta_key_format = :camelized_key:
"data": {
"attributes": {
"firstName": "foo",
"lastName": "bar"
},
"meta": {
"formalName": "bar, foo"
},
...
}
(Notice formalName instead of formal_name)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla configurazione json_key_format esistente e dal metodo dei metadati della risorsa mostrato nell’issue, quindi segui il punto in cui vengono serializzate le chiavi dei metadati. Aggiungi il comportamento proposto di json_meta_key_format in modo che formal_name possa diventare formalName e verifica che il JSON generato corrisponda all’esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100