Skip to content

Commit

Permalink
Merge pull request #585 from jennydaman/fix-plugininstance-nullables
Browse files Browse the repository at this point in the history
Fix OpenAPI spec of PluginInstance nullable fields previous, previous_id, workflow
  • Loading branch information
jennydaman authored Oct 7, 2024
2 parents a197f17 + e04fa0f commit 3f6858b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions chris_backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.reverse import reverse
from rest_framework import exceptions
from rest_framework.authentication import TokenAuthentication
from drf_spectacular.extensions import OpenApiAuthenticationExtension

from collectionjson import services
from .models import ChrisInstance, FileDownloadToken, FileDownloadTokenFilter
Expand Down Expand Up @@ -156,3 +157,15 @@ def authenticate_token(token: str) -> User:

token_obj.delete() # one-time-use token, we could instead set revoked=true
return user


class TokenAuthSupportQueryStringScheme(OpenApiAuthenticationExtension):
target_class = TokenAuthSupportQueryString
name = 'DownloadTokenInQueryString'

def get_security_definition(self, auto_schema):
return {
'type': 'apiKey',
'in': 'header',
'name': 'download_token'
}
4 changes: 2 additions & 2 deletions chris_backend/plugininstances/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PluginInstanceSerializer(serializers.HyperlinkedModelSerializer):
size = serializers.ReadOnlyField()
error_code = serializers.ReadOnlyField()
previous = serializers.HyperlinkedRelatedField(
view_name='plugininstance-detail', read_only=True
view_name='plugininstance-detail', read_only=True, allow_null=True
)
output_folder = serializers.HyperlinkedRelatedField(view_name='chrisfolder-detail',
read_only=True)
Expand All @@ -49,7 +49,7 @@ class PluginInstanceSerializer(serializers.HyperlinkedModelSerializer):
view_name='plugin-detail', read_only=True
)
workflow = serializers.HyperlinkedRelatedField(
view_name='workflow-detail', read_only=True
view_name='workflow-detail', read_only=True, allow_null=True
)
feed = serializers.HyperlinkedRelatedField(view_name='feed-detail', read_only=True)
compute_resource = serializers.HyperlinkedRelatedField(
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ whitenoise[brotli]==6.5.0
PyJWT===2.8.0
channels[daphne]==4.1.0
nats-py==2.9.0
drf-spectacular==0.27.2
git+https://github.com/tfranzel/drf-spectacular.git@refs/pull/1307/head

0 comments on commit 3f6858b

Please sign in to comment.