Skip to content

Commit 84ce36f

Browse files
committed
import fix from netbox-community#178
1 parent acfb572 commit 84ce36f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Diff for: scripts/fix-spec.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
for name, schema in data['components']['schemas'].items():
1414
if 'properties' in schema:
1515
# Remove "null" item from nullable enums
16-
for name, prop in schema['properties'].items():
16+
for propName, prop in schema['properties'].items():
1717
if 'enum' in prop and None in prop['enum']:
1818
prop['enum'].remove(None)
1919
if 'properties' in prop and 'value' in prop['properties'] and 'enum' in prop['properties']['value'] and None in prop['properties']['value']['enum']:
@@ -39,7 +39,25 @@
3939
for ntype in non_nullable_types:
4040
if ntype in schema['properties']:
4141
if schema['properties'][ntype]['format'] == 'binary':
42-
schema['properties'][ntype].pop('nullable')
42+
schema['properties'][ntype].pop('nullable', None)
43+
44+
if 'required' in schema:
45+
non_required_props = [
46+
'devicetype_count',
47+
'device_count',
48+
'virtualmachine_count',
49+
'prefix_count',
50+
]
51+
52+
schema['required'] = [prop for prop in schema['required'] if prop not in non_required_props]
53+
54+
data['components']['schemas']['Device']['required'] = [
55+
'id',
56+
'url',
57+
'display',
58+
'name',
59+
'description',
60+
]
4361

4462
# Save the spec file
4563
with open(SPEC_PATH, 'w') as file:

0 commit comments

Comments
 (0)