Starlette响应的键中是否允许空格?

时间:2019-08-10 08:28:30

标签: python fastapi starlette pydantic

我正在尝试确定是否可以在架构的键中放置空格。

我的回答似乎出现错误,并且似乎与此空间有关。没有空格,我得到200,并且得到验证错误。

下面使用foo_bar的方式是它是pydantic.BaseModel的属性,其实例将返回到装饰有FastAPI().post的协程。

foo_bar = Schema(
    ...,
    alias='foo bar'
)

foo_bar = Schema(...)

跟踪

File python3.6/site-packages/starlette/routing.py\", line 585, in __call__

await route(scope, receive, send)

File \"python3.6/site-packages/starlette/routing.py\", line 207, in __call__

await self.app(scope, receive, send)

File \"python3.6/site-packages/starlette/routing.py\", line 40, in app

response = await func(request)

File \"python3.6/site-packages/fastapi/routing.py\", line 122, in app

skip_defaults=response_model_skip_defaults

File \"python3.6/site-packages/fastapi/routing.py\", line 54, in serialize_response

raise ValidationError(errors)

pydantic.error_wrappers.ValidationError: 1 validation error
  response
value is not a valid dict (type=type_error.dict)"

0 个答案:

没有答案