Skip to content

type = param['schema']['type'] breaks in newer spec #113

@havok4u

Description

@havok4u

PROBLEM:
In the newest spec and pydantic capability you can give multiple types for validation. When I do a make html this breaks as there is not type key under param['schema']. Rather you now have anyof as a key and a list of types of which a type might have a format as an alternative.
In file sphinxcontrib/openapi/openapi30.py, starting on line 270

for param in filter(lambda p: p['in'] == 'path', parameters):
        yield indent + ':param {type} {name}:'.format(
           type=param['schema']['type'],
           name=param['name'])

This can be changed to the following to fix:

for param in filter(lambda p: p['in'] == 'path', parameters):
        if 'type' in param['schema'].keys():
            dtype = param['schema']['type']
        else:
            dtype = set()
            for t in param['schema']['anyOf']:
                if 'format' in t.keys():
                    dtype.add(t['format'])
                else:
                    dtype.add( t['type'])
        yield indent + ':param {type} {name}:'.format(
           type = dtype,
           name=param['name'])

This then gives an output of
Parameters componentid ({'uuid', 'integer', 'string'}) –

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions