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

Path Args Components Unable To Be Rendered #223

Open
Noupin opened this issue Jul 12, 2021 · 0 comments
Open

Path Args Components Unable To Be Rendered #223

Noupin opened this issue Jul 12, 2021 · 0 comments

Comments

@Noupin
Copy link

Noupin commented Jul 12, 2021

With OpenAPI 3 and up the path arguments have to be inside a schema to be recognized. In paths.py argument_to_param the 'type', 'format', and 'default' are all just put in the param dictionary to fix this the spec version could be passed to argument_to_param and if it is >= 3 then put the previously mentioned values inside a schema dictionary inside of params. I'm sure there is a better fix but something like this would suffice:

def argument_to_param(argument, rule, spec_version, override=None):
    param = {
        'in': 'path',
        'name': argument,
        'required': True,
    }
    type_, format_ = CONVERTER_MAPPING.get(type(rule._converters[argument]), DEFAULT_TYPE)
    if spec_version < 3:
        param['type'] = type_
        if format_ is not None:
            param['format'] = format_
        if rule.defaults and argument in rule.defaults:
            param['default'] = rule.defaults[argument]
    else:
        param['schema'] = {}
        param['schema']['type'] = type_
        if format_ is not None:
            param['schema']['format'] = format_
        if rule.defaults and argument in rule.defaults:
            param['schema']['default'] = rule.defaults[argument]
    param.update(override or {})
    return param
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant