Created
July 28, 2018 18:07
-
-
Save bwesterb/786028bfae5a62dc8b71179698298660 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml | |
import json | |
with open('swagger.json') as f: | |
d = json.load(f) | |
for obj in d['components']['schemas'].values(): | |
if 'required' in obj and not obj['required']: | |
del(obj['required']) | |
if 'properties' in obj and not obj['properties']: | |
del(obj['properties']) | |
for obj in d['components']['headers'].values(): | |
if 'name' in obj: del(obj['name']) | |
if 'in' in obj: del(obj['in']) | |
with open('swagger.yaml', 'w') as f: | |
yaml.safe_dump(d, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment