Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 'choices' in add_argument leads to invalid swagger schema #164

Closed
leopold-p opened this issue Jun 26, 2020 · 0 comments
Closed

Using 'choices' in add_argument leads to invalid swagger schema #164

leopold-p opened this issue Jun 26, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@leopold-p
Copy link

I seems the issue is inherited from flask-restplus
noirbizarre/flask-restplus#488

Code

In Argument from regparse.py:

    @property
    def __schema__(self):
        if self.location == 'cookie':
            return
        param = {
            'name': self.name,
            'in': LOCATIONS.get(self.location, 'query')
        }
        _handle_arg_type(self, param)
        if self.required:
            param['required'] = True
        if self.help:
            param['description'] = self.help
        if self.default is not None:
            param['default'] = self.default() if callable(self.default) else self.default
        if self.action == 'append':
            param['items'] = {'type': param['type']}
            param['type'] = 'array'
            param['collectionFormat'] = 'multi'
        if self.action == 'split':
            param['items'] = {'type': param['type']}
            param['type'] = 'array'
            param['collectionFormat'] = 'csv'
        if self.choices:
            param['enum'] = self.choices
            param['collectionFormat'] = 'multi'
        return param

An argument with choices must not generate a collectionFormat field

@leopold-p leopold-p added the bug Something isn't working label Jun 26, 2020
ziirish added a commit that referenced this issue Jul 15, 2020
Fix Issue #164: generate choices schema without collectionFormat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant