From 9327e301a6821724bc1c6d825f4e8167333b603e Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE Date: Sun, 10 Sep 2023 11:44:49 +0200 Subject: [PATCH] refactor(api): correct Query parameter specification in API endpoints --- antarest/eventbus/web.py | 2 +- antarest/launcher/web.py | 18 +--------------- antarest/study/web/study_data_blueprint.py | 25 +++------------------- 3 files changed, 5 insertions(+), 40 deletions(-) diff --git a/antarest/eventbus/web.py b/antarest/eventbus/web.py index cae0ffb99f..d7675b20ec 100644 --- a/antarest/eventbus/web.py +++ b/antarest/eventbus/web.py @@ -91,7 +91,7 @@ async def send_event_to_ws(event: Event) -> None: @application.websocket("/ws") async def connect( websocket: WebSocket, - token: str = Query(...), + token: str = Query(), jwt_manager: AuthJWT = Depends(), ) -> None: user: Optional[JWTUser] = None diff --git a/antarest/launcher/web.py b/antarest/launcher/web.py index ffb4cf6ccf..d63d274c30 100644 --- a/antarest/launcher/web.py +++ b/antarest/launcher/web.py @@ -201,23 +201,7 @@ def get_load( response_model=List[str], ) def get_solver_versions( - solver: str = Query( - "default", - examples={ - "Default solver": { - "description": "Get the solver versions of the default configuration", - "value": "default", - }, - "SLURM solver": { - "description": "Get the solver versions of the SLURM server if available", - "value": "slurm", - }, - "Local solver": { - "description": "Get the solver versions of the Local server if available", - "value": "local", - }, - }, - ) + solver: str = Query("default", examples=["default", "slurm", "local"]), ) -> List[str]: """ Get list of supported solver versions defined in the configuration. diff --git a/antarest/study/web/study_data_blueprint.py b/antarest/study/web/study_data_blueprint.py index 931816391a..93f6983b00 100644 --- a/antarest/study/web/study_data_blueprint.py +++ b/antarest/study/web/study_data_blueprint.py @@ -1018,23 +1018,7 @@ def set_allocation_form_fields( ) def get_correlation_matrix( uuid: str, - columns: Optional[str] = Query( - None, - examples={ - "all areas": { - "description": "get the correlation matrix for all areas (by default)", - "value": "", - }, - "single area": { - "description": "get the correlation column for a single area", - "value": "north", - }, - "selected areas": { - "description": "get the correlation columns for a selected list of areas", - "value": "north,east", - }, - }, - ), # type: ignore + columns: str = Query("", examples=["", "north", "north,east"]), current_user: JWTUser = Depends(auth.get_current_user), ) -> CorrelationMatrix: """ @@ -1059,11 +1043,8 @@ def get_correlation_matrix( study_service.get_all_areas(uuid, area_type=AreaType.AREA, ui=False, params=params), ) manager = CorrelationManager(study_service.storage_service) - return manager.get_correlation_matrix( - all_areas, - study, - columns.split(",") if columns else [], - ) + cols = columns.split(",") if columns else [] + return manager.get_correlation_matrix(all_areas, study, cols) @bp.put( path="/studies/{uuid}/areas/hydro/correlation/matrix",