drf-spectacular icon indicating copy to clipboard operation
drf-spectacular copied to clipboard

Vendor extensions in schema fields

Open ElSaico opened this issue 2 years ago • 2 comments

Hello,

I'm working on an API schema so that it plays nicely with the Prism mock server, and one of its features is the support for using Faker to generate field values. However, this makes use of a vendor extension (x-faker), and trying to set it (with a dict on extend_schema_field) seems ineffective.

Is there any way to actually set this extra parameter?

ElSaico avatar Jul 06 '22 13:07 ElSaico

Hi!

do you mean this? https://github.com/tfranzel/drf-spectacular/blob/66086cf2d18ca007224a79269efdfa74f1a035e1/tests/test_specification_extensions.py#L165

otherwise, please provide an example to make this easier to talk about.

tfranzel avatar Jul 06 '22 14:07 tfranzel

Hi!

do you mean this?

https://github.com/tfranzel/drf-spectacular/blob/66086cf2d18ca007224a79269efdfa74f1a035e1/tests/test_specification_extensions.py#L165

otherwise, please provide an example to make this easier to talk about.

Hi, thanks for answering!

What I mean is extending the response properties - tried to set it on the serializer, but no dice. Like:

address:
  type: string
  maxLength: 64
  x-faker: address.streetAddress

ElSaico avatar Jul 06 '22 15:07 ElSaico