Feature: openapi spec, full api browser (#8948)

This commit is contained in:
shamoon
2025-02-10 08:43:07 -08:00
committed by GitHub
parent c316ae369b
commit 1dc80f04cb
19 changed files with 1048 additions and 255 deletions

44
src/documents/schema.py Normal file
View File

@@ -0,0 +1,44 @@
from drf_spectacular.extensions import OpenApiAuthenticationExtension
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter
from drf_spectacular.utils import extend_schema
class AngularApiAuthenticationOverrideScheme(OpenApiAuthenticationExtension):
target_class = "paperless.auth.AngularApiAuthenticationOverride"
name = "AngularApiAuthenticationOverride"
def get_security_definition(self, auto_schema): # pragma: no cover
return {
"type": "http",
"scheme": "basic",
}
class PaperelessBasicAuthenticationScheme(OpenApiAuthenticationExtension):
target_class = "paperless.auth.PaperlessBasicAuthentication"
name = "PaperelessBasicAuthentication"
def get_security_definition(self, auto_schema):
return {
"type": "http",
"scheme": "basic",
}
def generate_object_with_permissions_schema(serializer_class):
return {
operation: extend_schema(
parameters=[
OpenApiParameter(
name="full_perms",
type=OpenApiTypes.BOOL,
location=OpenApiParameter.QUERY,
),
],
responses={
200: serializer_class(many=operation == "list", all_fields=True),
},
)
for operation in ["list", "retrieve"]
}