-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document Swagger update procedure and add script (#6546)
- Loading branch information
1 parent
a85dee3
commit d72728a
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import logging | ||
from pathlib import ( | ||
Path, | ||
) | ||
|
||
from furl import ( | ||
furl, | ||
) | ||
|
||
from azul import ( | ||
config, | ||
require, | ||
) | ||
from azul.http import ( | ||
http_client, | ||
) | ||
from azul.logging import ( | ||
configure_script_logging, | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
http = http_client(log) | ||
|
||
repository_url = 'https://raw.githubusercontent.com/swagger-api/swagger-ui' | ||
tag = 'v4.15.2' | ||
files = [ | ||
'oauth2-redirect.html', | ||
'swagger-ui.css', | ||
'swagger-ui-bundle.js', | ||
'swagger-ui-standalone-preset.js', | ||
# We don't directly serve this file, but we maintain a verbatim copy from | ||
# the upstream distribution for reference. | ||
'swagger-initializer.js' | ||
] | ||
|
||
swagger_dir = Path(config.project_root) / 'swagger' | ||
|
||
|
||
def download_file(name: str): | ||
object_url = furl(repository_url) / tag / 'dist' / name | ||
response = http.request('GET', str(object_url)) | ||
require(response.status == 200, name) | ||
with open(swagger_dir / name, 'wb') as f: | ||
f.write(response.data) | ||
|
||
|
||
def main(): | ||
for file_name in files: | ||
download_file(file_name) | ||
|
||
|
||
if __name__ == '__main__': | ||
configure_script_logging(log) | ||
main() |