Skip to content

Commit

Permalink
Sb jsonschema update for t_map_of (#8)
Browse files Browse the repository at this point in the history
* Updated w_fdef to include field options

* adjusted array to contain draft2020 complaint json schema formatting for an array of objects (mapOf)

---------

Co-authored-by: Matt Roberts <matthew.roberts@bestgateeng.com>
  • Loading branch information
ScreamBun and maroberts82 authored Aug 24, 2024
1 parent fc6ba08 commit 897fd14
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions distribution/src/jadn/translate/jsonschema_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def w_fdef(f: list, ctx: dict) -> dict:
"""
fopts, topts = ftopts_s2d(f[FieldOptions])
if is_builtin(f[FieldType]):
t = w_type(['', f[FieldType], [], f[FieldDesc]], topts, ctx)
t = w_type(['', f[FieldType], f[FieldOptions], f[FieldDesc]], topts, ctx)
else:
t = dmerge(w_ref(f[FieldType], ctx), {'description': f[FieldDesc]})

Expand Down Expand Up @@ -337,12 +337,15 @@ def t_map_of(tdef: list, topts: dict, ctx: dict) -> dict:
{'maxItems': topts['maxv']} if 'maxv' in topts else {},
)

prefix_items = [
{k_name : ktype},
{v_name : vtype}
]
_items = {
"type" : "object",
"properties": {
k_name : ktype,
v_name : vtype
}
}

merged['items'] = prefix_items
merged['items'] = _items

return merged

Expand Down

0 comments on commit 897fd14

Please sign in to comment.