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

Show description for arrays of string, number, integer or boolean #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions sphinxcontrib/openapi/openapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ def _convert(schema, name='', required=False):
(prop in required_properties))

elif type_ == 'array':
_convert(schema['items'], name + '[]')
name = name.lstrip('.')
description = schema.get('description', '')
output.append((
name,
'{type_} {name}:'
' {description}'.format(**locals())))
if schema['items'].get('type', 'any') not in ['string', 'number', 'integer', 'boolean']:
_convert(schema['items'], name + '[]')

else:
if name:
Expand Down Expand Up @@ -227,7 +234,7 @@ def openapihttpdomain(spec, **options):
if 'group' in options:
groups = collections.OrderedDict(
[(x['name'], []) for x in spec.get('tags', {})]
)
)

for endpoint in paths:
for method, properties in spec['paths'][endpoint].items():
Expand All @@ -239,7 +246,7 @@ def openapihttpdomain(spec, **options):
method,
properties,
utils.get_text_converter(options),
))
))

for key in groups.keys():
if key:
Expand All @@ -258,6 +265,6 @@ def openapihttpdomain(spec, **options):
method,
properties,
utils.get_text_converter(options),
))
))

return iter(itertools.chain(*generators))