Proper flask_restful boolean parsing.

This is documented here: https://github.com/flask-restful/flask-restful/issues/488
This commit is contained in:
Mike Grima 2018-07-30 13:49:41 -07:00 committed by Curtis Castrapel
parent 82c7530b6f
commit 46cd1a21f7
3 changed files with 10 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import base64
from builtins import str from builtins import str
from flask import Blueprint, make_response, jsonify, g from flask import Blueprint, make_response, jsonify, g
from flask_restful import reqparse, Api from flask_restful import reqparse, Api, inputs
from lemur.common.schema import validate_schema from lemur.common.schema import validate_schema
from lemur.common.utils import paginated_parser from lemur.common.utils import paginated_parser
@ -132,9 +132,9 @@ class CertificatesList(AuthenticatedResource):
""" """
parser = paginated_parser.copy() parser = paginated_parser.copy()
parser.add_argument('timeRange', type=int, dest='time_range', location='args') parser.add_argument('timeRange', type=int, dest='time_range', location='args')
parser.add_argument('owner', type=bool, location='args') parser.add_argument('owner', type=inputs.boolean, location='args')
parser.add_argument('id', type=str, location='args') parser.add_argument('id', type=str, location='args')
parser.add_argument('active', type=bool, location='args') parser.add_argument('active', type=inputs.boolean, location='args')
parser.add_argument('destinationId', type=int, dest="destination_id", location='args') parser.add_argument('destinationId', type=int, dest="destination_id", location='args')
parser.add_argument('creator', type=str, location='args') parser.add_argument('creator', type=str, location='args')
parser.add_argument('show', type=str, location='args') parser.add_argument('show', type=str, location='args')
@ -756,9 +756,9 @@ class NotificationCertificatesList(AuthenticatedResource):
""" """
parser = paginated_parser.copy() parser = paginated_parser.copy()
parser.add_argument('timeRange', type=int, dest='time_range', location='args') parser.add_argument('timeRange', type=int, dest='time_range', location='args')
parser.add_argument('owner', type=bool, location='args') parser.add_argument('owner', type=inputs.boolean, location='args')
parser.add_argument('id', type=str, location='args') parser.add_argument('id', type=str, location='args')
parser.add_argument('active', type=bool, location='args') parser.add_argument('active', type=inputs.boolean, location='args')
parser.add_argument('destinationId', type=int, dest="destination_id", location='args') parser.add_argument('destinationId', type=int, dest="destination_id", location='args')
parser.add_argument('creator', type=str, location='args') parser.add_argument('creator', type=str, location='args')
parser.add_argument('show', type=str, location='args') parser.add_argument('show', type=str, location='args')

View File

@ -7,7 +7,7 @@
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com> .. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
""" """
from flask import Blueprint from flask import Blueprint
from flask_restful import Api, reqparse from flask_restful import Api, reqparse, inputs
from lemur.notifications import service from lemur.notifications import service
from lemur.notifications.schemas import notification_input_schema, notification_output_schema, notifications_output_schema from lemur.notifications.schemas import notification_input_schema, notification_output_schema, notifications_output_schema
@ -103,7 +103,7 @@ class NotificationsList(AuthenticatedResource):
:statuscode 200: no error :statuscode 200: no error
""" """
parser = paginated_parser.copy() parser = paginated_parser.copy()
parser.add_argument('active', type=bool, location='args') parser.add_argument('active', type=inputs.boolean, location='args')
args = parser.parse_args() args = parser.parse_args()
return service.render(args) return service.render(args)

View File

@ -5,7 +5,7 @@
.. moduleauthor:: James Chuong <jchuong@instartlogic.com> .. moduleauthor:: James Chuong <jchuong@instartlogic.com>
""" """
from flask import Blueprint, g, make_response, jsonify from flask import Blueprint, g, make_response, jsonify
from flask_restful import Api, reqparse from flask_restful import Api, reqparse, inputs
from lemur.auth.service import AuthenticatedResource from lemur.auth.service import AuthenticatedResource
from lemur.auth.permissions import CertificatePermission from lemur.auth.permissions import CertificatePermission
@ -110,9 +110,9 @@ class PendingCertificatesList(AuthenticatedResource):
""" """
parser = paginated_parser.copy() parser = paginated_parser.copy()
parser.add_argument('timeRange', type=int, dest='time_range', location='args') parser.add_argument('timeRange', type=int, dest='time_range', location='args')
parser.add_argument('owner', type=bool, location='args') parser.add_argument('owner', type=inputs.boolean, location='args')
parser.add_argument('id', type=str, location='args') parser.add_argument('id', type=str, location='args')
parser.add_argument('active', type=bool, location='args') parser.add_argument('active', type=inputs.boolean, location='args')
parser.add_argument('destinationId', type=int, dest="destination_id", location='args') parser.add_argument('destinationId', type=int, dest="destination_id", location='args')
parser.add_argument('creator', type=str, location='args') parser.add_argument('creator', type=str, location='args')
parser.add_argument('show', type=str, location='args') parser.add_argument('show', type=str, location='args')