Skip to content

Commit c494fb2

Browse files
authored
Fix codegen enum symbol inheritance (#558)
* Fix typo * Add test
1 parent e0c7734 commit c494fb2

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

schema_salad/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def extend_and_specialize(
699699
elif stype["type"] == "enum":
700700
stype = copy.copy(stype)
701701
exsym.extend(stype.get("symbols", []))
702-
stype["symbol"] = exsym
702+
stype["symbols"] = exsym
703703

704704
types[stype["name"]] = stype
705705

schema_salad/tests/test_schema.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from pathlib import Path
2+
from typing import Any, Dict, List, cast
3+
4+
from schema_salad import schema
5+
from .util import get_data_uri
6+
7+
cwl_file_uri = get_data_uri("tests/test_schema/CommonWorkflowLanguage.yml")
8+
9+
10+
def test_extend_and_specialize_enums(tmp_path: Path) -> None:
11+
document_loader, _, _, metaschema_loader = schema.load_schema(cwl_file_uri)
12+
schema_raw_doc = metaschema_loader.fetch(cwl_file_uri)
13+
schema_doc, _ = metaschema_loader.resolve_all(schema_raw_doc, cwl_file_uri)
14+
15+
j = schema.extend_and_specialize(
16+
cast(List[Dict[str, Any]], schema_doc), document_loader
17+
)
18+
CWLType = next(
19+
(x for x in j if x["name"] == "https://w3id.org/cwl/cwl#CWLType"), None
20+
)
21+
assert CWLType is not None
22+
symbols = [
23+
"https://w3id.org/cwl/salad#null",
24+
"http://www.w3.org/2001/XMLSchema#boolean",
25+
"http://www.w3.org/2001/XMLSchema#int",
26+
"http://www.w3.org/2001/XMLSchema#long",
27+
"http://www.w3.org/2001/XMLSchema#float",
28+
"http://www.w3.org/2001/XMLSchema#double",
29+
"http://www.w3.org/2001/XMLSchema#string",
30+
"https://w3id.org/cwl/cwl#File",
31+
"https://w3id.org/cwl/cwl#Directory",
32+
]
33+
for symbol in symbols:
34+
assert symbol in CWLType["symbols"]

0 commit comments

Comments
 (0)