Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 17 for if (0.13 sec)

  1. tests/test_security_oauth2_optional.py

        if oauth_header is None:
            return None
        user = User(username=oauth_header)
        return user
    
    
    @app.post("/login")
    def login(form_data: OAuth2PasswordRequestFormStrict = Depends()):
        return form_data
    
    
    @app.get("/users/me")
    def read_users_me(current_user: Optional[User] = Depends(get_current_user)):
        if current_user is None:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 10.8K bytes
    - Viewed (0)
  2. fastapi/utils.py

        """
        Create a new response field. Raises if type_ is invalid.
        """
        class_validators = class_validators or {}
        if PYDANTIC_V2:
            field_info = field_info or FieldInfo(
                annotation=type_, default=default, alias=alias
            )
        else:
            field_info = field_info or FieldInfo()
        kwargs = {"name": name, "field_info": field_info}
        if PYDANTIC_V2:
            kwargs.update({"mode": mode})
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  3. fastapi/security/http.py

            if not (authorization and scheme and credentials):
                if self.auto_error:
                    raise HTTPException(
                        status_code=HTTP_403_FORBIDDEN, detail="Not authenticated"
                    )
                else:
                    return None
            if scheme.lower() != "bearer":
                if self.auto_error:
                    raise HTTPException(
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Apr 19 15:29:38 GMT 2024
    - 13.2K bytes
    - Viewed (0)
  4. fastapi/param_functions.py

                the dependency is declared again for the rest of the request (for example
                if the dependency is needed by several dependencies), the value will be
                re-used for the rest of the request.
    
                Set `use_cache` to `False` to disable this behavior and ensure the
                dependency is called again (if declared more than once) in the same request.
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 62.5K bytes
    - Viewed (0)
  5. fastapi/params.py

                allow_nan=allow_inf_nan,
                max_digits=max_digits,
                decimal_places=decimal_places,
                **extra,
            )
            if examples is not None:
                kwargs["examples"] = examples
            if regex is not None:
                warnings.warn(
                    "`regex` has been deprecated, please use `pattern` instead",
                    category=DeprecationWarning,
    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)
  6. tests/test_filter_pydantic_sub_model_pv2.py

        class ModelA(BaseModel):
            name: str
            description: Optional[str] = None
            foo: ModelB
    
            @field_validator("name")
            def lower_username(cls, name: str, info: ValidationInfo):
                if not name.endswith("A"):
                    raise ValueError("name must end in A")
                return name
    
        async def get_model_c() -> ModelC:
            return ModelC(username="test-user", password="test-password")
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 6.3K bytes
    - Viewed (0)
  7. fastapi/openapi/utils.py

    ) -> Dict[str, Any]:
        info: Dict[str, Any] = {"title": title, "version": version}
        if summary:
            info["summary"] = summary
        if description:
            info["description"] = description
        if terms_of_service:
            info["termsOfService"] = terms_of_service
        if contact:
            info["contact"] = contact
        if license_info:
            info["license"] = license_info
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 21.8K bytes
    - Viewed (0)
  8. fastapi/security/api_key.py

            ] = None,
            auto_error: Annotated[
                bool,
                Doc(
                    """
                    By default, if the query parameter is not provided, `APIKeyQuery` will
                    automatically cancel the request and send the client an error.
    
                    If `auto_error` is set to `False`, when the query parameter is not
                    available, instead of erroring out, the dependency result will be
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 23 22:29:18 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  9. tests/test_jsonable_encoder.py

            raise NotImplementedError()
    
    
    class RoleEnum(Enum):
        admin = "admin"
        normal = "normal"
    
    
    class ModelWithConfig(BaseModel):
        role: Optional[RoleEnum] = None
    
        if PYDANTIC_V2:
            model_config = {"use_enum_values": True}
        else:
    
            class Config:
                use_enum_values = True
    
    
    class ModelWithAlias(BaseModel):
        foo: str = Field(alias="Foo")
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 9K bytes
    - Viewed (0)
  10. tests/main.py

    
    @app.get("/query/optional")
    def get_query_optional(query=None):
        if query is None:
            return "foo bar"
        return f"foo bar {query}"
    
    
    @app.get("/query/int")
    def get_query_type(query: int):
        return f"foo bar {query}"
    
    
    @app.get("/query/int/optional")
    def get_query_type_optional(query: Optional[int] = None):
        if query is None:
            return "foo bar"
        return f"foo bar {query}"
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 4.3K bytes
    - Viewed (0)
Back to top