polyapi-python 0.3.20.dev0__py3-none-any.whl → 0.3.20.dev1__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.
polyapi/utils.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import keyword
2
2
  import re
3
3
  import os
4
- from urllib.parse import urlparse
4
+ from urllib.parse import unquote, urlparse
5
5
  from typing import Tuple, List, Optional, cast
6
6
  from colorama import Fore, Style
7
7
  from polyapi.constants import BASIC_PYTHON_TYPES
@@ -299,11 +299,29 @@ def _maybe_add_fallback_schema_name(a: PropertySpecification):
299
299
  # Handle cases where type might be missing
300
300
  if not a.get("type"):
301
301
  return
302
-
302
+
303
303
  if a["type"].get("kind") == "object" and a["type"].get("schema"):
304
304
  schema = a["type"].get("schema", {})
305
- if not schema.get("title") and not schema.get("name") and a.get("name"):
306
- schema["title"] = a["name"].title()
305
+ title = schema.get("title") or schema.get("name")
306
+ if not title and a.get("name"):
307
+ title = a["name"].title()
308
+ schema["title"] = title
309
+
310
+ reference = schema.get("$ref")
311
+ definitions = schema.get("definitions")
312
+ reference_prefix = "#/definitions/"
313
+ if not isinstance(title, str):
314
+ return
315
+ if not isinstance(reference, str) or not reference.startswith(reference_prefix):
316
+ return
317
+ if not isinstance(definitions, dict):
318
+ return
319
+
320
+ definition_name = unquote(reference[len(reference_prefix):])
321
+ definition_name = definition_name.replace("~1", "/").replace("~0", "~")
322
+ definition = definitions.get(definition_name)
323
+ if isinstance(definition, dict):
324
+ definition.setdefault("title", title)
307
325
 
308
326
 
309
327
  def _clean_description(text: str) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.20.dev0
3
+ Version: 0.3.20.dev1
4
4
  Summary: The Python SDK for the integration platform PolyAPI
5
5
  Author-email: PolyAPI <support@polyapi.io>
6
6
  License: MIT License
@@ -25,11 +25,11 @@ polyapi/schema.py,sha256=SPO5GDvIE1BjRfJR89vJMEGCXERfEbhNXQm2A05UAOc,6959
25
25
  polyapi/server.py,sha256=_14lP4_BmRYMBXwaqXVWmiSTHH3h7ecCHxSalM9UiSc,3049
26
26
  polyapi/sync.py,sha256=t0Khh8B5GylxB7KWRP_xvkrvkuyVarSLCOvtmaz7lcc,6766
27
27
  polyapi/typedefs.py,sha256=UeAdyYrgqxrvBRkjisK_xgzQmuTePPvOM74HKf1y0II,5656
28
- polyapi/utils.py,sha256=dIkuIlGNsg1USiXNNkUnOtLVzie4mxBCBlTc0YsaXao,15594
28
+ polyapi/utils.py,sha256=LUqTkbb0b7y3gjsOU-WO1LVYaTMyExTGpYjKY8wVKg8,16300
29
29
  polyapi/variables.py,sha256=hfSDPGQK6YphNCa9MqE0W88WIFfqCQWgpBDWkExMq-A,7582
30
30
  polyapi/webhook.py,sha256=0ceLwHNjNd2Yx_8MX5jOIxiQ5Lwhy2pe81ProAuKon0,5108
31
- polyapi_python-0.3.20.dev0.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
32
- polyapi_python-0.3.20.dev0.dist-info/METADATA,sha256=ALClEHU18Bx3hbOi6PeBVsdv1zBdyWQCq6sbnVe36B4,5898
33
- polyapi_python-0.3.20.dev0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
34
- polyapi_python-0.3.20.dev0.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
35
- polyapi_python-0.3.20.dev0.dist-info/RECORD,,
31
+ polyapi_python-0.3.20.dev1.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
32
+ polyapi_python-0.3.20.dev1.dist-info/METADATA,sha256=uQkx5Ut9vT6cP2Gt3rsw3yB1uSWGB9_Q85rel0BlzFg,5898
33
+ polyapi_python-0.3.20.dev1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
34
+ polyapi_python-0.3.20.dev1.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
35
+ polyapi_python-0.3.20.dev1.dist-info/RECORD,,