drf-to-mkdoc 0.1.0__py3-none-any.whl → 0.1.3__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.
- drf_to_mkdoc/__init__.py +6 -6
- drf_to_mkdoc/apps.py +14 -14
- drf_to_mkdoc/conf/settings.py +44 -44
- drf_to_mkdoc/management/commands/build_docs.py +76 -76
- drf_to_mkdoc/management/commands/generate_doc_json.py +512 -512
- drf_to_mkdoc/management/commands/generate_docs.py +138 -138
- drf_to_mkdoc/management/commands/generate_model_docs.py +327 -327
- drf_to_mkdoc/management/commands/update_doc_schema.py +53 -53
- drf_to_mkdoc/utils/__init__.py +3 -3
- drf_to_mkdoc/utils/endpoint_generator.py +945 -945
- drf_to_mkdoc/utils/extractors/__init__.py +3 -3
- drf_to_mkdoc/utils/extractors/query_parameter_extractors.py +229 -229
- drf_to_mkdoc/utils/md_generators/query_parameters_generators.py +72 -72
- drf_to_mkdoc/utils/model_generator.py +269 -269
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/METADATA +247 -247
- drf_to_mkdoc-0.1.3.dist-info/RECORD +25 -0
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/licenses/LICENSE +21 -21
- drf_to_mkdoc-0.1.0.dist-info/RECORD +0 -25
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/WHEEL +0 -0
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/top_level.txt +0 -0
|
@@ -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
|
+
)
|
drf_to_mkdoc/utils/__init__.py
CHANGED
|
@@ -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
|
+
"""
|