move swagger doc metadata out of the awx repo

This commit is contained in:
Ryan Petrello
2018-02-09 09:18:33 -05:00
parent 6cb6c61e5c
commit fe02abe630
3 changed files with 0 additions and 72 deletions

View File

@@ -1,6 +1,4 @@
import json
import yaml
import os
import re
from django.conf import settings
@@ -12,18 +10,9 @@ from coreapi.compat import force_bytes
from openapi_codec.encode import generate_swagger_object
import pytest
import awx
from awx.api.versioning import drf_reverse
config_dest = os.sep.join([
os.path.realpath(os.path.dirname(awx.__file__)),
'api', 'templates', 'swagger'
])
config_file = os.sep.join([config_dest, 'config.yml'])
description_file = os.sep.join([config_dest, 'description.md'])
class i18nEncoder(DjangoJSONEncoder):
def default(self, obj):
if isinstance(obj, Promise):
@@ -62,21 +51,6 @@ class TestSwaggerGeneration():
data['schemes'] = ['https']
data['consumes'] = ['application/json']
# Inject a top-level description into the OpenAPI document
if os.path.exists(description_file):
with open(description_file, 'r') as f:
data['info']['description'] = f.read()
# Write tags in the order we want them sorted
if os.path.exists(config_file):
with open(config_file, 'r') as f:
config = yaml.load(f.read())
for category in config.get('categories', []):
tag = {'name': category['name']}
if 'description' in category:
tag['description'] = category['description']
data.setdefault('tags', []).append(tag)
revised_paths = {}
deprecated_paths = data.pop('deprecated_paths', [])
for path, node in data['paths'].items():
@@ -108,7 +82,6 @@ class TestSwaggerGeneration():
# Make some basic assertions about the rendered JSON so we can
# be sure it doesn't break across DRF upgrades and view/serializer
# changes.
assert len(JSON['tags'])
assert len(JSON['paths'])
# The number of API endpoints changes over time, but let's just check