jsonapi-converter
jsonapi-converter copied to clipboard
Unable to deserialise links relationship
relationships: {run: {}, contents: {links: {related: "/api/v2/sections/5950/relationships/contents"}}}
contents: {links: {related: "/api/v2/sections/5950/relationships/contents"}}
links: {related: "/api/v2/sections/5950/relationships/contents"}
related: "/api/v2/sections/5950/relationships/contents"
above is my response,related link is not included in the so how to make an api call with the link obtained from related and serialise that response to the object
@RelationshipLinks("contents")
val contentsRelationshipLinks: Links?= null,
@Relationship("contents",relType = RelType.RELATED)
@JvmField
var contents: ArrayList<LectureContent>? = null
i tried above method but it not working
@aggarwalpulkit596 Can you please provide more details, I'm not sure what you are asking.
I want to hit the endpoint which I get in contentRelationshipLinks and then map that response to contents ArrayList object SerializationFeature.INCLUDE_RELATIONSHIP_ATTRIBUTES) This is not working as this section is not included in the same api call
@Type("section")
@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy::class)
data class CourseSection(
@JvmField
val name: String,
@JvmField
var status: String,
@JvmField
var order: Int,
@JvmField
var createdAt: String,
@JvmField
var premium: Boolean,
@JvmField
var runId: String,
@RelationshipLinks("contents")
val contentsRelationshipLinks: Links?= null,
@Relationship("contents",relType = RelType.RELATED)
@JvmField
var contents: ArrayList<LectureContent>? = null
) : BaseModel()
Above is my Section Model and
@Type("content")
@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy::class)
data class LectureContent(
@JvmField
var section_content: SectionContent? = null,
@Relationship("code-challenge")
@JvmField
var code_challenge: ContentCodeChallenge? = null,
@Relationship("document")
@JvmField
var document: ContentDocumentType? = null,
@Relationship("lecture")
@JvmField
var lecture: ContentLectureType? = null,
@Relationship("progress")
@JvmField
var progress: ContentProgress? = null,
@Relationship("video")
@JvmField
var video: ContentVideoType? = null,
@Relationship("qna")
@JvmField
var qna: ContentQna? = null,
@Relationship("csv")
@JvmField
var csv: ContentCsv? = null) : Contents()
and this is my lecture Content Model
If you want to automatically resolve relationship links, you can do so using the 'RelationshipResolver' mechanism.
Please see: https://github.com/jasminb/jsonapi-converter/blob/develop/src/test/java/com/github/jasminb/jsonapi/ResourceConverterTest.java#testLinkObjectsAndRelType
@jasminb I tried using relationship resolved but that isn't working either
Basically, i want this endpoint to hit https://api-online.cb.lk/api/v2/sections/5950/relationships/contents but this endpoint is never requested
If you register a 'global' resolver, it should work.
Make sure to set resolve
flag to true
:
@RelationshipLinks("name", resolve = true)
@jasminb you mean
@Relationship("name", resolve = true)
RelationshipLinks do not have a property resolve
@aggarwalpulkit596 yeah, copy-pasta issue...
@jasminb Will try that and let you know if the issue persists
As you can see contents are not mapped it is still null