Horreum
Horreum copied to clipboard
Find usages API not completely working
Describe the bug
Find label usages is not properly working on UI, the API requests seems good but the UI is not properly filled in:
The text should be something like Report config <b>{loc.title}</b> in {loc.where} {loc.name ? loc.name : ""}
As you can see loc.where
and loc.name
(and also loc.configId
)are empty.
After some investigation, the API is properly returning those fields properly filled in. IIUC the problem seems in the OpenAPI definition, as it was constructed assuming some sort of inheritance which does not actually exists in OpenAPI specs:
- In the
horreum-api
we have an abstractLabelLocation
schema which is extended by several locations, e.g.,LabelInReport
- The autogenerated client code (for the models) does not reflect that inheritance and you'll have two distinct classes, the
LabelLocation
andLabelInReport
(the latter having all fields coming fromLabelLocation
and their owns) - The UI calls the client method
findUsages
which is returningLabelLocation[]
the most generic one, thus it will simply discard all other fields
To Reproduce
- Simply look for a label (in a specific schema having some usages on reports) and click find usages
- You should see the table is not properly filled in
- If you click the "Go to", it will redirect to an
undefined
report config id, this is because alsoloc.configId
is undefined.
Version
What is the version of Horreum ?
Discovered on 0.13
but it was affecting also previous versions.
I think the proper way to handle this use case is using the Discriminator
.