Skip to content

Commit

Permalink
Merge pull request #15189 from mvdbeek/openapi_python_client
Browse files Browse the repository at this point in the history
Tweak OpenAPI schema
  • Loading branch information
jmchilton authored Dec 14, 2022
2 parents 35bf24a + 22962f4 commit 0d76b26
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 102 deletions.
13 changes: 0 additions & 13 deletions .redocly.lint-ignore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
_schema.yaml:
no-empty-servers:
- '#/openapi'
no-identical-paths:
- '#/paths/~1api~1groups~1{group_id}~1roles~1{role_id}'
- '#/paths/~1api~1groups~1{group_id}~1user~1{user_id}'
- '#/paths/~1api~1groups~1{group_id}~1users~1{user_id}'
no-ambiguous-paths:
- '#/paths/~1api~1groups~1{group_id}~1roles~1{role_id}'
- '#/paths/~1api~1groups~1{group_id}~1user~1{user_id}'
- '#/paths/~1api~1groups~1{group_id}~1users~1{user_id}'
- '#/paths/~1api~1histories~1{history_id}~1contents~1archive~1{id}'
- >-
#/paths/~1api~1histories~1{history_id}~1contents~1{dataset_id}~1permissions
- >-
Expand All @@ -22,8 +14,3 @@ _schema.yaml:
#/paths/~1api~1histories~1{history_id}~1contents~1{history_content_id}~1metadata_file
- '#/paths/~1api~1histories~1{history_id}~1contents~1{id}~1validate'
- '#/paths/~1api~1histories~1{history_id}~1contents~1{type}s~1{id}'
path-parameters-defined:
- >-
#/paths/~1api~1dataset_collections~1{id}~1prepare_download/post/parameters/0/name
- >-
#/paths/~1api~1histories~1{history_id}~1contents~1archive~1{id}/get/parameters
93 changes: 19 additions & 74 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,20 @@ export interface paths {
/** Displays a collection (list) of groups. */
get: operations["index_api_groups__group_id__roles_get"];
};
"/api/groups/{group_id}/roles/{id}": {
/** Displays information about a group role. */
get: operations["group_role_api_groups__group_id__roles__id__get"];
};
"/api/groups/{group_id}/roles/{role_id}": {
/** Displays information about a group role. */
get: operations["group_role_api_groups__group_id__roles__role_id__get"];
/** Adds a role to a group */
put: operations["update_api_groups__group_id__roles__role_id__put"];
/** Removes a role from a group */
delete: operations["delete_api_groups__group_id__roles__role_id__delete"];
};
"/api/groups/{group_id}/user/{id}": {
"/api/groups/{group_id}/user/{user_id}": {
/**
* Displays information about a group user.
* @description GET /api/groups/{encoded_group_id}/users/{encoded_user_id}
* Displays information about a group user.
* @description Displays information about a group user.
*/
get: operations["group_user_api_groups__group_id__user__id__get"];
};
"/api/groups/{group_id}/user/{user_id}": {
get: operations["group_user_api_groups__group_id__user__user_id__get"];
/**
* Adds a user to a group
* @description PUT /api/groups/{encoded_group_id}/users/{encoded_user_id}
Expand All @@ -359,15 +354,12 @@ export interface paths {
*/
get: operations["index_api_groups__group_id__users_get"];
};
"/api/groups/{group_id}/users/{id}": {
"/api/groups/{group_id}/users/{user_id}": {
/**
* Displays information about a group user.
* @description GET /api/groups/{encoded_group_id}/users/{encoded_user_id}
* Displays information about a group user.
* @description Displays information about a group user.
*/
get: operations["group_user_api_groups__group_id__users__id__get"];
};
"/api/groups/{group_id}/users/{user_id}": {
get: operations["group_user_api_groups__group_id__users__user_id__get"];
/**
* Adds a user to a group
* @description PUT /api/groups/{encoded_group_id}/users/{encoded_user_id}
Expand Down Expand Up @@ -491,15 +483,6 @@ export interface paths {
*/
get: operations["download_dataset_collection_api_histories__history_id__contents_dataset_collections__id__download_get"];
};
"/api/histories/{history_id}/contents/dataset_collections/{id}/prepare_download": {
/**
* Prepare an short term storage object that the collection will be downloaded to.
* @description The history dataset collection will be written as a `zip` archive to the
* returned short term storage object. Progress tracking this file's creation
* can be tracked with the short_term_storage API.
*/
post: operations["prepare_collection_download_api_histories__history_id__contents_dataset_collections__id__prepare_download_post"];
};
"/api/histories/{history_id}/contents/datasets/{id}/materialize": {
/** Materialize a deferred dataset into real, usable dataset. */
post: operations["materialize_dataset_api_histories__history_id__contents_datasets__id__materialize_post"];
Expand Down Expand Up @@ -7831,15 +7814,13 @@ export interface operations {
header?: {
"run-as"?: string;
};
/** @description The ID of the History. */
/** @description The ID of the `HDCA` contained in the history. */
path: {
history_id: string;
id: string;
};
};
responses: {
/** @description Successful Response */
/** @description Short term storage reference for async monitoring of this download. */
200: {
content: {
"application/json": components["schemas"]["AsyncFile"];
Expand All @@ -7851,6 +7832,8 @@ export interface operations {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
/** @description Required asynchronous tasks required for this operation not available. */
501: never;
};
};
suitable_converters_api_dataset_collections__id__suitable_converters_get: {
Expand Down Expand Up @@ -9086,7 +9069,7 @@ export interface operations {
};
};
};
group_role_api_groups__group_id__roles__id__get: {
group_role_api_groups__group_id__roles__role_id__get: {
/** Displays information about a group role. */
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
Expand All @@ -9097,7 +9080,7 @@ export interface operations {
/** @description The ID of the role */
path: {
group_id: string;
id: string;
role_id: string;
};
};
responses: {
Expand Down Expand Up @@ -9173,11 +9156,10 @@ export interface operations {
};
};
};
group_user_api_groups__group_id__user__id__get: {
group_user_api_groups__group_id__user__user_id__get: {
/**
* Displays information about a group user.
* @description GET /api/groups/{encoded_group_id}/users/{encoded_user_id}
* Displays information about a group user.
* @description Displays information about a group user.
*/
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
Expand All @@ -9188,7 +9170,7 @@ export interface operations {
/** @description The ID of the user */
path: {
group_id: string;
id: string;
user_id: string;
};
};
responses: {
Expand Down Expand Up @@ -9303,11 +9285,10 @@ export interface operations {
};
};
};
group_user_api_groups__group_id__users__id__get: {
group_user_api_groups__group_id__users__user_id__get: {
/**
* Displays information about a group user.
* @description GET /api/groups/{encoded_group_id}/users/{encoded_user_id}
* Displays information about a group user.
* @description Displays information about a group user.
*/
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
Expand All @@ -9318,7 +9299,7 @@ export interface operations {
/** @description The ID of the user */
path: {
group_id: string;
id: string;
user_id: string;
};
};
responses: {
Expand Down Expand Up @@ -10329,42 +10310,6 @@ export interface operations {
};
};
};
prepare_collection_download_api_histories__history_id__contents_dataset_collections__id__prepare_download_post: {
/**
* Prepare an short term storage object that the collection will be downloaded to.
* @description The history dataset collection will be written as a `zip` archive to the
* returned short term storage object. Progress tracking this file's creation
* can be tracked with the short_term_storage API.
*/
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string;
};
/** @description The ID of the History. */
/** @description The ID of the `HDCA` contained in the history. */
path: {
history_id: string;
id: string;
};
};
responses: {
/** @description Short term storage reference for async monitoring of this download. */
200: {
content: {
"application/json": components["schemas"]["AsyncFile"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
/** @description Required asynchronous tasks required for this operation not available. */
501: never;
};
};
materialize_dataset_api_histories__history_id__contents_datasets__id__materialize_post: {
/** Materialize a deferred dataset into real, usable dataset. */
parameters: {
Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy/webapps/galaxy/api/group_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
def group_role_to_model(trans, group_id: int, role) -> GroupRoleModel:
encoded_group_id = DecodedDatabaseIdField.encode(group_id)
encoded_role_id = DecodedDatabaseIdField.encode(role.id)
url = trans.url_builder("group_role", group_id=encoded_group_id, id=encoded_role_id)
url = trans.url_builder("group_role", group_id=encoded_group_id, role_id=encoded_role_id)
return GroupRoleModel.construct(id=encoded_role_id, name=role.name, url=url)


Expand All @@ -49,7 +49,7 @@ def index(
)

@router.get(
"/api/groups/{group_id}/roles/{id}",
"/api/groups/{group_id}/roles/{role_id}",
name="group_role",
require_admin=True,
summary="Displays information about a group role.",
Expand All @@ -58,9 +58,9 @@ def show(
self,
trans: ProvidesAppContext = DependsOnTrans,
group_id: DecodedDatabaseIdField = GroupIDParam,
id: DecodedDatabaseIdField = RoleIDParam,
role_id: DecodedDatabaseIdField = RoleIDParam,
) -> GroupRoleModel:
role = self.manager.show(trans, id, group_id)
role = self.manager.show(trans, role_id, group_id)
return group_role_to_model(trans, group_id, role)

@router.put("/api/groups/{group_id}/roles/{role_id}", require_admin=True, summary="Adds a role to a group")
Expand Down
9 changes: 4 additions & 5 deletions lib/galaxy/webapps/galaxy/api/group_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def index(
return GroupUserListModel(__root__=[group_user_to_model(trans, group_id, gr) for gr in group_users])

@router.get(
"/api/groups/{group_id}/user/{id}",
alias="/api/groups/{group_id}/users/{id}",
"/api/groups/{group_id}/user/{user_id}",
alias="/api/groups/{group_id}/users/{user_id}",
name="group_user",
require_admin=True,
summary="Displays information about a group user.",
Expand All @@ -60,13 +60,12 @@ def show(
self,
trans: ProvidesAppContext = DependsOnTrans,
group_id: DecodedDatabaseIdField = GroupIDParam,
id: DecodedDatabaseIdField = UserIDParam,
user_id: DecodedDatabaseIdField = UserIDParam,
) -> GroupUserModel:
"""
GET /api/groups/{encoded_group_id}/users/{encoded_user_id}
Displays information about a group user.
"""
user = self.manager.show(trans, id, group_id)
user = self.manager.show(trans, user_id, group_id)
return group_user_to_model(trans, group_id, user)

@router.put(
Expand Down
10 changes: 5 additions & 5 deletions lib/galaxy/webapps/galaxy/api/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,22 +511,22 @@ def download_dataset_collection(
@router.post(
"/api/histories/{history_id}/contents/dataset_collections/{id}/prepare_download",
summary="Prepare an short term storage object that the collection will be downloaded to.",
include_in_schema=False,
)
@router.post(
"/api/dataset_collections/{id}/prepare_download",
summary="Prepare an short term storage object that the collection will be downloaded to.",
responses={
200: {
"description": "Short term storage reference for async monitoring of this download.",
},
501: {"description": "Required asynchronous tasks required for this operation not available."},
},
)
@router.post(
"/api/dataset_collections/{id}/prepare_download",
summary="Prepare an short term storage object that the collection will be downloaded to.",
tags=["dataset collections"],
)
def prepare_collection_download(
self,
trans: ProvidesHistoryContext = DependsOnTrans,
history_id: DecodedDatabaseIdField = HistoryIDPathParam,
id: DecodedDatabaseIdField = HistoryHDCAIDPathParam,
) -> AsyncFile:
"""The history dataset collection will be written as a `zip` archive to the
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/openapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def generate_operation_summary(*, route: routing.APIRoute, method: str) -> str:
def get_openapi_operation_metadata(*, route: routing.APIRoute, method: str, operation_ids: Set[str]) -> Dict[str, Any]:
operation: Dict[str, Any] = {}
if route.tags:
operation["tags"] = route.tags
operation["tags"] = list(set(route.tags))
operation["summary"] = generate_operation_summary(route=route, method=method)
if route.description:
operation["description"] = route.description
Expand Down

0 comments on commit 0d76b26

Please sign in to comment.