• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vintasoftware / nextjs-fastapi-template / 12421386556

19 Dec 2024 09:53PM CUT coverage: 98.188% (-0.6%) from 98.811%
12421386556

Pull #46

github

andersonresende
Fixed tests
Pull Request #46: Ft/error component

84 of 93 branches covered (90.32%)

Branch coverage included in aggregate %.

58 of 65 new or added lines in 3 files covered. (89.23%)

1 existing line in 1 file now uncovered.

1867 of 1894 relevant lines covered (98.57%)

6.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/fastapi_backend/commands/generate_openapi_schema.py
1
import json
1✔
2
from pathlib import Path
1✔
3
from app.main import app
1✔
4
import os
1✔
5

6
from dotenv import load_dotenv
1✔
7

8
load_dotenv()
1✔
9

10
OUTPUT_FILE = os.getenv("OPENAPI_OUTPUT_FILE")
1✔
11

12

13
def generate_openapi_schema(output_file):
1✔
14
    schema = app.openapi()
1✔
15
    output_path = Path(output_file)
1✔
16

17
    updated_schema = remove_operation_id_tag(schema)
1✔
18

19
    output_path.write_text(json.dumps(updated_schema, indent=2))
1✔
20
    print(f"OpenAPI schema saved to {output_file}")
1✔
21

22

23
def remove_operation_id_tag(schema):
1✔
24
    """
25
    Removes the tag prefix from the operation IDs in the OpenAPI schema.
26

27
    This cleans up the OpenAPI operation IDs that are used by the frontend
28
    client generator to create the names of the functions. The modified
29
    schema is then returned.
30
    """
31
    for path_data in schema["paths"].values():
1✔
32
        for operation in path_data.values():
1✔
33
            tag = operation["tags"][0]
1✔
34
            operation_id = operation["operationId"]
1✔
35
            to_remove = f"{tag}-"
1✔
36
            new_operation_id = operation_id[len(to_remove) :]
1✔
37
            operation["operationId"] = new_operation_id
1✔
38
    return schema
1✔
39

40

41
if __name__ == "__main__":
1✔
42
    generate_openapi_schema(OUTPUT_FILE)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc