the form we create uses
colgroup
and
col
elements as demonstrated next
<table>
<colgroup>
<col id="/$defs/A" span="2"/>
<col id="/$defs/B" span="1"/>
</colgroup>
<colgroup>
<col id="/$defs/A/properties/foo"/>
<col id="/$defs/A/properties/bar"/>
<col id="/$defs/B/properties/baz"/>
</colgroup>
</table>
and it is generated directly from schema using the following code generate example
colgroup
and
col
elements
import bs4, jsonpointer
soup = bs4.BeautifulSoup(features="html5lib")
soup.append(table := soup.new_tag("table"))
table.append(colgroup := soup.new_tag("colgroup"))
table.append(props := soup.new_tag("colgroup"))
for s in schema["allOf"]:
id = jsonpointer.JsonPointer.from_parts((ref:=s.get("$ref")).split("/")[1:])
colgroup.append(col := soup.new_tag("col"))
p = id.get(schema).get("properties")
col.attrs.update(id=str(id), span=len(p))
for k in p:
props.append(x := soup.new_tag("col"))
x.attrs.update(id=jsonpointer.JsonPointer.from_parts(ref.split("/")[1:] + ["properties", k]))