0

Trying to serialize a collection of non-primitive types using katharsis, but getting an empty collection all the time.

Response example:

{
"data": {
    "type": "products",
    "id": "1",
    "attributes": {
        "simpleAttributes": [
            {}
        ],
        "variationGroup": "variationGroup"
    },
    "relationships": {},
    "links": {
        "self": "http://localhost:8080/api/products/1"
    }
},
"included": []
}

Expected response:

{
"data": {
    "type": "products",
    "id": "1",
    "attributes": {
        "simpleAttributes": [
            {
                tittle: "some title",
                value: "some value"
            }
        ],
        "variationGroup": "variationGroup"
    },
    "relationships": {},
    "links": {
        "self": "http://localhost:8080/api/products/1"
    }
},
"included": []
}

Domain objects (getters, setters, constructor and other stuff omitted by using lombok @Data annotation):

@JsonApiResource(type = "products")
@Data
public class Product {

    @JsonApiId
    private Integer id;
    private List<SimpleAttribute> simpleAttributes = new ArrayList<>();

    private String variationGroup;
}

@Data
public class SimpleAttribute implements Serializable{

    private String title;
    private String value;
}

I do not want to use relationships in this case or to include attributes to "included" field. Is it possible in katharsis?

Green A
  • 11
  • 4

1 Answers1

0

Not sure what actually was wrong, but the problem disappeared after I changed katharsis-spring version from 2.3.0 to 2.3.1.

Green A
  • 11
  • 4