# Extending RecordSchemas?

**URL:** <https://cwl.discourse.group/t/extending-recordschemas/981>\
**Category:** CWL Questions\
**Created:** [February 18, 2025, 2:31am UTC](https://cwl.discourse.group/t/extending-recordschemas/981 "2025-02-18T02:31:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexiswl](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/alexiswl/32/93_2.png) [@alexiswl](https://cwl.discourse.group/u/alexiswl)\
**Post date:** [February 18, 2025, 2:31am UTC](https://cwl.discourse.group/t/extending-recordschemas/981/1 "2025-02-18T02:31:18Z")

</div>

Is it possible to extend a record schema?

For example, let’s say I have the base schema ‘contig’ which has the attributes - `chromosome`, `start` and `end`, that I have added to a file called `contig_basic.yaml`. Let’s assume I use this schema in a tool called bedtools\_basic.cwl

```yaml
type: record
name: contig

fields:
  chromosome:
    label: chromosome
    doc: |
      The name of the chromosome
    type: string
  start:
    label: start position
    doc: |
      The start position of the chromosome of the region
    type: int?
  end:
    label: end position
    doc: |
      The end position of the chromosome of the region
    type: int?

```

Let’s say now, for another tool called bedtools\_advanced, I want to have a schema that is identical to the contig schema but with a boolean attribute `is_alt_contig` which is set to true for ‘ALT’ contigs. Is there a way for me to import the attributes from contig\_base.yaml and then extend this with my additional field?

The best I can achieve so far is:

```yaml
type: record
name: contig_advanced

fields:
  # Import each field from the basic schema
  - $import: "contig_base.yaml#contig/chromosome"
  - $import: "contig_base.yaml#contig/start"
  - $import: "contig_base.yaml#contig/end"
  # Extend the basic schema with the field 'is_alt_contig'
  - name: is_alt_contig
    label: is alt contig
    doc: |
      Is this contig an alt contig
    type: boolean

```

Ideally I’d be able to do something like

```yaml
type: record
name: contig_advanced

fields:
  # Import entire schema
  - { "$import": "contig_base.yaml#contig" }
  # Extend the basic schema with the field 'is_alt_contig'
  - name: is_alt_contig
    label: is alt contig
    doc: |
      Is this contig an alt contig
    type: boolean

```
