Generate link to response schema, #42.
This commit is contained in:
parent
4361a5760c
commit
060b3283b6
|
@ -45,13 +45,16 @@ TMPL_API = """
|
|||
{% if request['examples']['text/plain'] %}
|
||||
:requestexample: {{version}}/examples/{{request['operationId']}}_req.txt
|
||||
{%- endif -%}
|
||||
{% for status_code, response in request.responses.items() -%}
|
||||
{% for status_code, response in request.responses.items() %}
|
||||
{%- if response['examples']['application/json'] %}
|
||||
:responseexample {{status_code}}: {{version}}/examples/{{request['operationId']}}_resp_{{status_code}}.json
|
||||
{%- endif -%}
|
||||
{%- if response['examples']['text/plain'] %}
|
||||
:responseexample {{status_code}}: {{version}}/examples/{{request['operationId']}}_resp_{{status_code}}.txt
|
||||
{%- endif -%}
|
||||
{%- if response['schema']['$ref'] %}
|
||||
:responseschema {{status_code}}: {{version}}/{{response['schema']['$ref'].rsplit('/', 1)[1]}}.json
|
||||
{%- endif -%}
|
||||
{% endfor -%}
|
||||
{% for mime in request.consumes %}
|
||||
:accepts: {{mime}}
|
||||
|
|
|
@ -827,6 +827,9 @@ class WADLHandler(xml.sax.ContentHandler):
|
|||
'properties': {}}
|
||||
schema_properties = self.schemas[schema_name]['properties']
|
||||
schema_properties[parameter['name']] = parameter
|
||||
response = self.current_api['responses'][status_code]
|
||||
response['schema']['$ref'] = "#/definitions/%s" % \
|
||||
schema_name
|
||||
del parameter['name']
|
||||
del parameter['in']
|
||||
elif parameter['in'] == 'header':
|
||||
|
|
|
@ -481,6 +481,13 @@ class JSONTranslator(nodes.GenericNodeVisitor):
|
|||
'in': 'body',
|
||||
'required': True,
|
||||
'schema': {'$ref': filepath}})
|
||||
elif name == 'responseschema':
|
||||
responses = resource['responses']
|
||||
status_code = node[0].astext()
|
||||
filepath = node[1].astext()
|
||||
if 'schema' not in responses[status_code]:
|
||||
responses[status_code]['schema'] = {}
|
||||
responses[status_code]['schema'] = {'$ref': filepath}
|
||||
elif name == 'parameter':
|
||||
param_name = node[0].astext()
|
||||
description = node[1].astext()
|
||||
|
@ -718,6 +725,9 @@ class Resource(Directive):
|
|||
GroupedField('statuscode', label='Status Codes',
|
||||
rolename='statuscode',
|
||||
names=('statuscode', 'status', 'code')),
|
||||
GroupedField('responseschema', label='Response Schema',
|
||||
rolename='responseschema',
|
||||
names=('reponse-schema', 'responseschema')),
|
||||
|
||||
# Swagger Extensions
|
||||
GroupedField('responseexample', label='Response Example',
|
||||
|
|
|
@ -525,6 +525,15 @@ class TestWADLHandler(unittest.TestCase):
|
|||
</request>
|
||||
<response status="202">
|
||||
<representation mediaType="application/json">
|
||||
<param name="thing-a-imagig-response" style="plain"
|
||||
type="xsd:string" required="true">
|
||||
<wadl:doc>
|
||||
<para>
|
||||
Specify the <code>interfaceAttachment</code>
|
||||
action in the request body.
|
||||
</para>
|
||||
</wadl:doc>
|
||||
</param>
|
||||
</representation>
|
||||
</response>
|
||||
</method>
|
||||
|
@ -552,7 +561,8 @@ class TestWADLHandler(unittest.TestCase):
|
|||
'produces': [],
|
||||
'responses': {'202': {'examples': {},
|
||||
'headers': {},
|
||||
'schema': {},
|
||||
'schema': {
|
||||
'$ref': '#/definitions/createThing_202'},
|
||||
'description': ''}},
|
||||
'summary': 'Creates and uses a port interface '
|
||||
'to attach the port to a server instance.',
|
||||
|
@ -570,4 +580,15 @@ class TestWADLHandler(unittest.TestCase):
|
|||
'format': '',
|
||||
'required': True,
|
||||
'type': 'string'}},
|
||||
'type': 'object'}})
|
||||
'type': 'object'},
|
||||
'createThing_202':
|
||||
{'properties':
|
||||
{'thing-a-imagig-response':
|
||||
{'description':
|
||||
'Specify the ``interfaceAttachment``'
|
||||
' action in the request body.',
|
||||
'format': '',
|
||||
'required': True,
|
||||
'type': 'string'}},
|
||||
'type': 'object'}}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue