polyapi-python 0.3.14.dev4__py3-none-any.whl → 0.3.15__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/schema.py CHANGED
@@ -101,8 +101,11 @@ def generate_schema_types(input_data: Dict, root=None):
101
101
  return output
102
102
 
103
103
 
104
- # Regex to match everything between "# example: {\n" and "^}$"
105
- MALFORMED_EXAMPLES_PATTERN = re.compile(r"# example: \{\n.*?^\}$", flags=re.DOTALL | re.MULTILINE)
104
+ # Matches commented example headers emitted by jsonschema-gentypes before a raw
105
+ # multiline JSON object/array body that is not commented out.
106
+ MALFORMED_EXAMPLE_HEADER_PATTERN = re.compile(
107
+ r"^\s*#\s*(?:\|\s*)?example:\s*([\[{])\s*$"
108
+ )
106
109
 
107
110
  # Regex to fix invalid escape sequences in docstrings
108
111
  INVALID_ESCAPE_PATTERNS = [
@@ -117,8 +120,24 @@ def clean_malformed_examples(example: str) -> str:
117
120
  """ there is a bug in the `jsonschmea_gentypes` library where if an example from a jsonchema is an object,
118
121
  it will break the code because the object won't be properly commented out. Also fixes invalid escape sequences.
119
122
  """
120
- # Remove malformed examples
121
- cleaned_example = MALFORMED_EXAMPLES_PATTERN.sub("", example)
123
+ cleaned_lines = []
124
+ balance = 0
125
+ skipping_example = False
126
+
127
+ for line in example.splitlines(keepends=True):
128
+ if not skipping_example:
129
+ if MALFORMED_EXAMPLE_HEADER_PATTERN.match(line):
130
+ skipping_example = True
131
+ balance = line.count("{") + line.count("[") - line.count("}") - line.count("]")
132
+ continue
133
+ cleaned_lines.append(line)
134
+ continue
135
+
136
+ balance += line.count("{") + line.count("[") - line.count("}") - line.count("]")
137
+ if balance <= 0:
138
+ skipping_example = False
139
+
140
+ cleaned_example = "".join(cleaned_lines)
122
141
 
123
142
  # Fix invalid escape sequences in docstrings
124
143
  for pattern, replacement in INVALID_ESCAPE_PATTERNS:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.14.dev4
3
+ Version: 0.3.15
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -20,15 +20,15 @@ polyapi/poly_tables.py,sha256=T07j4H-HdcIFP5HwUq0uljpzzYzMtJvdqYvOdC0oZ4I,19728
20
20
  polyapi/prepare.py,sha256=DBlrQu_A0PqdaQ3KlMs-C6PkV3qncatkAiBlC7j2hnk,7441
21
21
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  polyapi/rendered_spec.py,sha256=J2Num7MXnW_mKAe2MSVIL1coWopNYZ-6nNNwQRfseV0,2262
23
- polyapi/schema.py,sha256=-mtRV5iL3CV0X3phXhGYFV8sLz0KouTACOKWyGO9Pwc,5309
23
+ polyapi/schema.py,sha256=2ehUgs4IcNvqsg5cUjZReg-X83hbh4l0eStKmJhFsBY,5921
24
24
  polyapi/server.py,sha256=35l3f9d6jWaa60MfX5n7KF4UCAQR-Xg8WLc0NL9dlfY,2479
25
25
  polyapi/sync.py,sha256=t0Khh8B5GylxB7KWRP_xvkrvkuyVarSLCOvtmaz7lcc,6766
26
26
  polyapi/typedefs.py,sha256=mfll-KrngOW0wzbvDNiIDaDkFMwbsT-MY5y5hzWj9RE,5642
27
27
  polyapi/utils.py,sha256=VN8n_jvphderplI5MDYjSutxVnYbJjHhJznYkwjgstw,13349
28
28
  polyapi/variables.py,sha256=hfSDPGQK6YphNCa9MqE0W88WIFfqCQWgpBDWkExMq-A,7582
29
29
  polyapi/webhook.py,sha256=0ceLwHNjNd2Yx_8MX5jOIxiQ5Lwhy2pe81ProAuKon0,5108
30
- polyapi_python-0.3.14.dev4.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
31
- polyapi_python-0.3.14.dev4.dist-info/METADATA,sha256=_SPOiz8v0LAzfWBJQw4XwS7w0Z5-sJuPW7WghBXnT38,5928
32
- polyapi_python-0.3.14.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
33
- polyapi_python-0.3.14.dev4.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
34
- polyapi_python-0.3.14.dev4.dist-info/RECORD,,
30
+ polyapi_python-0.3.15.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
31
+ polyapi_python-0.3.15.dist-info/METADATA,sha256=IyUgGO1dlCtUPOc-Eu75YmalUsHes80GZRTdpT-8ZGg,5923
32
+ polyapi_python-0.3.15.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
33
+ polyapi_python-0.3.15.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
34
+ polyapi_python-0.3.15.dist-info/RECORD,,