Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Update REST API classes to remove extraneous wrapper classes

Aperta
#3 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java, spring-boot
Ambito
api, backend

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.

Descrizione

enhancement good first issue

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....

Lingua principale
Java
Stelle
55
Fork
18
Merge medio
7h 14m
PR unite (30g)
4

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di devondragon/SpringShopifyAppFramework

Tutte le issue di devondragon/SpringShopifyAppFramework

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.