Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 167 for modal (0.48 sec)

  1. tests/test_response_model_invalid.py

        pass
    
    
    def test_invalid_response_model_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=NonPydanticModel)
            def read_root():
                pass  # pragma: nocover
    
    
    def test_invalid_response_model_sub_type_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=List[NonPydanticModel])
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 29 13:04:35 GMT 2020
    - 1.1K bytes
    - Viewed (0)
  2. tests/test_response_model_data_filter.py

        name: str
        owner: UserDB
    
    
    class PetOut(BaseModel):
        name: str
        owner: UserBase
    
    
    @app.post("/users/", response_model=UserBase)
    async def create_user(user: UserCreate):
        return user
    
    
    @app.get("/pets/{pet_id}", response_model=PetOut)
    async def read_pet(pet_id: int):
        user = UserDB(
            email="******@****.***",
            hashed_password="secrethashed",
        )
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.7K bytes
    - Viewed (0)
  3. tests/test_jsonable_encoder.py

    
    def test_encode_model_with_alias_raises():
        with pytest.raises(ValidationError):
            ModelWithAlias(foo="Bar")
    
    
    def test_encode_model_with_alias():
        model = ModelWithAlias(Foo="Bar")
        assert jsonable_encoder(model) == {"Foo": "Bar"}
    
    
    def test_encode_model_with_default():
        model = ModelWithDefault(foo="foo", bar="bar")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 9K bytes
    - Viewed (0)
  4. docs_src/path_params/tutorial005.py

    
    app = FastAPI()
    
    
    @app.get("/models/{model_name}")
    async def get_model(model_name: ModelName):
        if model_name is ModelName.alexnet:
            return {"model_name": model_name, "message": "Deep Learning FTW!"}
    
        if model_name.value == "lenet":
            return {"model_name": model_name, "message": "LeCNN all the images"}
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Aug 26 13:26:03 GMT 2022
    - 546 bytes
    - Viewed (0)
  5. tests/test_datetime_custom_encoder.py

        app = FastAPI()
        model = ModelWithDatetimeField(dt_field=datetime(2019, 1, 1, 8))
    
        @app.get("/model", response_model=ModelWithDatetimeField)
        def get_model():
            return model
    
        client = TestClient(app)
        with client:
            response = client.get("/model")
        assert response.json() == {"dt_field": "2019-01-01T08:00:00+00:00"}
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.6K bytes
    - Viewed (0)
  6. fastapi/openapi/utils.py

        all_fields = get_fields_from_routes(list(routes or []) + list(webhooks or []))
        model_name_map = get_compat_model_name_map(all_fields)
        schema_generator = GenerateJsonSchema(ref_template=REF_TEMPLATE)
        field_mapping, definitions = get_definitions(
            fields=all_fields,
            schema_generator=schema_generator,
            model_name_map=model_name_map,
            separate_input_output_schemas=separate_input_output_schemas,
        )
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 21.8K bytes
    - Viewed (0)
  7. docs_src/sql_databases/sql_app_py310/main.py

            db.close()
    
    
    @app.post("/users/", response_model=schemas.User)
    def create_user(user: schemas.UserCreate, db: Session = Depends(get_db)):
        db_user = crud.get_user_by_email(db, email=user.email)
        if db_user:
            raise HTTPException(status_code=400, detail="Email already registered")
        return crud.create_user(db=db, user=user)
    
    
    @app.get("/users/", response_model=list[schemas.User])
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.6K bytes
    - Viewed (0)
  8. docs_src/response_model/tutorial005.py

            "tax": 10.5,
        },
    }
    
    
    @app.get(
        "/items/{item_id}/name",
        response_model=Item,
        response_model_include={"name", "description"},
    )
    async def read_item_name(item_id: str):
        return items[item_id]
    
    
    @app.get("/items/{item_id}/public", response_model=Item, response_model_exclude={"tax"})
    async def read_item_public_data(item_id: str):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 848 bytes
    - Viewed (0)
  9. docs_src/response_model/tutorial006_py310.py

            "tax": 10.5,
        },
    }
    
    
    @app.get(
        "/items/{item_id}/name",
        response_model=Item,
        response_model_include=["name", "description"],
    )
    async def read_item_name(item_id: str):
        return items[item_id]
    
    
    @app.get("/items/{item_id}/public", response_model=Item, response_model_exclude=["tax"])
    async def read_item_public_data(item_id: str):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 816 bytes
    - Viewed (0)
  10. docs_src/body_updates/tutorial002_py39.py

    }
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_item(item_id: str):
        return items[item_id]
    
    
    @app.patch("/items/{item_id}", response_model=Item)
    async def update_item(item_id: str, item: Item):
        stored_item_data = items[item_id]
        stored_item_model = Item(**stored_item_data)
        update_data = item.dict(exclude_unset=True)
        updated_item = stored_item_model.copy(update=update_data)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 1K bytes
    - Viewed (0)
Back to top