0

I'm documenting my REST endpoints with Flask-restx (Python 2.7) and the parameters to the endpoints get really strange sorting in Swagger. Right now the required parameters are not always first in the list.

Output in Swagger

It seems to be a way to sort the parameters in some way with "sortParamsByRequiredFlag", but I don't see where I can set it. Anyone knows?

My code for one of the endpoints:

@g_api.route('/apx_export', methods=['GET'])
@g_api.doc(params={
    'date_time_start': {
        'required': True,
        'type': 'string',
        'format': 'YYYY-MM-DD',
        'description': 'Start date'},
    'date_time_end': {
        'required': False,
        'type': 'string',
        'format': 'YYYY-MM-DD',
        'description': 'End date'},
    'portfolio': {
        'required': False,
        'type': 'string',
        'description': 'The apx id of the account or portfolio to be filtered on'}, })
class ApxExport(Resource):
    def get(self):
        date_time_start = _unicode_to_latin1(flask.request.args.get(key='date_time_start', default=None, type=str))
        date_time_end = _unicode_to_latin1(flask.request.args.get('date_time_end', None))
        apx_portfolio = _unicode_to_latin1(flask.request.args.get('portfolio', None))

        if date_time_start is None:
            def apx_error_binder():
                raise ServerError('apx_export: date_time_start is unassigned', status_code=400, include_traceback=False)

            return QueuedCall.redirect(apx_error_binder)

        def apx_export_binder():
            return ipm.ats.apx_export.apx_export(date_time_start, date_time_end, apx_portfolio)

        return QueuedCall.redirect(apx_export_binder)

The output in Swagger is in this order:

date_time_end, string($YYYY-MM-DD), (query), End date

portfolio, string, (query), The apx id of the account or portfolio to be filtered on

date_time_start *, string($YYYY-MM-DD), (query),Start date

0 Answers0