使用 ORM,我想要执行一个 POST 请求,让某些字段具有null值,该值将在数据库中转换为那里指定的默认值。
问题是 OpenAPI (Swagger) docs忽略了默认值None,并且默认情况下仍然提示 a UUID。
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
from uuid import UUID
import uvicorn
class Table(BaseModel):
# ID: Optional[UUID] # the docs show a example UUID, ok
ID: Optional[UUID] = None # the docs still shows a uuid, when it should show a null or valid None value.
app = FastAPI()
@app.post("/table/", response_model=Table)
def create_table(table: Table):
# here we call …Run Code Online (Sandbox Code Playgroud) 我有一个 SvelteKit 应用程序,只需遵循文档https://learn.svelte.dev/tutorial/named-form-actions中的示例,问题是一切正常,直到我尝试编写一个操作:
在: +page.server.js
export const actions = {
default: async () => {
console.log('test')
}
};
Run Code Online (Sandbox Code Playgroud)
vite 立即失败并显示:“无法使用操作预渲染页面”
Error: Cannot prerender pages with actions
at render_page (file:///mydir/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:87:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async resolve (file:///mydir/node_modules/@sveltejs/kit/src/runtime/server/index.js:356:17)
at async respond (file:///mydir/node_modules/@sveltejs/kit/src/runtime/server/index.js:229:20)
at async file:///mydir/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:444:22
Run Code Online (Sandbox Code Playgroud)
可能我缺少一些配置或忘记了一些基础知识,知道吗?
我正在使用基于 python 2.7 的旧代码(不幸的是,无法更改它)。我必须从一段基于 python 3.6 的代码中引入一个新功能。这段代码可以工作,除非它使用了包枚举,据我所知,该枚举不再维护。所以:
from enum import Enum, auto (不适用于Python 2.7)
因为我认为 python 2.7 中没有定义“auto”。是否有可能使该线路正常工作?或者至少安装/导入“enum.auto”或具有相同功能的东西?
python ×2
database ×1
enums ×1
fastapi ×1
javascript ×1
openapi ×1
python-2.7 ×1
sveltekit ×1
swagger ×1
vite ×1