Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 48 for get_items (0.07 sec)

  1. docs_src/sql_databases_peewee/sql_app/crud.py

        fake_hashed_password = user.password + "notreallyhashed"
        db_user = models.User(email=user.email, hashed_password=fake_hashed_password)
        db_user.save()
        return db_user
    
    
    def get_items(skip: int = 0, limit: int = 100):
        return list(models.Item.select().offset(skip).limit(limit))
    
    
    def create_user_item(item: schemas.ItemCreate, user_id: int):
        db_item = models.Item(**item.dict(), owner_id=user_id)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 843 bytes
    - Viewed (0)
  2. docs_src/generate_clients/tutorial003_py39.py

    @app.post("/items/", response_model=ResponseMessage, tags=["items"])
    async def create_item(item: Item):
        return {"message": "Item received"}
    
    
    @app.get("/items/", response_model=list[Item], tags=["items"])
    async def get_items():
        return [
            {"name": "Plumbus", "price": 3},
            {"name": "Portal Gun", "price": 9001},
        ]
    
    
    @app.post("/users/", response_model=ResponseMessage, tags=["users"])
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Mar 04 22:02:18 UTC 2022
    - 914 bytes
    - Viewed (0)
  3. docs_src/sql_databases_peewee/sql_app/main.py

        return crud.create_user_item(item=item, user_id=user_id)
    
    
    @app.get("/items/", response_model=List[schemas.Item], dependencies=[Depends(get_db)])
    def read_items(skip: int = 0, limit: int = 100):
        items = crud.get_items(skip=skip, limit=limit)
        return items
    
    
    @app.get(
        "/slowusers/", response_model=List[schemas.User], dependencies=[Depends(get_db)]
    )
    def read_slow_users(skip: int = 0, limit: int = 100):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 2.2K bytes
    - Viewed (0)
  4. docs/em/docs/advanced/generate-clients.md

    👥 💪 ⏬ 🗄 🎻 📁 `openapi.json` & ⤴️ 👥 💪 **❎ 👈 🔡 🔖** ⏮️ ✍ 💖 👉:
    
    ```Python
    {!../../docs_src/generate_clients/tutorial004.py!}
    ```
    
    ⏮️ 👈, 🛠️ 🆔 🔜 📁 ⚪️➡️ 👜 💖 `items-get_items` `get_items`, 👈 🌌 👩‍💻 🚂 💪 🏗 🙅 👩‍🔬 📛.
    
    ### 🏗 📕 👩‍💻 ⏮️ 🗜 🗄
    
    🔜 🔚 🏁 📁 `openapi.json`, 👆 🔜 🔀 `package.json` ⚙️ 👈 🇧🇿 📁, 🖼:
    
    ```JSON  hl_lines="7"
    {
      "name": "frontend-app",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.4K bytes
    - Viewed (0)
  5. docs/de/docs/advanced/generate-clients.md

    ```
    
    ////
    
    //// tab | Node.js
    
    ```Javascript
    {!> ../../docs_src/generate_clients/tutorial004.js!}
    ```
    
    ////
    
    Damit würden die Operation-IDs von Dingen wie `items-get_items` in `get_items` umbenannt, sodass der Client-Generator einfachere Methodennamen generieren kann.
    
    ### Einen TypeScript-Client mit der modifizierten OpenAPI generieren
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11.9K bytes
    - Viewed (0)
  6. tests/test_infer_param_optionality.py

        return {"user_id": user_id}
    
    
    @item_router.get("/")
    def get_items(user_id: Optional[str] = None):
        if user_id is None:
            return [{"item_id": "i1", "user_id": "u1"}, {"item_id": "i2", "user_id": "u2"}]
        else:
            return [{"item_id": "i2", "user_id": user_id}]
    
    
    @item_router.get("/{item_id}")
    def get_item(item_id: str, user_id: Optional[str] = None):
        if user_id is None:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 13.3K bytes
    - Viewed (0)
  7. docs/zh/docs/advanced/generate-clients.md

    我们可以将 OpenAPI JSON 下载到一个名为`openapi.json`的文件中,然后使用以下脚本**删除此前缀的标签**:
    
    ```Python
    {!../../docs_src/generate_clients/tutorial004.py!}
    ```
    
    通过这样做,操作ID将从类似于 `items-get_items` 的名称重命名为 `get_items` ,这样客户端生成器就可以生成更简洁的方法名称。
    
    ### 使用预处理的OpenAPI生成TypeScript客户端
    
    现在,由于最终结果保存在文件openapi.json中,你可以修改 package.json 文件以使用此本地文件,例如:
    
    ```JSON  hl_lines="7"
    {
      "name": "frontend-app",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 9K bytes
    - Viewed (0)
  8. tests/test_extra_routes.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        price: Optional[float] = None
    
    
    @app.api_route("/items/{item_id}", methods=["GET"])
    def get_items(item_id: str):
        return {"item_id": item_id}
    
    
    def get_not_decorated(item_id: str):
        return {"item_id": item_id}
    
    
    app.add_api_route("/items-not-decorated/{item_id}", get_not_decorated)
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 13.7K bytes
    - Viewed (0)
  9. docs_src/dependencies/tutorial008c.py

        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("Oops, we didn't raise again, Britney 😱")
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: str = Depends(get_username)):
        if item_id == "portal-gun":
            raise InternalError(
                f"The portal gun is too dangerous to be owned by {username}"
            )
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 660 bytes
    - Viewed (0)
  10. docs_src/dependencies/tutorial008c_an_py39.py

        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("Oops, we didn't raise again, Britney 😱")
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
        if item_id == "portal-gun":
            raise InternalError(
                f"The portal gun is too dangerous to be owned by {username}"
            )
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 700 bytes
    - Viewed (0)
Back to top