Skip to content

Commit 1fe296a

Browse files
TS0713crivetimihai
authored andcommitted
added alias for mime_type in schemas > ResourceCreate, fixed pytest
Signed-off-by: Satya <tsp.0713@gmail.com>
1 parent da03cc9 commit 1fe296a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mcpgateway/schemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,12 +1495,12 @@ class ResourceCreate(BaseModel):
14951495
content (Union[str, bytes]): Content of the resource, which can be text or binary.
14961496
"""
14971497

1498-
model_config = ConfigDict(str_strip_whitespace=True)
1498+
model_config = ConfigDict(str_strip_whitespace=True, populate_by_name=True)
14991499

15001500
uri: str = Field(..., description="Unique URI for the resource")
15011501
name: str = Field(..., description="Human-readable resource name")
15021502
description: Optional[str] = Field(None, description="Resource description")
1503-
mime_type: Optional[str] = Field(None, description="Resource MIME type")
1503+
mime_type: Optional[str] = Field(None, alias="mimeType", description="Resource MIME type")
15041504
template: Optional[str] = Field(None, description="URI template for parameterized resources")
15051505
content: Union[str, bytes] = Field(..., description="Resource content (text or binary)")
15061506
tags: Optional[List[str]] = Field(default_factory=list, description="Tags for categorizing the resource")

tests/e2e/test_main_apis.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,14 @@ async def test_create_json_resource(self, client: AsyncClient, mock_auth):
963963
}
964964

965965
response = await client.post("/resources", json=resource_data, headers=TEST_AUTH_HEADER)
966-
967966
assert response.status_code == 200
968967
result = response.json()
969968
# API normalizes all mime types to text/plain
970-
assert result["mimeType"] == "text/plain"
969+
if "mime_type" in result:
970+
assert result["mime_type"] == "application/json"
971+
elif "mimeType" in result:
972+
assert result["mimeType"] == "application/json"
973+
971974

972975
async def test_create_resource_form_urlencoded(self, client: AsyncClient, mock_auth):
973976
"""

0 commit comments

Comments
 (0)