Open vdytynyuk opened 6 years ago
I don't understand the issue.
Can you provide you json ? I will try to reproduce your error.
@deblockt here's my json.
{
"_links": {
"self": {
"href": "projects/2",
"type": "application/hal+json"
},
"service.runs": {
"href": "project/2/runs",
"type": "application/hal+json"
}
},
"key": 2,
"name": "proj54"
}
Here's my Project model.
export class Project extends HalResource {
@HalProperty()
key: number;
@HalProperty()
name: string;
@HalProperty('service.runs')
runs: RunCollection;
}
export class RunCollection extends HalResource {
@HalProperty()
count: number;
@HalProperty(Run)
list: Run[];
}
After execution of await this.project.runs.fetch(true);
field this.project.runs
is HalResource not RunCollection.
Lets say I have a model which has a field expected as link.
Model:
When fetching Foo resource hal-parser spits out
bar
field asHalResorce
not asBar
which is incorrect behavior. After some debugging I found that library passes to method Reflect.getMetadata link key as it is from hal json (e.g.'response.bar'
) but MetadataMap contains field names and appropriate constructors in format that is specified in@HalProperty()
decorator (e.g.'bar'
). Apparently proper constructor cannot be found by incorrect key and that leads to castingBar
field toHalResource
.