Fix API returning snake_case
parent
067c287fc4
commit
708aafed9e
|
@ -2,7 +2,6 @@ import datetime
|
||||||
import time
|
import time
|
||||||
from typing import List
|
from typing import List
|
||||||
from flask import Blueprint, abort, jsonify, make_response, request
|
from flask import Blueprint, abort, jsonify, make_response, request
|
||||||
import pydantic
|
|
||||||
from pydantic.v1 import validator
|
from pydantic.v1 import validator
|
||||||
from spectree import Response
|
from spectree import Response
|
||||||
from sqlalchemy.orm import joinedload, subqueryload
|
from sqlalchemy.orm import joinedload, subqueryload
|
||||||
|
@ -85,7 +84,7 @@ def create_team(json: CreateTeamJson, player: Player, **kwargs):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
response = ViewTeamResponse(team=map_team_to_schema(team))
|
response = ViewTeamResponse(team=map_team_to_schema(team))
|
||||||
return jsonify(response.dict())
|
return jsonify(response.dict(by_alias=True))
|
||||||
|
|
||||||
@api_team.delete("/id/<team_id>/")
|
@api_team.delete("/id/<team_id>/")
|
||||||
@spec.validate(
|
@spec.validate(
|
||||||
|
@ -185,7 +184,7 @@ def view_teams(**kwargs):
|
||||||
player: Player = kwargs["player"]
|
player: Player = kwargs["player"]
|
||||||
response = fetch_teams_for_player(player, None)
|
response = fetch_teams_for_player(player, None)
|
||||||
if isinstance(response, ViewTeamsResponse):
|
if isinstance(response, ViewTeamsResponse):
|
||||||
return jsonify(response.dict())
|
return jsonify(response.dict(by_alias=True))
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
@api_team.get("/id/<team_id>/")
|
@api_team.get("/id/<team_id>/")
|
||||||
|
@ -202,7 +201,7 @@ def view_team(team_id: int, **kwargs):
|
||||||
player: Player = kwargs["player"]
|
player: Player = kwargs["player"]
|
||||||
response = fetch_teams_for_player(player, team_id)
|
response = fetch_teams_for_player(player, team_id)
|
||||||
if isinstance(response, ViewTeamResponse):
|
if isinstance(response, ViewTeamResponse):
|
||||||
return jsonify(response.dict())
|
return jsonify(response.dict(by_alias=True))
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
def fetch_teams_for_player(player: Player, team_id: int | None):
|
def fetch_teams_for_player(player: Player, team_id: int | None):
|
||||||
|
@ -295,6 +294,6 @@ def view_team_members(player: Player, team_id: int, **kwargs):
|
||||||
availability=availability,
|
availability=availability,
|
||||||
playtime=player_team.playtime.total_seconds() / 3600,
|
playtime=player_team.playtime.total_seconds() / 3600,
|
||||||
created_at=player_team.created_at,
|
created_at=player_team.created_at,
|
||||||
)
|
).dict(by_alias=True)
|
||||||
|
|
||||||
return list(map(map_to_response, player_teams))
|
return list(map(map_to_response, player_teams))
|
||||||
|
|
Loading…
Reference in New Issue