Questions tagged [drf-spectacular]

Sane and flexible OpenAPI 3.0 schema generation for Django REST framework.

98 questions
1
vote
1 answer

Swagger UI examples using drf-spectacular and x-www-form-urlencoded requests

Is it possible to generate a swagger UI page (and redoc for that matter) that has examples for both application/json and x-www-form-urlencoded request bodies? I can get examples for application/json, but not when selecting x-www-form-urlencoded as…
gmcc051
  • 390
  • 3
  • 17
1
vote
1 answer

Append new request example to drf-spectacular schema

I know the way to add examples for the schema used by drf-spectacular is: examples=[ OpenApiExample( 'Example 1', description='longer description', value='example' ), …
1
vote
1 answer

drf-spectacular not working when versioning is used (No operations defined in spec!)

Some weeks ago I installed drf-spectacular. Everything was working properly until I enabled versioning in DRF (Django Rest Framework). I implemented AcceptHeaderVersioning and it was working correctly. But then I realized Swagger wasn't showing the…
oz19
  • 1,616
  • 1
  • 17
  • 22
1
vote
1 answer

drf-spectacular: how to show the primary key in examples section of Swagger

I'm trying to show the primary key in the examples section of Swagger, I'm using drf-spectacular and my code looks like: Serializers.py class SerializerExample(serializers.ModelSerializer): class Meta: model = Book fields =…
David1212k
  • 190
  • 1
  • 10
1
vote
1 answer

drf-spectacular: Add description to HTTP_204

@extend_schema( request=MyRequestSerializer, …
ThunderHorn
  • 1,975
  • 1
  • 20
  • 42
0
votes
0 answers

How to send payload using body of a GET request with drf-spectacular?

I'm writing an API using Django REST Framework. I'm sending some data using the body of a GET request and everything is working fine. Now I'm using drf-spectacular to generate SwaggerUI and ReDoc but I don't know how to make it do the request like…
0
votes
0 answers

drf_spectacular schema annotation for optional serializer return type

I have a Django Rest Framework ModelSerializer with the following SerializerMethodField: def get_segments(self, obj): segments = models.Segment.objects.filter(obj=obj) if segments: return SegmentSerializer(segments,…
Luciano
  • 426
  • 2
  • 9
  • 19
0
votes
1 answer

PresentablePrimaryKeyRelatedFieldSchema extension is not working

I am very new to drf-spectacular. Actually i have a third party field in my Serializer. class DummySerializer(serializers.Serializer): dummy_field = PresentablePrimaryKeyRelatedField( queryset=DummyModel.objects, …
0
votes
0 answers

is is possible to generate examples from PolymorphicProxySerializer using drf-spectacular

I am using drf-spectacular to generate some swagger documentations. There is one endpoints, that supports multiple body requests and I am using PolymorphicProxySerializer to describe this oneOf schema. Also, I see that by default one example is auto…
Sharmiko
  • 543
  • 4
  • 21
0
votes
0 answers

DRF Spectacular - @extend_schema subclass method for Serializers

Im using DRF_SPECTACTULAR to generate swagger DOC from my DRF Project. I have a GenericViewSet that implement CRUD methods. Over each ones, I have extend_schema decorator. Take this one as example: @extend_schema( # extra parameters…
EviSvil
  • 510
  • 3
  • 21
0
votes
0 answers

Custom Swagger Documentation Setup for Internal and Client Use with Tailored Endpoints and Operations

I need to set up Swagger documentation for both internal and client use, with custom HTML templates for each. For internal documentation, I need to display all endpoints along with all their operations. However, for client documentation, I only want…
0
votes
1 answer

how to specify response for specific request methods for API action in django

I have an API action in django which accepts GET and POST requests where each of them will have a distinct response schema. If a request is of method "GET" we will return a list, if it is "POST" we will return only the created entity... from…
Austin Hallett
  • 183
  • 1
  • 17
0
votes
1 answer

drf_spectacular.utils.PolymorphicProxySerializer.__init__() got an unexpected keyword argument 'context'

I am using a PolymorphicProxySerializer provided by drf_spectacular but I am getting a strange error when attempting to load the schema usage @extend_schema( parameters=[NoteQueryParameters], …
0
votes
0 answers

Receive input in file format from swagger form (Django)

# model class User(AbstractBaseUser, PermissionsMixin, CommonModel): phone = models.CharField(max_length=20, unique=True) nickname = models.CharField(max_length=20, unique=True) certification_profile = models.URLField(null=True) …
0
votes
1 answer

"detail": "Authentication credentials were not provided." Django DRF

Im trying to create an api for my django project to get some data from database and show it as restframework Response everytime I try to get the data it shows me this error this is my views.py code for getting the data class…