Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 43 for Enum (0.15 sec)

  1. docs/en/docs/tutorial/path-params.md

    ### Create an `Enum` class
    
    Import `Enum` and create a sub-class that inherits from `str` and from `Enum`.
    
    By inheriting from `str` the API docs will be able to know that the values must be of type `string` and will be able to render correctly.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  2. docs/ru/docs/tutorial/path-params.md

    ### Создание класса `Enum`
    
    Импортируйте `Enum` и создайте подкласс, который наследуется от `str` и `Enum`.
    
    Мы наследуемся от `str`, чтобы документация API могла понять, что значения должны быть типа `string` и отображалась правильно.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 14.1K bytes
    - Viewed (0)
  3. docs/zh/docs/tutorial/path-params.md

    ```
    
    否则,`/users/{user_id}` 将匹配 `/users/me`,FastAPI 会**认为**正在接收值为 `"me"` 的 `user_id` 参数。
    
    ## 预设值
    
    路径操作使用 Python 的 <abbr title="Enumeration">`Enum`</abbr> 类型接收预设的*路径参数*。
    
    ### 创建 `Enum` 类
    
    导入 `Enum` 并创建继承自 `str` 和 `Enum` 的子类。
    
    通过从 `str` 继承,API 文档就能把值的类型定义为**字符串**,并且能正确渲染。
    
    然后,创建包含固定值的类属性,这些固定值是可用的有效值:
    
    ```Python hl_lines="1  6-9"
    {!../../../docs_src/path_params/tutorial005.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Apr 01 05:35:40 GMT 2024
    - 7.6K bytes
    - Viewed (0)
  4. docs/fr/docs/tutorial/path-params.md

    ### Création d'un `Enum`
    
    Importez `Enum` et créez une sous-classe qui hérite de `str` et `Enum`.
    
    En héritant de `str` la documentation sera capable de savoir que les valeurs doivent être de type `string` et pourra donc afficher cette `Enum` correctement.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 10K bytes
    - Viewed (0)
  5. docs_src/path_operation_configuration/tutorial002b.py

    from enum import Enum
    
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    class Tags(Enum):
        items = "items"
        users = "users"
    
    
    @app.get("/items/", tags=[Tags.items])
    async def get_items():
        return ["Portal gun", "Plumbus"]
    
    
    @app.get("/users/", tags=[Tags.users])
    async def read_users():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Jan 23 17:43:04 GMT 2022
    - 323 bytes
    - Viewed (0)
  6. docs/de/docs/tutorial/path-params.md

    ### Erstellen Sie eine `Enum`-Klasse
    
    Importieren Sie `Enum` und erstellen Sie eine Unterklasse, die von `str` und `Enum` erbt.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:28:59 GMT 2024
    - 10.3K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_path_params/test_tutorial005.py

            {
                "detail": [
                    {
                        "ctx": {"enum_values": ["alexnet", "resnet", "lenet"]},
                        "loc": ["path", "model_name"],
                        "msg": "value is not a valid enumeration member; permitted: 'alexnet', 'resnet', 'lenet'",
                        "type": "type_error.enum",
                    }
                ]
            }
        )
    
    
    def test_openapi_schema():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Sep 28 04:14:40 GMT 2023
    - 5K bytes
    - Viewed (0)
  8. fastapi/params.py

    import warnings
    from enum import Enum
    from typing import Any, Callable, Dict, List, Optional, Sequence, Union
    
    from fastapi.openapi.models import Example
    from pydantic.fields import FieldInfo
    from typing_extensions import Annotated, deprecated
    
    from ._compat import PYDANTIC_V2, PYDANTIC_VERSION, Undefined
    
    _Unset: Any = Undefined
    
    
    class ParamTypes(Enum):
        query = "query"
        header = "header"
        path = "path"
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 27.5K bytes
    - Viewed (1)
  9. tests/test_application.py

        assert response.status_code == 200, response.text
        assert response.headers["content-type"] == "text/html; charset=utf-8"
        assert "redoc@next" in response.text
    
    
    def test_enum_status_code_response():
        response = client.get("/enum-status-code")
        assert response.status_code == 201, response.text
        assert response.json() == "foo bar"
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 52.2K bytes
    - Viewed (0)
  10. docs/es/docs/tutorial/path-params.md

    ### Crea una clase `Enum`
    
    Importa `Enum` y crea una sub-clase que herede desde `str` y desde `Enum`.
    
    Al heredar desde `str` la documentación de la API podrá saber que los valores deben ser de tipo `string` y podrá mostrarlos correctamente.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.4K bytes
    - Viewed (0)
Back to top