Skip to content

Incorrect attribute type when merging OpenAPI spec into merged dataStructure.yml elements #1

@zero1zero

Description

@zero1zero

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:

        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:

    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:

    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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions