Skip to content

Commit

Permalink
refactor(api): correct Query parameter specification in API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro committed Oct 3, 2023
1 parent edc0d0c commit 9327e30
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
2 changes: 1 addition & 1 deletion antarest/eventbus/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 1 addition & 17 deletions antarest/launcher/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 3 additions & 22 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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",
Expand Down

0 comments on commit 9327e30

Please sign in to comment.