drf-to-mkdoc 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of drf-to-mkdoc might be problematic. Click here for more details.

@@ -1,53 +1,53 @@
1
- import os
2
- import shutil
3
-
4
- import yaml
5
- from django.conf import settings
6
- from django.core.management.base import BaseCommand
7
-
8
-
9
- class Command(BaseCommand):
10
- help = "Updates the final schema by copying the documented schema."
11
-
12
- def handle(self, *args, **options):
13
- self.stdout.write("Starting the schema update process...")
14
-
15
- # Load documented schema
16
- doc_schema_path = os.path.join(settings.BASE_DIR, "docs/configs/doc-schema.yaml")
17
- try:
18
- with open(doc_schema_path) as f:
19
- documented_schema = yaml.safe_load(f)
20
- self.stdout.write(f"Successfully loaded documented schema from {doc_schema_path}")
21
- except FileNotFoundError:
22
- self.stderr.write(
23
- self.style.ERROR(f"'{doc_schema_path}' not found. Please create it first.")
24
- )
25
- return
26
- except yaml.YAMLError as e:
27
- self.stderr.write(self.style.ERROR(f"Error parsing '{doc_schema_path}': {e}"))
28
- return
29
-
30
- # Save to final schema location
31
- output_path = os.path.join(settings.BASE_DIR, "schema.yaml")
32
-
33
- # Create backup if schema.yaml exists
34
- if os.path.exists(output_path):
35
- backup_path = f"{output_path}.bak"
36
- shutil.copyfile(output_path, backup_path)
37
- self.stdout.write(f"Created backup at '{backup_path}'")
38
-
39
- # Write the documented schema
40
- with open(output_path, "w") as f:
41
- yaml.dump(documented_schema, f, default_flow_style=False, sort_keys=False)
42
-
43
- # Count documented endpoints
44
- paths_count = len(documented_schema.get("paths", {}))
45
-
46
- self.stdout.write(
47
- self.style.SUCCESS(f"Successfully updated schema and saved to '{output_path}'.")
48
- )
49
- self.stdout.write(f"Schema now contains {paths_count} documented endpoint(s).")
50
- self.stdout.write(
51
- "You can now use this schema for API documentation or import"
52
- " it into tools like Swagger UI."
53
- )
1
+ import os
2
+ import shutil
3
+
4
+ import yaml
5
+ from django.conf import settings
6
+ from django.core.management.base import BaseCommand
7
+
8
+
9
+ class Command(BaseCommand):
10
+ help = "Updates the final schema by copying the documented schema."
11
+
12
+ def handle(self, *args, **options):
13
+ self.stdout.write("Starting the schema update process...")
14
+
15
+ # Load documented schema
16
+ doc_schema_path = os.path.join(settings.BASE_DIR, "docs/configs/doc-schema.yaml")
17
+ try:
18
+ with open(doc_schema_path) as f:
19
+ documented_schema = yaml.safe_load(f)
20
+ self.stdout.write(f"Successfully loaded documented schema from {doc_schema_path}")
21
+ except FileNotFoundError:
22
+ self.stderr.write(
23
+ self.style.ERROR(f"'{doc_schema_path}' not found. Please create it first.")
24
+ )
25
+ return
26
+ except yaml.YAMLError as e:
27
+ self.stderr.write(self.style.ERROR(f"Error parsing '{doc_schema_path}': {e}"))
28
+ return
29
+
30
+ # Save to final schema location
31
+ output_path = os.path.join(settings.BASE_DIR, "schema.yaml")
32
+
33
+ # Create backup if schema.yaml exists
34
+ if os.path.exists(output_path):
35
+ backup_path = f"{output_path}.bak"
36
+ shutil.copyfile(output_path, backup_path)
37
+ self.stdout.write(f"Created backup at '{backup_path}'")
38
+
39
+ # Write the documented schema
40
+ with open(output_path, "w") as f:
41
+ yaml.dump(documented_schema, f, default_flow_style=False, sort_keys=False)
42
+
43
+ # Count documented endpoints
44
+ paths_count = len(documented_schema.get("paths", {}))
45
+
46
+ self.stdout.write(
47
+ self.style.SUCCESS(f"Successfully updated schema and saved to '{output_path}'.")
48
+ )
49
+ self.stdout.write(f"Schema now contains {paths_count} documented endpoint(s).")
50
+ self.stdout.write(
51
+ "You can now use this schema for API documentation or import"
52
+ " it into tools like Swagger UI."
53
+ )
@@ -1,3 +1,3 @@
1
- """
2
- Utility modules for DRF to MkDocs documentation generation.
3
- """
1
+ """
2
+ Utility modules for DRF to MkDocs documentation generation.
3
+ """