jentic-openapi-validator 1.0.0a28__py3-none-any.whl → 1.0.0a30__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.
@@ -1,9 +1,8 @@
1
- import asyncio
2
1
  import importlib.metadata
3
2
  import json
4
3
  import warnings
5
4
  from collections.abc import Sequence
6
- from concurrent.futures import ProcessPoolExecutor
5
+ from concurrent.futures import ProcessPoolExecutor, as_completed
7
6
  from typing import Type
8
7
 
9
8
  from jentic.apitools.openapi.parser.core import OpenAPIParser
@@ -147,24 +146,29 @@ class OpenAPIValidator:
147
146
  f"Expected str (URI or JSON/YAML) or dict."
148
147
  )
149
148
 
149
+ diagnostics: list[JenticDiagnostic] = []
150
+
150
151
  # Run validation through all backends
151
152
  if parallel and len(self.backends) > 1:
152
- # Parallel execution using asyncio with ProcessPoolExecutor
153
- diagnostics = asyncio.run(
154
- _validate_parallel(
155
- self.backends,
156
- document,
157
- document_dict,
158
- document_text,
159
- document_is_uri,
160
- base_url,
161
- target,
162
- max_workers,
163
- )
164
- )
153
+ # Parallel execution using ProcessPoolExecutor
154
+ with ProcessPoolExecutor(max_workers=max_workers) as executor:
155
+ futures = [
156
+ executor.submit(
157
+ _validate_single_backend,
158
+ backend,
159
+ document,
160
+ document_dict,
161
+ document_text,
162
+ document_is_uri,
163
+ base_url,
164
+ target,
165
+ )
166
+ for backend in self.backends
167
+ ]
168
+ for future in as_completed(futures):
169
+ diagnostics.extend(future.result())
165
170
  else:
166
171
  # Sequential execution (default)
167
- diagnostics: list[JenticDiagnostic] = []
168
172
  for backend in self.backends:
169
173
  diagnostics.extend(
170
174
  _validate_single_backend(
@@ -259,58 +263,3 @@ def _validate_single_backend(
259
263
  result = backend.validate(backend_document, base_url=base_url, target=target)
260
264
  return list(result.diagnostics)
261
265
  return []
262
-
263
-
264
- async def _validate_parallel(
265
- backends: Sequence[BaseValidatorBackend],
266
- document: str | dict,
267
- document_dict: dict | None,
268
- document_text: str,
269
- document_is_uri: bool,
270
- base_url: str | None,
271
- target: str | None,
272
- max_workers: int | None,
273
- ) -> list[JenticDiagnostic]:
274
- """
275
- Run validators in parallel using ProcessPoolExecutor.
276
-
277
- This module-level async function uses asyncio's run_in_executor to dispatch
278
- each backend validation to a separate process, enabling true parallelism
279
- for CPU-bound validators.
280
-
281
- Args:
282
- backends: List of validator backends to run
283
- document: The original document (URI or text)
284
- document_dict: Parsed document as dict (if available)
285
- document_text: Document as text string
286
- document_is_uri: Whether document is a URI
287
- base_url: Optional base URL for resolving references
288
- target: Optional target identifier
289
- max_workers: Maximum number of worker processes
290
-
291
- Returns:
292
- Aggregated list of diagnostics from all backends
293
- """
294
- loop = asyncio.get_running_loop()
295
-
296
- with ProcessPoolExecutor(max_workers=max_workers) as executor:
297
- tasks = [
298
- loop.run_in_executor(
299
- executor,
300
- _validate_single_backend,
301
- backend,
302
- document,
303
- document_dict,
304
- document_text,
305
- document_is_uri,
306
- base_url,
307
- target,
308
- )
309
- for backend in backends
310
- ]
311
- results = await asyncio.gather(*tasks)
312
-
313
- diagnostics: list[JenticDiagnostic] = []
314
- for result in results:
315
- diagnostics.extend(result)
316
- return diagnostics
@@ -1,17 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jentic-openapi-validator
3
- Version: 1.0.0a28
3
+ Version: 1.0.0a30
4
4
  Summary: Jentic OpenAPI Validator
5
5
  Author: Jentic
6
6
  Author-email: Jentic <hello@jentic.com>
7
7
  License-Expression: Apache-2.0
8
8
  License-File: LICENSE
9
9
  License-File: NOTICE
10
- Requires-Dist: jentic-openapi-parser~=1.0.0a28
10
+ Requires-Dist: jentic-openapi-parser~=1.0.0a30
11
11
  Requires-Dist: openapi-spec-validator~=0.7.2
12
12
  Requires-Dist: lsprotocol~=2025.0.0
13
- Requires-Dist: jentic-openapi-validator-redocly~=1.0.0a28 ; extra == 'redocly'
14
- Requires-Dist: jentic-openapi-validator-spectral~=1.0.0a28 ; extra == 'spectral'
13
+ Requires-Dist: jentic-openapi-validator-redocly~=1.0.0a30 ; extra == 'redocly'
14
+ Requires-Dist: jentic-openapi-validator-spectral~=1.0.0a30 ; extra == 'spectral'
15
15
  Requires-Python: >=3.11
16
16
  Project-URL: Homepage, https://github.com/jentic/jentic-openapi-tools
17
17
  Provides-Extra: redocly
@@ -152,7 +152,7 @@ result = validator.validate(document, parallel=True)
152
152
  result = validator.validate(document, parallel=True, max_workers=2)
153
153
  ```
154
154
 
155
- Parallel execution uses `asyncio` with `ProcessPoolExecutor` via `run_in_executor()`, enabling true parallelism that bypasses Python's GIL. This is particularly beneficial when using multiple backends, especially I/O-bound backends like Spectral and Redocly that spawn subprocesses.
155
+ Parallel execution uses `ProcessPoolExecutor` for true parallelism that bypasses Python's GIL. This is particularly beneficial when using multiple backends, especially I/O-bound backends like Spectral and Redocly that spawn subprocesses.
156
156
 
157
157
  **Notes:**
158
158
  - `parallel=False` by default (opt-in)
@@ -8,11 +8,11 @@ jentic/apitools/openapi/validator/backends/openapi_spec.py,sha256=tEboIwNHxe8BXk
8
8
  jentic/apitools/openapi/validator/backends/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  jentic/apitools/openapi/validator/core/__init__.py,sha256=OOJD1Z8Zn8ya537_62xaAhdHypy8J8iFHvx0U0DpP5o,181
10
10
  jentic/apitools/openapi/validator/core/diagnostics.py,sha256=3TXAxIHly_o5lKw_YcNEwOH2BinOHBK90X32-ioFGFc,3233
11
- jentic/apitools/openapi/validator/core/openapi_validator.py,sha256=lEYhwHhcuzJFYpvgQTjVAkLSobWxEJOZn6waU6fgWyc,11591
11
+ jentic/apitools/openapi/validator/core/openapi_validator.py,sha256=5X5VmPhseDhw2uFlABrwU0jA1nWAnoWl4YfsZxdE1nU,10119
12
12
  jentic/apitools/openapi/validator/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- jentic_openapi_validator-1.0.0a28.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
14
- jentic_openapi_validator-1.0.0a28.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
15
- jentic_openapi_validator-1.0.0a28.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
16
- jentic_openapi_validator-1.0.0a28.dist-info/entry_points.txt,sha256=zIjHHOn2NeSIYzj-HvxuXZY74uRXJOE0Vi4aFV09gjg,237
17
- jentic_openapi_validator-1.0.0a28.dist-info/METADATA,sha256=KmQK1mxEK-3896YHAsuaAP5BEI_2X-92iIO9vnuKSck,8359
18
- jentic_openapi_validator-1.0.0a28.dist-info/RECORD,,
13
+ jentic_openapi_validator-1.0.0a30.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
14
+ jentic_openapi_validator-1.0.0a30.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
15
+ jentic_openapi_validator-1.0.0a30.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
16
+ jentic_openapi_validator-1.0.0a30.dist-info/entry_points.txt,sha256=zIjHHOn2NeSIYzj-HvxuXZY74uRXJOE0Vi4aFV09gjg,237
17
+ jentic_openapi_validator-1.0.0a30.dist-info/METADATA,sha256=mMCpyPyXzgNkbO7CkXmLmnjtZIE5169PmSxoeZnEYa0,8314
18
+ jentic_openapi_validator-1.0.0a30.dist-info/RECORD,,