drf-to-mkdoc 0.1.8__py3-none-any.whl → 0.1.9__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.

@@ -5,6 +5,8 @@ DEFAULTS = {
5
5
  "MODEL_DOCS_FILE": "docs/model-docs.json", # Path to model documentation JSON file
6
6
  "DOC_CONFIG_FILE": "docs/configs/doc_config.json", # Path to documentation configuration file
7
7
  "CUSTOM_SCHEMA_FILE": "docs/configs/custom_schema.json", # Path to custom schema file
8
+ "PATH_PARAM_SUBSTITUTE_FUNCTION": None,
9
+ "PATH_PARAM_SUBSTITUTE_MAPPING": {},
8
10
  # Django apps - required, no default
9
11
  "DJANGO_APPS": None, # List of Django app names to process
10
12
  }
@@ -174,39 +174,44 @@ def get_custom_schema():
174
174
  def convert_to_django_path(path: str, parameters: list[dict[str, Any]]) -> str:
175
175
  """
176
176
  Convert a path with {param} to a Django-style path with <type:param>.
177
- If PATH_PARAM_SUBSTITUTOR is set, use that function instead.
177
+ If PATH_PARAM_SUBSTITUTE_FUNCTION is set, use that function instead.
178
178
  """
179
179
  function = None
180
- func_path = getattr(drf_to_mkdoc_settings, "PATH_PARAM_SUBSTITUTOR", None)
180
+ func_path = drf_to_mkdoc_settings.PATH_PARAM_SUBSTITUTE_FUNCTION
181
181
 
182
182
  if func_path:
183
183
  try:
184
184
  function = import_string(func_path)
185
185
  except ImportError:
186
- logger.warning("PATH_PARAM_SUBSTITUTOR is not a valid import path")
186
+ logger.warning("PATH_PARAM_SUBSTITUTE_FUNCTION is not a valid import path")
187
187
 
188
188
  # If custom function exists and returns a valid value, use it
189
+ PATH_PARAM_SUBSTITUTE_MAPPING = drf_to_mkdoc_settings.PATH_PARAM_SUBSTITUTE_MAPPING
189
190
  if callable(function):
190
191
  try:
191
- value = function(path, parameters)
192
- if isinstance(value, str) and value.strip():
193
- return value
192
+ result = function(path, parameters)
193
+ if result and isinstance(result, dict):
194
+ PATH_PARAM_SUBSTITUTE_MAPPING.update(result)
194
195
  except Exception as e:
195
196
  logger.exception("Error in custom path substitutor: %s", e)
196
197
 
197
198
  # Default Django path conversion
198
199
  def replacement(match):
199
200
  param_name = match.group(1)
200
- param_info = next((p for p in parameters if p.get("name") == param_name), {})
201
- param_type = param_info.get("schema", {}).get("type")
202
- param_format = param_info.get("schema", {}).get("format")
203
-
204
- if param_type == "integer":
205
- converter = "int"
206
- elif param_type == "string" and param_format == "uuid":
207
- converter = "uuid"
201
+ custom_param_type = PATH_PARAM_SUBSTITUTE_MAPPING.get(param_name)
202
+ if custom_param_type and custom_param_type in ("int", "uuid", "str"):
203
+ converter = custom_param_type
208
204
  else:
209
- converter = "str"
205
+ param_info = next((p for p in parameters if p.get("name") == param_name), {})
206
+ param_type = param_info.get("schema", {}).get("type")
207
+ param_format = param_info.get("schema", {}).get("format")
208
+
209
+ if param_type == "integer":
210
+ converter = "int"
211
+ elif param_type == "string" and param_format == "uuid":
212
+ converter = "uuid"
213
+ else:
214
+ converter = "str"
210
215
 
211
216
  return f"<{converter}:{param_name}>"
212
217
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drf-to-mkdoc
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Generate Markdown API docs from Django/DRF OpenAPI schema for MkDocs
5
5
  Author-email: Hossein Shayesteh <shayestehhs1@gmail.com>
6
6
  Maintainer-email: Hossein Shayesteh <shayestehhs1@gmail.com>
@@ -1,7 +1,7 @@
1
1
  drf_to_mkdoc/__init__.py,sha256=IbTW5uKQvJRG9ncHRuk_AGKHPn4ruxs5LqDpUFgUhws,180
2
2
  drf_to_mkdoc/apps.py,sha256=-NrC_dRr6GmLmNQhkNh819B7V1SS4DYDv5JOR0TtuJM,560
3
3
  drf_to_mkdoc/conf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- drf_to_mkdoc/conf/defaults.py,sha256=hEjQdN3WsT539UWhFkylI60piykV_7BDudLPNd_E8PE,575
4
+ drf_to_mkdoc/conf/defaults.py,sha256=DZiATgfjkyU_J1RgR_zAzPdOVp-F2o3LVwjb3hP6j0U,660
5
5
  drf_to_mkdoc/conf/settings.py,sha256=OOna4jWNTEfROBprpKnEHVl5RcAYExmOf0gBMA0E_FY,1664
6
6
  drf_to_mkdoc/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  drf_to_mkdoc/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -34,7 +34,7 @@ drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/models/model-tables.css,sha256=8CSy
34
34
  drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/models/responsive.css,sha256=ygqyUtpiWchTBBIQil1C6mN0AC5xinLoP7whSKfBmwg,944
35
35
  drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/models/variables.css,sha256=2HvyjnJrygSzdzpE-FYpo6FGhrYhmZ7NwDFAkADXQNg,1094
36
36
  drf_to_mkdoc/utils/__init__.py,sha256=6dFTb07S6yIf-INMy0Mlgf5purNir687ZU9WZtITh4k,68
37
- drf_to_mkdoc/utils/common.py,sha256=qPF7tfnEsRbf57JJwDCqMtjMFmxmpWguXPQabHkag70,11711
37
+ drf_to_mkdoc/utils/common.py,sha256=SxjGe9MtyxTyroXP7QdUiW9QqZ1N7xPjHHaAI-hqYxc,12077
38
38
  drf_to_mkdoc/utils/endpoint_detail_generator.py,sha256=mX3sklhWsd-FmOV-ePrhLpg5l8-Eu7V7qb5EL4Tq0FI,27650
39
39
  drf_to_mkdoc/utils/endpoint_list_generator.py,sha256=P7pEHscHNHpjDuTXmAUPYV3_t8uGSdaYOgiDGGoCwYc,9705
40
40
  drf_to_mkdoc/utils/model_detail_generator.py,sha256=P5kWO-5aWgvyPgzq1qXnt1380ExnrzlOw18zI57P9u0,8063
@@ -43,8 +43,8 @@ drf_to_mkdoc/utils/extractors/__init__.py,sha256=BvC8gKOPVI9gU1Piw0jRhKQ2ER5s1mo
43
43
  drf_to_mkdoc/utils/extractors/query_parameter_extractors.py,sha256=gnDlvF-bxkTp2NcEQf0EZZAfmdQzUpedhZ7N1LAYQzU,8432
44
44
  drf_to_mkdoc/utils/md_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  drf_to_mkdoc/utils/md_generators/query_parameters_generators.py,sha256=N-XqZ_FUODSR5V4xM9oEA3aaIiNGNmNwpvrWbQTx6RI,2566
46
- drf_to_mkdoc-0.1.8.dist-info/licenses/LICENSE,sha256=3n9_ckIREsH8ogCxWW6dFsw_WfGcluG2mHcgl9i_UU0,1068
47
- drf_to_mkdoc-0.1.8.dist-info/METADATA,sha256=A_y3wLQBP6TCyeuv40sF-iqeD-UEYLzXQwUTdeem1dI,7037
48
- drf_to_mkdoc-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- drf_to_mkdoc-0.1.8.dist-info/top_level.txt,sha256=ZzJecR6j_tvLZiubUBEgawHflozC4DQy9ooNf1yDJ3Q,13
50
- drf_to_mkdoc-0.1.8.dist-info/RECORD,,
46
+ drf_to_mkdoc-0.1.9.dist-info/licenses/LICENSE,sha256=3n9_ckIREsH8ogCxWW6dFsw_WfGcluG2mHcgl9i_UU0,1068
47
+ drf_to_mkdoc-0.1.9.dist-info/METADATA,sha256=FgkNktIYpIuto47SGr2cvo_DdxMs15HGG6d8uaZAc7w,7037
48
+ drf_to_mkdoc-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ drf_to_mkdoc-0.1.9.dist-info/top_level.txt,sha256=ZzJecR6j_tvLZiubUBEgawHflozC4DQy9ooNf1yDJ3Q,13
50
+ drf_to_mkdoc-0.1.9.dist-info/RECORD,,