Spaces:
Running
Running
refactor: standardize logging usage across OpenAPI utilities (#1322)
Browse files
src/fastmcp/experimental/utilities/openapi/json_schema_converter.py
CHANGED
|
@@ -6,10 +6,11 @@ to JSON Schema, inspired by py-openapi-schema-to-json-schema but optimized
|
|
| 6 |
for our specific use case.
|
| 7 |
"""
|
| 8 |
|
| 9 |
-
import logging
|
| 10 |
from typing import Any
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# OpenAPI-specific fields that should be removed from JSON Schema
|
| 15 |
OPENAPI_SPECIFIC_FIELDS = {
|
|
|
|
| 6 |
for our specific use case.
|
| 7 |
"""
|
| 8 |
|
|
|
|
| 9 |
from typing import Any
|
| 10 |
|
| 11 |
+
from fastmcp.utilities.logging import get_logger
|
| 12 |
+
|
| 13 |
+
logger = get_logger(__name__)
|
| 14 |
|
| 15 |
# OpenAPI-specific fields that should be removed from JSON Schema
|
| 16 |
OPENAPI_SPECIFIC_FIELDS = {
|
src/fastmcp/experimental/utilities/openapi/parser.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
"""OpenAPI parsing logic for converting OpenAPI specs to HTTPRoute objects."""
|
| 2 |
|
| 3 |
-
import logging
|
| 4 |
from typing import Any, Generic, TypeVar
|
| 5 |
|
| 6 |
from openapi_pydantic import (
|
|
@@ -25,6 +24,8 @@ from openapi_pydantic.v3.v3_0 import Response as Response_30
|
|
| 25 |
from openapi_pydantic.v3.v3_0 import Schema as Schema_30
|
| 26 |
from pydantic import BaseModel, ValidationError
|
| 27 |
|
|
|
|
|
|
|
| 28 |
from .models import (
|
| 29 |
HTTPRoute,
|
| 30 |
JsonSchema,
|
|
@@ -35,7 +36,7 @@ from .models import (
|
|
| 35 |
)
|
| 36 |
from .schemas import _combine_schemas_and_map_params, _replace_ref_with_defs
|
| 37 |
|
| 38 |
-
logger =
|
| 39 |
|
| 40 |
# Type variables for generic parser
|
| 41 |
TOpenAPI = TypeVar("TOpenAPI", OpenAPI, OpenAPI_30)
|
|
|
|
| 1 |
"""OpenAPI parsing logic for converting OpenAPI specs to HTTPRoute objects."""
|
| 2 |
|
|
|
|
| 3 |
from typing import Any, Generic, TypeVar
|
| 4 |
|
| 5 |
from openapi_pydantic import (
|
|
|
|
| 24 |
from openapi_pydantic.v3.v3_0 import Schema as Schema_30
|
| 25 |
from pydantic import BaseModel, ValidationError
|
| 26 |
|
| 27 |
+
from fastmcp.utilities.logging import get_logger
|
| 28 |
+
|
| 29 |
from .models import (
|
| 30 |
HTTPRoute,
|
| 31 |
JsonSchema,
|
|
|
|
| 36 |
)
|
| 37 |
from .schemas import _combine_schemas_and_map_params, _replace_ref_with_defs
|
| 38 |
|
| 39 |
+
logger = get_logger(__name__)
|
| 40 |
|
| 41 |
# Type variables for generic parser
|
| 42 |
TOpenAPI = TypeVar("TOpenAPI", OpenAPI, OpenAPI_30)
|
src/fastmcp/experimental/utilities/openapi/schemas.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
"""Schema manipulation utilities for OpenAPI operations."""
|
| 2 |
|
| 3 |
-
import logging
|
| 4 |
from typing import Any
|
| 5 |
|
|
|
|
|
|
|
| 6 |
from .models import HTTPRoute, JsonSchema, ResponseInfo
|
| 7 |
|
| 8 |
-
logger =
|
| 9 |
|
| 10 |
|
| 11 |
def clean_schema_for_display(schema: JsonSchema | None) -> JsonSchema | None:
|
|
|
|
| 1 |
"""Schema manipulation utilities for OpenAPI operations."""
|
| 2 |
|
|
|
|
| 3 |
from typing import Any
|
| 4 |
|
| 5 |
+
from fastmcp.utilities.logging import get_logger
|
| 6 |
+
|
| 7 |
from .models import HTTPRoute, JsonSchema, ResponseInfo
|
| 8 |
|
| 9 |
+
logger = get_logger(__name__)
|
| 10 |
|
| 11 |
|
| 12 |
def clean_schema_for_display(schema: JsonSchema | None) -> JsonSchema | None:
|
src/fastmcp/utilities/openapi.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import json
|
| 2 |
-
import logging
|
| 3 |
from typing import Any, Generic, Literal, TypeVar, cast
|
| 4 |
|
| 5 |
from openapi_pydantic import (
|
|
@@ -24,9 +23,10 @@ from openapi_pydantic.v3.v3_0 import Response as Response_30
|
|
| 24 |
from openapi_pydantic.v3.v3_0 import Schema as Schema_30
|
| 25 |
from pydantic import BaseModel, Field, ValidationError
|
| 26 |
|
|
|
|
| 27 |
from fastmcp.utilities.types import FastMCPBaseModel
|
| 28 |
|
| 29 |
-
logger =
|
| 30 |
|
| 31 |
# --- Intermediate Representation (IR) Definition ---
|
| 32 |
# (IR models remain the same)
|
|
|
|
| 1 |
import json
|
|
|
|
| 2 |
from typing import Any, Generic, Literal, TypeVar, cast
|
| 3 |
|
| 4 |
from openapi_pydantic import (
|
|
|
|
| 23 |
from openapi_pydantic.v3.v3_0 import Schema as Schema_30
|
| 24 |
from pydantic import BaseModel, Field, ValidationError
|
| 25 |
|
| 26 |
+
from fastmcp.utilities.logging import get_logger
|
| 27 |
from fastmcp.utilities.types import FastMCPBaseModel
|
| 28 |
|
| 29 |
+
logger = get_logger(__name__)
|
| 30 |
|
| 31 |
# --- Intermediate Representation (IR) Definition ---
|
| 32 |
# (IR models remain the same)
|