Created
June 23, 2023 04:28
-
-
Save h4sh5/47db0b2eabdad7dac3b506db76d67786 to your computer and use it in GitHub Desktop.
check swagger docs for security or the lack thereof
This file contains 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
#!/usr/bin/env python3 | |
import yaml | |
import sys | |
filename = sys.argv[1] | |
with open(filename,'r') as f: | |
d = yaml.safe_load(f) | |
if 'security' in d: | |
print('security root level:', d['security']) | |
print('------') | |
if 'securityDefinitions' in d: | |
print('securityDefinitions root level:', d['securityDefinitions']) | |
print('------') | |
for path in d['paths']: | |
for method in d['paths'][path]: | |
try: | |
print(method.upper(),path,d['paths'][path][method].get('security')) | |
except Exception as e: | |
print("error parsing:",e, method.upper(), path, d['paths'][path][method]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment