More renaming

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2023-09-19 16:51:32 +02:00
parent 2b30ff48ec
commit f70d54453a
No known key found for this signature in database
GPG key ID: 29A48C1F03620416
3 changed files with 11 additions and 11 deletions

View file

@ -87,11 +87,11 @@ def check_response(filepath, request, code, response):
), e) ), e)
def check_swagger_file(filepath): def check_openapi_file(filepath):
with open(filepath) as f: with open(filepath) as f:
swagger = yaml.safe_load(f) openapi = yaml.safe_load(f)
for path, path_api in swagger.get('paths', {}).items(): for path, path_api in openapi.get('paths', {}).items():
for method, request_api in path_api.items(): for method, request_api in path_api.items():
request = "%s %s" % (method.upper(), path) request = "%s %s" % (method.upper(), path)
@ -169,7 +169,7 @@ if __name__ == '__main__':
# Get the directory that this script is residing in # Get the directory that this script is residing in
script_directory = os.path.dirname(os.path.realpath(__file__)) script_directory = os.path.dirname(os.path.realpath(__file__))
# Resolve the directory containing the swagger sources, # Resolve the directory containing the OpenAPI sources,
# relative to the script path # relative to the script path
source_files_directory = os.path.realpath(os.path.join(script_directory, "../data")) source_files_directory = os.path.realpath(os.path.join(script_directory, "../data"))
@ -182,6 +182,6 @@ if __name__ == '__main__':
path = os.path.join(root, filename) path = os.path.join(root, filename)
try: try:
check_swagger_file(path) check_openapi_file(path)
except Exception as e: except Exception as e:
raise ValueError("Error checking file %s" % (path,), e) raise ValueError("Error checking file %s" % (path,), e)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# dump-swagger reads all of the OpenAPI docs used in spec generation and # dump-openapi reads all of the OpenAPI docs used in spec generation and
# outputs a JSON file which merges them all, for use as input to an OpenAPI # outputs a JSON file which merges them all, for use as input to an OpenAPI
# viewer. # viewer.
@ -84,7 +84,7 @@ def edit_links(node, base_url):
edit_links(item, base_url) edit_links(item, base_url)
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
"dump-swagger.py - assemble the OpenAPI specs into a single JSON file" "dump-openapi.py - assemble the OpenAPI specs into a single JSON file"
) )
parser.add_argument( parser.add_argument(
"--base-url", "-b", "--base-url", "-b",
@ -113,7 +113,7 @@ parser.add_argument(
) )
parser.add_argument( parser.add_argument(
"-o", "--output", "-o", "--output",
default=os.path.join(scripts_dir, "swagger", "api-docs.json"), default=os.path.join(scripts_dir, "openapi", "api-docs.json"),
help="File to write the output to. Default: %(default)s" help="File to write the output to. Default: %(default)s"
) )
args = parser.parse_args() args = parser.parse_args()

View file

@ -41,13 +41,13 @@ if __name__ == '__main__':
help='TCP port to listen on (default: %(default)s)', help='TCP port to listen on (default: %(default)s)',
) )
parser.add_argument( parser.add_argument(
'swagger_dir', nargs='?', 'openapi_dir', nargs='?',
default=os.path.join(scripts_dir, 'swagger'), default=os.path.join(scripts_dir, 'openapi'),
help='directory to serve (default: %(default)s)', help='directory to serve (default: %(default)s)',
) )
args = parser.parse_args() args = parser.parse_args()
os.chdir(args.swagger_dir) os.chdir(args.openapi)
httpd = socketserver.TCPServer(("localhost", args.port), httpd = socketserver.TCPServer(("localhost", args.port),
MyHTTPRequestHandler) MyHTTPRequestHandler)