django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

applying renderers and parsers to TestClient

Open VityasZV opened this issue 3 years ago • 1 comments

Hey, how can I apply my own renderer and parser to TestClient? The API itself works correctly, but the TestClient only accepts and returns json format. It should be added to this that when using a custom renderer (for example, xml), the generated swager still sends the content type equal to app/json in the headers

VityasZV avatar Jan 28 '22 10:01 VityasZV

Hi @VityasZV I think it should work out of the box

to send non-json body you can just use body argument in parsers tests:

see https://github.com/vitalik/django-ninja/blob/master/tests/test_parser.py#L38

for renderers:

https://github.com/vitalik/django-ninja/blob/master/tests/test_renderer.py#L89-L94

vitalik avatar Jan 28 '22 11:01 vitalik