Repository: common-workflow-language/schema_salad (language: python)

Issue:
Allowing type duplications is not documented in the spec
The spec of [Apache Avro](https://avro.apache.org/docs/1.11.1/specification/#unions) says:
> Unions may not contain more than one schema with the same type, except for the named types record, fixed and enum.

As [described in the spec of SALAD](https://www.commonwl.org/v1.2/SchemaSalad.html#Abstract), SALAD is based on Apache Avro.
>  Salad builds on JSON-LD and the Apache Avro data serialization system

Also, there are few descriptions of union types in the spec of SALAD.

Therefore, we expect that union types behave as same as Apache Avro. That is, SALAD does not allow type duplications in union types.
However, schema-salad-tool allows type duplications.

For example:
```yaml
$graph:
- name: Foo
  type: record
  fields:
    - name: field1
      type: [string, string]
```

```console
$ schema-salad-tool schema.yml 
/home/vscode/.local/bin/schema-salad-tool Current version: 8.4.20230606143604
Schema 'schema.yml' is valid
```

Is it an intended behavior?
If intended, it would be nice if it is clarified in the spec of SALAD.



Discussion / hints:
Allowing duplicated types is not specifically intended behavior, but nothing in the current code specifically checks for uniqueness, so it isn't disallowed either.  It has a minimal impact on correctness.  If we want to explicitly disallow it, we can.
I'm happy to accept a PR to formally allow type duplicates in union types.
OK, I will send a request to clarify it.

Fix patch:
diff --git a/schema_salad/metaschema/metaschema_base.yml b/schema_salad/metaschema/metaschema_base.yml
index 5a37a33a..96ae8d8c 100644
--- a/schema_salad/metaschema/metaschema_base.yml
+++ b/schema_salad/metaschema/metaschema_base.yml
@@ -91,7 +91,9 @@ $graph:
         typeDSL: true
         refScope: 2
       doc: |
-        The field type
+        The field type. If it is an array, it indicates
+        that the field type is a union type of its elements.
+        Its elements may be duplicated.
 
 
 - name: RecordSchema


Test patch:
diff --git a/schema_salad/tests/metaschema-pre.yml b/schema_salad/tests/metaschema-pre.yml
index 6224075d..684f23eb 100644
--- a/schema_salad/tests/metaschema-pre.yml
+++ b/schema_salad/tests/metaschema-pre.yml
@@ -161,7 +161,7 @@
                     "typeDSL": true,
                     "refScope": 2
                 },
-                "doc": "The field type\n"
+                "doc": "The field type. If it is an array, it indicates\nthat the field type is a union type of its elements.\nIts elements may be duplicated.\n"
             }
         ]
     },
diff --git a/schema_salad/tests/test_makedoc.py b/schema_salad/tests/test_makedoc.py
index 947ce896..a0ff265a 100644
--- a/schema_salad/tests/test_makedoc.py
+++ b/schema_salad/tests/test_makedoc.py
@@ -239,5 +239,5 @@ def test_detect_changes_in_html(metaschema_doc: str, tmp_path: Path) -> None:
     with open(result, "w") as h:
         h.write(metaschema_doc)
     assert (
-        hasher.hexdigest() == "360fcb7860e6ccc15db70a20f95247a0b5ee729dd3446747463e68054e186e59"
+        hasher.hexdigest() == "400bd8b4f3af31ffaeeb04b7780a140b0d26151645016e49a1a375964b67ea7e"
     ), result