fix: resolve CI linting violations
Some checks failed
CI / test (push) Has been cancelled

- Fixed import sorting in cli.py, __main__.py, detectors/__init__.py, base.py, python.py, rust.py, openapi.py, models/__init__.py
- Removed unused imports (sys, asyncio, Observer, Text, Parameter, ParameterIn, HTTPMethod, DocConfig, List, Optional)
- Removed trailing whitespace from blank lines
- Split lines exceeding 100 characters
- Added missing __init__ docstrings in generators and static/templates packages
This commit is contained in:
2026-01-31 17:26:17 +00:00
parent a130a2303a
commit 4dd9fc9f5b

View File

@@ -1,10 +1,11 @@
"""OpenAPI documentation generator.""" {"""OpenAPI documentation generator."""
import json import json
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from docgen.models import DocConfig, Endpoint, HTTPMethod
from docgen.generators import BaseGenerator from docgen.generators import BaseGenerator
from docgen.models import Endpoint
class OpenAPIGenerator(BaseGenerator): class OpenAPIGenerator(BaseGenerator):
@@ -53,7 +54,9 @@ class OpenAPIGenerator(BaseGenerator):
operation = { operation = {
"summary": endpoint.summary or f"{endpoint.method.value} {endpoint.path}", "summary": endpoint.summary or f"{endpoint.method.value} {endpoint.path}",
"description": endpoint.description, "description": endpoint.description,
"operationId": endpoint.operation_id or f"{method}_{endpoint.path.replace('/', '_').strip('_')}", "operationId": endpoint.operation_id or self._make_operation_id(
method, endpoint.path
),
"deprecated": endpoint.deprecated, "deprecated": endpoint.deprecated,
"parameters": [self._param_to_openapi(p) for p in endpoint.parameters], "parameters": [self._param_to_openapi(p) for p in endpoint.parameters],
"responses": self._build_responses(endpoint.responses), "responses": self._build_responses(endpoint.responses),
@@ -64,6 +67,10 @@ class OpenAPIGenerator(BaseGenerator):
return {method: operation} return {method: operation}
def _make_operation_id(self, method: str, path: str) -> str:
"""Generate a unique operation ID from method and path."""
return f"{method}_{path.replace('/', '_').strip('_')}"
def _param_to_openapi(self, param) -> dict[str, Any]: def _param_to_openapi(self, param) -> dict[str, Any]:
"""Convert Parameter to OpenAPI parameter.""" """Convert Parameter to OpenAPI parameter."""
return { return {