cdisc-org / cdisc-org/DDF-RA-Tools
Incorrect attribute type when merging OpenAPI spec into merged dataStructure.yml elements
- Dominant language
- Python
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
# Problem
Given certain attributes in the USDM spec that should be defined as concrete types of an abstract class, only the abstract class is used in the resulting `dataStructure.yml` instead of the appropriate concrete types. The spec generated at https://github.com/cdisc-org/usdm_api appears correct, but this information is lost when translating to `dataStructure.yml`.
For example:
Within `ScheduleTimeline` is an `instances` attribute. This is correctly defined in the OpenAPI spec as such:
```yaml
instances:
items:
anyOf:
- $ref: '#/components/schemas/ScheduledActivityInstance-Input'
- $ref: '#/components/schemas/ScheduledDecisionInstance-Input'
type: array
title: Instances
default: []
```
However, when merged into the resulting `dataStructure.yml`, we get this:
```yaml
instances:
Type:
- $ref: '#/ScheduledInstance'
Definition: A USDM relationship between the ScheduleTimeline and ScheduledInstance
classes which identifies the set of scheduled instances (e.g., scheduled activity
instances or scheduled decision instances) associated with the scheduled timeline.
Cardinality: 0..*
Relationship Type: Value
Model Name: instances
Model Representation: Relationship
```
The corrected form for `dataStructure.yaml` should be:
```yaml
instances:
Type:
anyOf:
- $ref: '#/ScheduledActivityInstance'
- $ref: '#/ScheduledDecisionInstance'
Definition: A USDM relationship between the ScheduleTimeline and ScheduledInstance
classes which identifies the set of scheduled instances (e.g., scheduled activity
instances or scheduled decision instances) associated with the scheduled timeline.
Cardinality: 0..*
Relationship Type: Value
Model Name: instances
Model Representation: Relationship
```
# Solution
I'm not quite familiar with the merge code, but perhaps the `ref` field needs to be a more complex type to use the full OpenAPI concrete types instead of the abstract class here: https://github.com/cdisc-org/DDF-RA-Tools/blob/main/ddf_ra_tools/reports/data_structure.py#L15
Context here is that were are using the `dataStructure.yml` definition to do code generation for the spec that we would like to contribute back to the community. Without these types being correctly represented it makes for clunky usage of the spec.
Thank you for the help!
Contributor guide
Assessment
This issue has not been assessed yet.