It's an app to convert a serializer to a typescript interface
pip install rest-serializer-to-typescript
- Add
rest_serializer_to_typescript
to INSTALLED_APPS - Add the following data to your
settings.py
file
REST_SERIALIZERS_TO_TYPESCRIPT = {
"META_DATA": "rest_framework.metadata.SimpleMetadata",
"SERIALIZERS": {
"your_serializer_1_path": "output_1_address",
"your_serializer_2_path": "output_2_address",
}
}
For example:
REST_SERIALIZERS_TO_TYPESCRIPT = {
"META_DATA": "rest_framework.metadata.SimpleMetadata",
"SERIALIZERS": {
"myapp.serializers": "types/myapp_types.ts",
"custom_app.serializers": "types/custom_app_types.ts",
}
}
- Run
./manage.py serializer_to_ts