Skip to content

Commit

Permalink
Make payload optional again for create tag API
Browse files Browse the repository at this point in the history
Before #17064 it was
possible to create a tag by simply making a POST request like
`/api/histories/911dde3ddb677bcd/tags/tag1` , this restores the
previous behaviour.

Fix BioBlend test failure:

https://github.com/galaxyproject/bioblend/actions/runs/7094150509/job/19308900670#step:10:3029
  • Loading branch information
nsoranzo committed Dec 7, 2023
1 parent 295934b commit 71be487
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6392,7 +6392,7 @@ export interface components {
*/
ItemTagsCreatePayload: {
/** value of the item tag */
value: string;
value?: string;
};
/**
* ItemTagsListResponse
Expand Down Expand Up @@ -13796,7 +13796,7 @@ export interface operations {
history_id: string;
};
};
requestBody: {
requestBody?: {
content: {
"application/json": components["schemas"]["ItemTagsCreatePayload"];
};
Expand Down Expand Up @@ -15103,7 +15103,7 @@ export interface operations {
tag_name: string;
};
};
requestBody: {
requestBody?: {
content: {
"application/json": components["schemas"]["ItemTagsCreatePayload"];
};
Expand Down Expand Up @@ -19862,7 +19862,7 @@ export interface operations {
tag_name: string;
};
};
requestBody: {
requestBody?: {
content: {
"application/json": components["schemas"]["ItemTagsCreatePayload"];
};
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/schema/item_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ItemTagsListResponse(Model):
class ItemTagsCreatePayload(Model):
"""Payload schema for creating an item tag."""

value: str = Field(
Required,
value: Optional[str] = Field(
None,
title="value of the item tag",
)
4 changes: 3 additions & 1 deletion lib/galaxy/webapps/galaxy/api/item_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def create(
trans: ProvidesAppContext = DependsOnTrans,
item_id: DecodedDatabaseIdField = Path(..., title="Item ID", alias=tagged_item_id),
tag_name: str = Path(..., title="Tag Name"),
payload: ItemTagsCreatePayload = Body(...),
payload: ItemTagsCreatePayload = Body(None),
) -> ItemTagsResponse:
if payload is None:
payload = ItemTagsCreatePayload()
return self.manager.create(trans, tagged_item_class, item_id, tag_name, payload)

@router.put(
Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy_test/api/test_item_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from typing import (
Any,
Dict,
)

from galaxy_test.base.populators import (
DatasetCollectionPopulator,
DatasetPopulator,
Expand Down Expand Up @@ -125,7 +130,7 @@ def _test_delete_tag(self, prefix):

def _create_valid_tag(self, prefix: str):
url = f"{prefix}/tags/awesometagname"
tag_data = dict(value="awesometagvalue")
tag_data: Dict[str, Any] = {} # Can also be dict(value="awesometagvalue")
response = self._post(url, data=tag_data, json=True)
return response

Expand Down

0 comments on commit 71be487

Please sign in to comment.