diff --git a/cwltool/main.py b/cwltool/main.py
index e024d22a..23c12d59 100755
--- a/cwltool/main.py
+++ b/cwltool/main.py
@@ -195,13 +195,15 @@ def generate_example_input(
                 else:
                     comment = "optional"
         else:
-            example = CommentedSeq()
-            for index, entry in enumerate(inptype):
+            example, comment = generate_example_input(inptype[0], default)
+            type_names = []
+            for entry in inptype:
                 value, e_comment = generate_example_input(entry, default)
-                example.append(value)
-                example.yaml_add_eol_comment(e_comment, index)
+                if e_comment:
+                    type_names.append(e_comment)
+            comment = "one of " + ", ".join(type_names)
             if optional:
-                comment = "optional"
+                comment = f"{comment} (optional)"
     elif isinstance(inptype, Mapping) and "type" in inptype:
         if inptype["type"] == "array":
             first_item = cast(MutableSequence[CWLObjectType], inptype["items"])[0]

diff --git a/tests/test_make_template.py b/tests/test_make_template.py
index 519f8603..f2bd2867 100644
--- a/tests/test_make_template.py
+++ b/tests/test_make_template.py
@@ -8,3 +8,21 @@ from cwltool import main
 def test_anonymous_record() -> None:
     inputs = cmap([{"type": "record", "fields": []}])
     assert main.generate_example_input(inputs, None) == ({}, "Anonymous record type.")
+
+
+def test_union() -> None:
+    """Test for --make-template for a union type."""
+    inputs = cmap(["string", "string[]"])
+    assert main.generate_example_input(inputs, None) == (
+        "a_string",
+        'one of type "string", type "string[]"',
+    )
+
+
+def test_optional_union() -> None:
+    """Test for --make-template for an optional union type."""
+    inputs = cmap(["null", "string", "string[]"])
+    assert main.generate_example_input(inputs, None) == (
+        "a_string",
+        'one of type "string", type "string[]" (optional)',
+    )

Creating input yaml - issue with ruamel comments.py
Hi,
I am using cwltool version 3.0.20201203173111 that came with `pip install cwl-runner`.  This might be issue with ruamel or with my workflow but here is run command and trace:

`cwltool --make-template --debug tumor_only_exome.cwl > hiv_input.yml`

traceback:
```
Traceback (most recent call last):
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 991, in main
    make_template(tool)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 744, in make_template
    generate_input_template(tool),
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 301, in generate_input_template
    template.insert(0, name, value, comment)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/ruamel/yaml/comments.py", line 722, in insert
    self.yaml_add_eol_comment(comment, key=key)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/ruamel/yaml/comments.py", line 295, in yaml_add_eol_comment
    if comment[0] != '#':
IndexError: string index out of range
```

tests/test_make_template.py::test_optional_union tests/test_make_template.py::test_union
tests/test_make_template.py::test_anonymous_record