mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
generate Swagger schemas as if view permissions didn't matter
this fixes several scenarios where certain POST endpoints don't show up in our generated Swagger doc; /api/swagger is only discoverable/accessible in the development environment where we generate the schema
This commit is contained in:
parent
fb1d918c2d
commit
023fbc931d
@ -13,6 +13,17 @@ from rest_framework.views import APIView
|
||||
from rest_framework_swagger import renderers
|
||||
|
||||
|
||||
class SuperUserSchemaGenerator(SchemaGenerator):
|
||||
|
||||
def has_view_permissions(self, path, method, view):
|
||||
#
|
||||
# Generate the Swagger schema as if you were a superuser and
|
||||
# permissions didn't matter; this short-circuits the schema path
|
||||
# discovery to include _all_ potential paths in the API.
|
||||
#
|
||||
return True
|
||||
|
||||
|
||||
class AutoSchema(DRFAuthSchema):
|
||||
|
||||
def get_link(self, path, method, base_url):
|
||||
@ -59,7 +70,7 @@ class SwaggerSchemaView(APIView):
|
||||
]
|
||||
|
||||
def get(self, request):
|
||||
generator = SchemaGenerator(
|
||||
generator = SuperUserSchemaGenerator(
|
||||
title='Ansible Tower API',
|
||||
patterns=None,
|
||||
urlconf=None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user