devondragon / devondragon/SpringShopifyAppFramework
Update REST API classes to remove extraneous wrapper classes
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 55
- Forks
- 18
- Merge medio
- 7 h 14 min
- PR fusionados (30 d)
- 4
Descripción
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....
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con las clases de modelo de la REST API, incluidas Webhook y Product, y compara cómo las anotaciones de wrapper de Jackson gestionan los objetos individuales frente a las colecciones. Reproduce las formas de respuesta documentadas de Product y products y determina después si se pueden eliminar los wrappers Root conservando ambas formas de deserialización; el issue no identifica archivos ni tests específicos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java, spring-boot
- Área
- api, backend
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100