Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/experimentation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def _get_user(request: Request) -> FFAdminUser:
),
)
@method_decorator(
name="update",
name="partial_update",
decorator=extend_schema(
tags=["mcp"],
operation_id="update_experiment",
Expand Down
17 changes: 17 additions & 0 deletions api/tests/unit/experimentation/test_experiment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,23 @@ def test_patch__change_feature__returns_400(
assert response.status_code == status.HTTP_400_BAD_REQUEST


def test_openapi_schema__update_experiment__exposed_to_mcp_as_patch(
api_client: APIClient,
) -> None:
# Given
path = "/api/v1/environments/{environment_api_key}/experiments/{experiment_id}/"

# When
response = api_client.get("/api/v1/swagger.json", HTTP_ACCEPT="application/json")

# Then
assert response.status_code == status.HTTP_200_OK
operations = response.json()["paths"][path]
assert operations["patch"]["operationId"] == "update_experiment"
assert operations["patch"]["tags"] == ["mcp"]
assert "mcp" not in operations["put"]["tags"]


@pytest.mark.parametrize(
"from_status, action_name, expected_status_code",
[
Expand Down
95 changes: 90 additions & 5 deletions mcp/src/flagsmith_mcp/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
"mcp"
]
},
"put": {
"patch": {
"operationId": "update_experiment",
"description": "(Beta) Updates an experiment's name or its hypothesis.",
"parameters": [
Expand All @@ -572,21 +572,20 @@
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Experiment"
"$ref": "#/components/schemas/PatchedExperiment"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/Experiment"
"$ref": "#/components/schemas/PatchedExperiment"
}
},
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Experiment"
"$ref": "#/components/schemas/PatchedExperiment"
}
}
}
Expand Down Expand Up @@ -6750,6 +6749,92 @@
"results"
]
},
"PatchedExperiment": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"readOnly": true
},
"feature": {
"type": "integer"
},
"name": {
"type": "string",
"maxLength": 255
},
"hypothesis": {
"type": "string"
},
"status": {
"allOf": [
{
"$ref": "#/components/schemas/Status7a8Enum"
}
],
"readOnly": true
},
"metrics": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ExperimentMetricInline"
},
"writeOnly": true
},
"experiment_rollout": {
"allOf": [
{
"$ref": "#/components/schemas/ExperimentRollout"
}
],
"writeOnly": true
},
"created_at": {
"type": "string",
"format": "date-time",
"readOnly": true
},
"updated_at": {
"type": "string",
"format": "date-time",
"readOnly": true
},
"started_at": {
"type": [
"string",
"null"
],
"format": "date-time",
"readOnly": true
},
"ended_at": {
"type": [
"string",
"null"
],
"format": "date-time",
"readOnly": true
},
"rollout_decision": {
"oneOf": [
{
"$ref": "#/components/schemas/RolloutDecisionEnum"
},
{
"$ref": "#/components/schemas/NullEnum"
}
],
"readOnly": true
},
"rollout_variant": {
"type": [
"integer",
"null"
],
"readOnly": true
}
}
},
"PaymentMethodEnum": {
"description": "* `CHARGEBEE` - Chargebee\n* `XERO` - Xero\n* `AWS_MARKETPLACE` - AWS Marketplace",
"type": "string",
Expand Down
12 changes: 6 additions & 6 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3622,8 +3622,8 @@ paths:
tags:
- mcp
put:
operationId: update_experiment
description: (Beta) Updates an experiment's name or its hypothesis.
operationId: api_v1_environments_experiments_update
description: Manage experiments for an environment.
parameters:
- name: environment_api_key
in: path
Expand Down Expand Up @@ -3659,10 +3659,10 @@ paths:
- tokenAuth: []
- Master API Key: []
tags:
- mcp
- Environments
patch:
operationId: api_v1_environments_experiments_partial_update
description: Manage experiments for an environment.
operationId: update_experiment
description: (Beta) Updates an experiment's name or its hypothesis.
parameters:
- name: environment_api_key
in: path
Expand Down Expand Up @@ -3697,7 +3697,7 @@ paths:
- tokenAuth: []
- Master API Key: []
tags:
- Environments
- mcp
delete:
operationId: api_v1_environments_experiments_destroy
description: Manage experiments for an environment.
Expand Down
Loading