mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-28 01:26:14 +00:00
Feature: openapi spec, full api browser (#8948)
This commit is contained in:
44
src/documents/schema.py
Normal file
44
src/documents/schema.py
Normal 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"]
|
||||
}
|
Reference in New Issue
Block a user