devondragon / devondragon/SpringShopifyAppFramework
Update REST API classes to remove extraneous wrapper classes
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 55
- Fork
- 18
- Merge medio
- 7h 14m
- PR unite (30g)
- 4
Descrizione
Much of the REST API model has "Root" classes which are just wrappers to handle the name of a JSON node.
I think we can get rid of all of those, by defining the actual model classes with a couple JSON annotations. An example is the Webhook class:
@JsonTypeName(value = "webhook")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
Update:
This is trickier than expected. The main approach works fine for single item use, but causes issues when there's an array of items being mapped to a collection.
For example, for a single Product call, Shopify returns something like:
{
"product": {
"id": 632910392,
"title": "IPod Nano - 8GB",
"body_html": "
It's the small iPod......
Which is why we need the Product class to have the As.WRAPPER_OBJECT annotation (or the wrapper class).
However, when getting an array of products, Shopify sends in something like this:
{
"products": [
{
"id": 632910392,
"title": "IPod Nano - 8GB",
"body_html": "
It's the small iPo
Note the lack of "product" level nodes. That's what breaks here. So basically we want Product to wrap itself with a "product" node if it's a single Product, but to NOT wrap itself when its an array or collection. I can't find any easy way to do this. A custom de-serializer is an option, but I'm not sure that's a lot better/cleaner than these wrapper classes....
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 con le classi del modello della REST API, incluse Webhook e Product, e confronta il modo in cui le annotazioni wrapper di Jackson gestiscono gli oggetti singoli rispetto alle collezioni. Riproduci le forme di risposta documentate di Product e products, quindi determina se è possibile rimuovere i wrapper Root preservando entrambe le forme di deserializzazione; l’issue non identifica file o test specifici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java, spring-boot
- Ambito
- api, backend
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100