mirror of https://github.com/yupix/mipac
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
672 B
25 lines
672 B
2 years ago
|
import json
|
||
|
|
||
|
from type import OpenAPI
|
||
|
|
||
|
PATHS: list[str] = []
|
||
|
PREFIX = '/api'
|
||
|
IMPORTS = "from typing import Literal\n\n"
|
||
|
TEMPLATES = "ENDPOINTS = "
|
||
|
|
||
|
with open('./datas/v13_api.json') as f:
|
||
|
api: OpenAPI = json.load(f)
|
||
|
for path in api['paths']:
|
||
|
PATHS.append(f'{PREFIX}{path}')
|
||
|
|
||
|
with open('./datas/ayuskey_api.json') as f:
|
||
|
api: OpenAPI = json.load(f)
|
||
|
for path in api['paths']:
|
||
|
PATHS.append(f'{PREFIX}{path}')
|
||
|
|
||
|
with open('../mipac/types/endpoints.py', 'w', encoding='utf-8') as f:
|
||
|
data = json.dumps(list(dict.fromkeys(PATHS)), ensure_ascii=False, indent=4)
|
||
|
f.write(
|
||
|
f'{IMPORTS}{TEMPLATES}Literal{data}'
|
||
|
)
|