Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
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
13 changes: 13 additions & 0 deletions 13 openapi_codec/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _get_paths_object(document):
def _get_operation(operation_id, link, tags):
encoding = get_encoding(link)
description = link.description.strip()
custom_attributes = getattr(link, 'custom_attributes', None)
summary = description.splitlines()[0] if description else None

operation = {
Expand All @@ -95,6 +96,9 @@ def _get_operation(operation_id, link, tags):
operation['consumes'] = [encoding]
if tags:
operation['tags'] = tags
if custom_attributes:
for key in custom_attributes:
operation[key] = custom_attributes[key]
return operation


Expand Down Expand Up @@ -127,6 +131,10 @@ def _get_field_type(field):
}.get(field.schema.__class__, 'string')


def _get_field_custom_attributes(field):
return getattr(field, 'custom_attributes', None)


def _get_parameters(link, encoding):
"""
Generates Swagger Parameter Item object.
Expand All @@ -139,6 +147,7 @@ def _get_parameters(link, encoding):
location = get_location(link, field)
field_description = _get_field_description(field)
field_type = _get_field_type(field)
field_custom_attributes = _get_field_custom_attributes(field)
if location == 'form':
if encoding in ('multipart/form-data', 'application/x-www-form-urlencoded'):
# 'formData' in swagger MUST be one of these media types.
Expand Down Expand Up @@ -189,6 +198,10 @@ def _get_parameters(link, encoding):
}
if field_type == 'array':
parameter['items'] = {'type': 'string'}
if field_custom_attributes:
# custom attributes can only be set when location is not body
for key in field_custom_attributes:
parameter[key] = field_custom_attributes[key]
parameters.append(parameter)

if properties:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.