mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-13 16:14:10 +00:00
chore(deps): redis 8, tiktoken 0.14, openapi3-parser 2, daytona 0.211, reportlab 5
Major bumps whose ceilings had to move. redis 8.1.0, tiktoken 0.14.0 and daytona 0.211.2 needed no code change (the Daytona client, filesystem and process signatures the sandbox calls are unchanged; redis 8 was checked against a live server through the app's own sync and async clients). reportlab 5.0.1 is test-only. openapi-parser 2.0.0 is a rewrite onto pydantic spec models: `paths` is now a dict keyed by URL rather than a list of objects carrying their own `url`, and a path item exposes one field per HTTP method instead of an `operations` list. `OpenAPI3Parser` reads both accordingly, iterating methods in the order the spec declares them, and its rendered output is byte-identical to before. The rewrite also drops prance, openapi-spec-validator and five more transitive packages. tokenizers stays at 0.22.2: transformers 5.8.1 caps it at <=0.23.0 and no such release exists, so it moves with the transformers cap or not at all.
This commit is contained in:
1 parent
7e00197678
commit
b3326b3c33
8 files changed
+197
-369
No files matched your search
@@ -1,3 +1,4 @@
|
||||
from typing import Dict, Iterable, Optional, Tuple
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from openapi_parser import parse
|
||||
@@ -7,6 +8,20 @@ try:
|
||||
except ModuleNotFoundError:
|
||||
from base_parser import BaseParser
|
||||
|
||||
# openapi-parser 2.x models a path item as one field per HTTP method rather
|
||||
# than an ``operations`` list, so the methods are read in the order the
|
||||
# OpenAPI spec declares them.
|
||||
_HTTP_METHODS: Tuple[str, ...] = (
|
||||
"get",
|
||||
"put",
|
||||
"post",
|
||||
"delete",
|
||||
"options",
|
||||
"head",
|
||||
"patch",
|
||||
"trace",
|
||||
)
|
||||
|
||||
|
||||
class OpenAPI3Parser(BaseParser):
|
||||
def init_parser(self) -> None:
|
||||
@@ -21,14 +36,21 @@ class OpenAPI3Parser(BaseParser):
|
||||
base_urls.append(base_url)
|
||||
return base_urls
|
||||
|
||||
def get_info_from_paths(self, path):
|
||||
def get_operations(self, path_item) -> Iterable[Tuple[str, object]]:
|
||||
"""Yield ``(method, operation)`` for every method the path item defines."""
|
||||
for method in _HTTP_METHODS:
|
||||
operation = getattr(path_item, method, None)
|
||||
if operation is not None:
|
||||
yield method, operation
|
||||
|
||||
def get_info_from_paths(self, path_item) -> str:
|
||||
"""Render one line per method as ``\\n<method>=<first response description>``."""
|
||||
info = ""
|
||||
if path.operations:
|
||||
for operation in path.operations:
|
||||
info += (
|
||||
f"\n{operation.method.value}="
|
||||
f"{operation.responses[0].description}"
|
||||
)
|
||||
for method, operation in self.get_operations(path_item):
|
||||
responses = operation.responses or {}
|
||||
first = next(iter(responses.values()), None)
|
||||
description = getattr(first, "description", None)
|
||||
info += f"\n{method}={description}"
|
||||
return info
|
||||
|
||||
def parse_file(self, file_path):
|
||||
@@ -37,15 +59,14 @@ class OpenAPI3Parser(BaseParser):
|
||||
base_urls = self.get_base_urls(link.url for link in data.servers)
|
||||
base_urls = ",".join([base_url for base_url in base_urls])
|
||||
results += f"Base URL:{base_urls}\n"
|
||||
i = 1
|
||||
for path in data.paths:
|
||||
info = self.get_info_from_paths(path)
|
||||
paths: Optional[Dict] = data.paths or {}
|
||||
for i, (url, path_item) in enumerate(paths.items(), start=1):
|
||||
info = self.get_info_from_paths(path_item)
|
||||
results += (
|
||||
f"Path{i}: {path.url}\n"
|
||||
f"description: {path.description}\n"
|
||||
f"parameters: {path.parameters}\nmethods: {info}\n"
|
||||
f"Path{i}: {url}\n"
|
||||
f"description: {path_item.description}\n"
|
||||
f"parameters: {path_item.parameters or []}\nmethods: {info}\n"
|
||||
)
|
||||
i += 1
|
||||
with open("results.txt", "w") as f:
|
||||
f.write(results)
|
||||
return results
|
||||
Reference in new issue
Block a user