mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 07:56:06 -03:30
move swagger doc metadata out of the awx repo
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
# Add categories here for generated Swagger docs; order will be respected
|
|
||||||
# in the generated document.
|
|
||||||
categories:
|
|
||||||
- name: Versioning
|
|
||||||
- name: Authentication
|
|
||||||
- name: Instances
|
|
||||||
- name: Instance Groups
|
|
||||||
- name: System Configuration
|
|
||||||
- name: Settings
|
|
||||||
- name: Dashboard
|
|
||||||
- name: Organizations
|
|
||||||
- name: Users
|
|
||||||
- name: Projects
|
|
||||||
- name: Project Updates
|
|
||||||
- name: Teams
|
|
||||||
- name: Credentials
|
|
||||||
- name: Credential Types
|
|
||||||
- name: Inventories
|
|
||||||
- name: Custom Inventory Scripts
|
|
||||||
- name: Inventory Sources
|
|
||||||
- name: Inventory Updates
|
|
||||||
- name: Groups
|
|
||||||
- name: Hosts
|
|
||||||
- name: Job Templates
|
|
||||||
- name: Jobs
|
|
||||||
- name: Job Events
|
|
||||||
- name: Job Host Summaries
|
|
||||||
- name: Ad Hoc Commands
|
|
||||||
- name: Ad Hoc Command Events
|
|
||||||
- name: System Job Templates
|
|
||||||
- name: System Jobs
|
|
||||||
- name: Schedules
|
|
||||||
- name: Roles
|
|
||||||
- name: Notification Templates
|
|
||||||
- name: Notifications
|
|
||||||
- name: Labels
|
|
||||||
- name: Unified Job Templates
|
|
||||||
- name: Unified Jobs
|
|
||||||
- name: Activity Streams
|
|
||||||
- name: Workflow Job Templates
|
|
||||||
- name: Workflow Jobs
|
|
||||||
- name: Workflow Job Template Nodes
|
|
||||||
- name: Workflow Job Nodes
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
The Ansible Tower API Reference Manual provides in-depth documentation for Tower's REST API, including examples on how to integrate with it.
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
import yaml
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -12,18 +10,9 @@ from coreapi.compat import force_bytes
|
|||||||
from openapi_codec.encode import generate_swagger_object
|
from openapi_codec.encode import generate_swagger_object
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import awx
|
|
||||||
from awx.api.versioning import drf_reverse
|
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):
|
class i18nEncoder(DjangoJSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
if isinstance(obj, Promise):
|
if isinstance(obj, Promise):
|
||||||
@@ -62,21 +51,6 @@ class TestSwaggerGeneration():
|
|||||||
data['schemes'] = ['https']
|
data['schemes'] = ['https']
|
||||||
data['consumes'] = ['application/json']
|
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 = {}
|
revised_paths = {}
|
||||||
deprecated_paths = data.pop('deprecated_paths', [])
|
deprecated_paths = data.pop('deprecated_paths', [])
|
||||||
for path, node in data['paths'].items():
|
for path, node in data['paths'].items():
|
||||||
@@ -108,7 +82,6 @@ class TestSwaggerGeneration():
|
|||||||
# Make some basic assertions about the rendered JSON so we can
|
# Make some basic assertions about the rendered JSON so we can
|
||||||
# be sure it doesn't break across DRF upgrades and view/serializer
|
# be sure it doesn't break across DRF upgrades and view/serializer
|
||||||
# changes.
|
# changes.
|
||||||
assert len(JSON['tags'])
|
|
||||||
assert len(JSON['paths'])
|
assert len(JSON['paths'])
|
||||||
|
|
||||||
# The number of API endpoints changes over time, but let's just check
|
# The number of API endpoints changes over time, but let's just check
|
||||||
|
|||||||
Reference in New Issue
Block a user