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

vintasoftware / nextjs-fastapi-template / 12466496974

23 Dec 2024 12:04PM CUT coverage: 97.313% (-0.7%) from 98.003%
12466496974

Pull #48

github

andersonresende
Merge branch 'main' into ft/password-reset-field-errors
Pull Request #48: Added field and form errors to password reset

83 of 98 branches covered (84.69%)

Branch coverage included in aggregate %.

31 of 39 new or added lines in 5 files covered. (79.49%)

4 existing lines in 3 files now uncovered.

1873 of 1912 relevant lines covered (97.96%)

6.9 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