x_param = openapi.Parameter('x', in_=openapi.IN_FORM, description='srring',
type=openapi.TYPE_STRING)
y_param = openapi.Parameter('y', in_=openapi.IN_FORM, description='string',
type=openapi.TYPE_STRING)
@swagger_auto_schema(method='post', manual_parameters=[x_param,y_param])
@api_view(['POST'])
def test(request):
pass
I used drf_yasg
as a swagger.
I did the coding above and tested it with swagger, and when I checked with Chrome, the request payload is x = 124 & y = 124124
.
And, with the following message, a bad request error occurred.
{
"detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)"
}
Is it wrong to add post parameters to the swagger?
in_=openapi.IN_FORM
tells it that you expect it to be a form, while your API is configured to accept JSON? – Overlay{'x': 124, 'y': 124124}
? – Moustacheopenapi.IN_FORM
toopenapi.IN_BODY
– Alvaroalveolar