-
Notifications
You must be signed in to change notification settings - Fork 342
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I am writing an endpoint where two params are part of the url
Code
schedule_api = Namespace(
"schedule",
description="API for all the League's Schedule queries"
)
schedule_payload = schedule_api.model('Schedule', {
'away_team': fields.String(
description="The name of the away team",
),
'away_team_id': fields.Integer(
description="The id of the away team",
),
'date': fields.Date(
description="The date of the game",
),
'field': fields.String(
description="The field of the game",
),
'home_team': fields.String(
description="The name of the home team",
),
'home_team_id': fields.Integer(
description="The id of the home team",
),
'league_id': fields.Integer(
description="The id of the league",
),
'score': fields.String(
description="The score of the game if played",
),
'status': fields.String(
description="The status of the game",
),
'time': fields.String(
description="The time of the game (Format: HH-MM)",
example="12:01"
),
})
pagination = get_pagination(schedule_api)
schedule_pagination = schedule_api.inherit("SchedulePagination", pagination, {
'items': fields.List(fields.Nested(schedule_payload))
})
@schedule_api.route("/<int:year>/<int:league_id>", endpoint="rest.schedule")
@schedule_api.doc(
params={"year": "The schedule year", "league_id": "The id of the league"}
)
class ScheduleAPIX(Resource):
@schedule_api.marshal_with(schedule_pagination, envelope='resource')
def get(self, year, league_id):
page = request.args.get('page', 1, type=int)
data = pull_schedule(year, league_id, page=page)
# running into issue where say this was needed in response
# just added them for now
data['year'] = year
data['league_id'] = league_id
return dataRepro Steps (if applicable)
- ...
- ...
- Broken!
Expected Behavior
Should be able to not include league_id and year in the response
Actual Behavior
[A description of the unexpected, buggy behavior.](root:errors_handler.py:86 Could not build url for endpoint 'rest.schedule' with values ['has_next', 'has_prev', 'items', 'pages', 'total']. Did you forget to specify values ['league_id', 'year']?)
Error Messages/Stack Trace
[A description of the unexpected, buggy behavior.](root:errors_handler.py:86 Could not build url for endpoint 'rest.schedule' with values ['has_next', 'has_prev', 'items', 'pages', 'total']. Did you forget to specify values ['league_id', 'year']?)
Environment
- Python version 3.10.12
- Flask version 2.2.3
- Flask-RESTX version 1.3.0
- Other installed Flask extensions
Additional Context
This is your last chance to provide any pertinent details, don't let this opportunity pass you by!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

