我按照说明将django-rest-swagger
添加到了django-rest-framework项目中。 GUI看起来不错,但是似乎由APIView
的{{1}}字段自动生成的请求描述有一些问题。具体地
get_serializer
{}
类型都被列为string
,而忽略了openapi string
字段例如,对于此序列化程序
format
GUI将请求显示为
class NestedSerializer(Serializer):
firstname = StringField()
class RequestSerializer(Serializer):
name = NestedSerializer()
date = DateField()
choice = ChoiceField(['aa', 'bb', 'cc'])
我是否缺少某些东西,或者该项目确实不支持更多特定类型?
答案 0 :(得分:0)
我不确定您是否导入了正确的序列化程序字段。
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"Amranidev/scaffold-interface": "^1.7",
"barryvdh/laravel-dompdf": "^0.8.4",
"doctrine/dbal": "^2.9",
"fideloper/proxy": "^4.0",
"genealabs/laravel-caffeine": "^0.8.1",
"h4cc/wkhtmltoimage-amd64": "0.12.x",
"h4cc/wkhtmltoimage-i386": "0.12.x",
"h4cc/wkhtmltopdf-amd64": "0.12.x",
"h4cc/wkhtmltopdf-i386": "0.12.x",
"laracasts/flash": "^3.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"league/html-to-markdown": "^4.8",
"maatwebsite/excel": "^3.1",
"mtownsend/request-xml": "^1.0"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"Ceamsa\\": "app/"
},
"files": [
"app/Http/Helpers/ApiHelpers.php",
"app/Http/Helpers/CertificateHelpers.php",
"app/Http/Helpers/CommonHelpers.php",
"app/Http/Helpers/CrudHelpers.php",
"app/Http/Helpers/LanguageHelpers.php",
"app/Http/Helpers/SapHelpers.php",
"app/Http/Helpers/TemplateHelpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
包中似乎没有包含StringField()
。
此外,rest_framework.serializers
被标记为已弃用。作为django-rest-swagger
回购django-rest-swagger
的所有者,您应该使用drf-yasg,它同时支持以下两种情况:
django-rest-swagger