8

I have an Api in DRF, describes with swagger. In my serializer i have a field like that :

settings = serializers.DictField(child=serializers.JSONField())

Is it possible that in the swagger.json the field was describe as 'Json' and not as string:

"additionalProperties": {
            "type": "string"
}

but

"additionalProperties": {
        "type": "JSON"
}
Tom DARBOUX
  • 462
  • 4
  • 9

1 Answers1

4

Sorry this is not possbile with JSON Schema.

The types are the primitive types allowed by JSON.

Relequestual
  • 11,631
  • 6
  • 47
  • 83
  • Do you now if it's possible to define a custom serializer Field with a custom type ? So I will be able to create a custom JsonField. – Tom DARBOUX Jun 27 '19 at 08:12
  • I need my auto-generated input in my form to be a textarea and not just a text input (which is the input associated with String)... – Tom DARBOUX Jun 27 '19 at 08:19
  • JSON Schema was designed for validating JSON data. If your field is a string encoded JSON (in your JSON), then you could use a regex (`pattern` keyword) to validate that the string is valid JSON. It would be helpful if you could include example JSON data you want to validate. – Relequestual Jun 27 '19 at 08:31