|
9 | 9 |
|
10 | 10 | if __name__ == "__main__": |
11 | 11 | cli_schema = json.loads(CliCommands.schema_json()) |
12 | | - with open('python/cli.schema.json', 'w') as out: |
| 12 | + with open("python/cli.schema.json", "w") as out: |
13 | 13 | json.dump(cli_schema, out, indent=2) |
14 | 14 |
|
15 | 15 | combined_schemas = {} |
16 | 16 | for route in api.routes: |
17 | 17 | if not isinstance(route, Mount): |
18 | 18 | continue # must be a built-in route like /docs |
19 | 19 | mount_path = route.path |
20 | | - openapi = get_openapi(title=f'refstudio{mount_path}', version='0.1', routes=route.app.routes) |
21 | | - components = openapi.get('components') |
| 20 | + openapi = get_openapi( |
| 21 | + title=f"refstudio{mount_path}", version="0.1", routes=route.app.routes |
| 22 | + ) |
| 23 | + components = openapi.get("components") |
22 | 24 | if components: |
23 | | - combined_schemas.update(components['schemas']) |
| 25 | + combined_schemas.update(components["schemas"]) |
24 | 26 |
|
25 | 27 | # OpenAPI puts request/response definitions under "/components/schemas", but |
26 | 28 | # json2ts wants them under "/definitions". |
27 | 29 | output_schema = json.dumps(combined_schemas) |
28 | | - output_schema = output_schema.replace('#/components/schemas/', '#/definitions/') |
| 30 | + output_schema = output_schema.replace("#/components/schemas/", "#/definitions/") |
29 | 31 | schema = json.loads(output_schema) |
30 | | - with open('python/api.schema.json', 'w') as out: |
31 | | - json.dump({'definitions': schema}, out, indent=2) |
| 32 | + with open("python/api.schema.json", "w") as out: |
| 33 | + json.dump({"definitions": schema}, out, indent=2) |
0 commit comments