Replies: 2 comments 3 replies
-
|
I don't understand why such an action is necessary, but you should have it in the following form (if I have understood the meaning correctly): from config import settings
class Item1(BaseModel):
name: str
description: str | None = None
cpu: int
ram: int
env: str
class Item2(BaseModel):
name: str
description: str | None = None
env: str
models = {
"dev": Item1,
"stage": Item2,
}
@app.post("/create")
def deploy_item_in_vra(item: models[settings.env] = Depends()):
response = vra_deploy_item(item=item)
return response |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Let's close this for now to keep the discussions clean and organized. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
is it possible in fastapi to select a body according to the value of another parameter?
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.105.0
Pydantic Version
2.5.2
Python Version
3.10.6
Additional Context
is it possible in fastapi to select a body according to the value of another parameter?
Beta Was this translation helpful? Give feedback.
All reactions