mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 17:51:06 -03:30
Merge pull request #1141 from ryanpetrello/swagger
a bit of extra Swagger doc tinkering
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from awx.api.swagger import SwaggerSchemaView
|
||||
|
||||
from awx.api.views import (
|
||||
ApiRootView,
|
||||
@@ -128,6 +127,7 @@ urlpatterns = [
|
||||
url(r'^(?P<version>(v1|v2))/', include(v1_urls)),
|
||||
]
|
||||
if settings.SETTINGS_MODULE == 'awx.settings.development':
|
||||
from awx.api.swagger import SwaggerSchemaView
|
||||
urlpatterns += [
|
||||
url(r'^swagger/$', SwaggerSchemaView.as_view(), name='swagger_view'),
|
||||
]
|
||||
|
||||
@@ -152,7 +152,10 @@ class TestSwaggerGeneration():
|
||||
content_type, resp, request_data = value
|
||||
if method in node:
|
||||
status_code = str(status_code)
|
||||
node[method].setdefault('produces', []).append(content_type)
|
||||
if content_type:
|
||||
produces = node[method].setdefault('produces', [])
|
||||
if content_type not in produces:
|
||||
produces.append(content_type)
|
||||
if request_data and status_code.startswith('2'):
|
||||
# DRF builds a schema based on the serializer
|
||||
# fields. This is _pretty good_, but if we
|
||||
@@ -181,5 +184,5 @@ class TestSwaggerGeneration():
|
||||
def teardown_class(cls):
|
||||
with open('swagger.json', 'w') as f:
|
||||
f.write(force_bytes(
|
||||
json.dumps(cls.JSON, cls=i18nEncoder, indent=5)
|
||||
json.dumps(cls.JSON, cls=i18nEncoder)
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user