Replace all mentions of Swagger by OpenAPI (#1633)
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
df3f0af5d4
commit
99e2ff4927
17 changed files with 40 additions and 87 deletions
|
@ -87,11 +87,11 @@ def check_response(filepath, request, code, response):
|
|||
), e)
|
||||
|
||||
|
||||
def check_swagger_file(filepath):
|
||||
def check_openapi_file(filepath):
|
||||
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():
|
||||
request = "%s %s" % (method.upper(), path)
|
||||
|
@ -169,7 +169,7 @@ if __name__ == '__main__':
|
|||
# Get the directory that this script is residing in
|
||||
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
|
||||
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)
|
||||
|
||||
try:
|
||||
check_swagger_file(path)
|
||||
check_openapi_file(path)
|
||||
except Exception as e:
|
||||
raise ValueError("Error checking file %s" % (path,), e)
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# dump-swagger reads all of the swagger API docs used in spec generation and
|
||||
# outputs a JSON file which merges them all, for use as input to a swagger UI
|
||||
# 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
|
||||
# viewer.
|
||||
# See https://github.com/swagger-api/swagger-ui for details of swagger-ui.
|
||||
|
||||
# Copyright 2016 OpenMarket Ltd
|
||||
#
|
||||
|
@ -85,7 +84,7 @@ def edit_links(node, base_url):
|
|||
edit_links(item, base_url)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
"dump-swagger.py - assemble the Swagger specs into a single JSON file"
|
||||
"dump-openapi.py - assemble the OpenAPI specs into a single JSON file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--base-url", "-b",
|
||||
|
@ -114,7 +113,7 @@ parser.add_argument(
|
|||
)
|
||||
parser.add_argument(
|
||||
"-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"
|
||||
)
|
||||
args = parser.parse_args()
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Runs an HTTP server on localhost:8000 which will serve the generated swagger
|
||||
# JSON so that it can be viewed in an online swagger UI.
|
||||
# Runs an HTTP server on localhost:8000 which will serve the generated OpenAPI
|
||||
# JSON so that it can be viewed in an online OpenAPI viewer.
|
||||
|
||||
# Copyright 2016 OpenMarket Ltd
|
||||
#
|
||||
|
@ -41,13 +41,13 @@ if __name__ == '__main__':
|
|||
help='TCP port to listen on (default: %(default)s)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'swagger_dir', nargs='?',
|
||||
default=os.path.join(scripts_dir, 'swagger'),
|
||||
'openapi_dir', nargs='?',
|
||||
default=os.path.join(scripts_dir, 'openapi'),
|
||||
help='directory to serve (default: %(default)s)',
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
os.chdir(args.swagger_dir)
|
||||
os.chdir(args.openapi_dir)
|
||||
|
||||
httpd = socketserver.TCPServer(("localhost", args.port),
|
||||
MyHTTPRequestHandler)
|
Loading…
Add table
Add a link
Reference in a new issue