Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 51 for Trick (0.2 sec)

  1. docs/en/docs/advanced/dataclasses.md

    !!! info
        Keep in mind that dataclasses can't do everything Pydantic models can do.
    
        So, you might still need to use Pydantic models.
    
        But if you have a bunch of dataclasses laying around, this is a nice trick to use them to power a web API using FastAPI. 🤓
    
    ## Dataclasses in `response_model`
    
    You can also use `dataclasses` in the `response_model` parameter:
    
    ```Python hl_lines="1  7-13  19"
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 4.1K bytes
    - Viewed (0)
  2. build-logic/jvm/src/main/kotlin/gradlebuild.launchable-jar.gradle.kts

    val startScripts = tasks.register<GradleStartScriptGenerator>("startScripts") {
        startScriptsDir = layout.buildDirectory.dir("startScripts")
        launcherJar.from(tasks.jar)
        agentJars.from(agentsClasspath)
        // The trick below is to use the templates from the current code instead of the wrapper. It does not cover the case where the generation logic is updated though.
    Plain Text
    - Registered: Wed Mar 27 11:36:08 GMT 2024
    - Last Modified: Wed Feb 28 23:38:57 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  3. guava-tests/benchmark/com/google/common/hash/ChecksumBenchmark.java

          result = (byte) (result ^ checksum.getValue());
        }
        return result;
      }
    
      // Helpers + main
    
      private byte runHashFunction(int reps, HashFunction hashFunction) {
        byte result = 0x01;
        // Trick the JVM to prevent it from using the hash function non-polymorphically
        result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
        result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
        for (int i = 0; i < reps; i++) {
    Java
    - Registered: Fri Apr 19 12:43:09 GMT 2024
    - Last Modified: Tue Jun 13 16:19:15 GMT 2023
    - 2.9K bytes
    - Viewed (0)
  4. android/guava-tests/benchmark/com/google/common/hash/ChecksumBenchmark.java

          result = (byte) (result ^ checksum.getValue());
        }
        return result;
      }
    
      // Helpers + main
    
      private byte runHashFunction(int reps, HashFunction hashFunction) {
        byte result = 0x01;
        // Trick the JVM to prevent it from using the hash function non-polymorphically
        result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
        result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
        for (int i = 0; i < reps; i++) {
    Java
    - Registered: Fri Apr 26 12:43:10 GMT 2024
    - Last Modified: Tue Jun 13 16:19:15 GMT 2023
    - 2.9K bytes
    - Viewed (0)
  5. docs/de/docs/advanced/dataclasses.md

        Daher müssen Sie möglicherweise weiterhin Pydantic-Modelle verwenden.
    
        Wenn Sie jedoch eine Menge Datenklassen herumliegen haben, ist dies ein guter Trick, um sie für eine Web-API mithilfe von FastAPI zu verwenden. 🤓
    
    ## Datenklassen als `response_model`
    
    Sie können `dataclasses` auch im Parameter `response_model` verwenden:
    
    ```Python hl_lines="1  7-13  19"
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:18:23 GMT 2024
    - 4.6K bytes
    - Viewed (0)
  6. docs/en/docs/tutorial/path-params-numeric-validations.md

        ```
    
    ## Order the parameters as you need, tricks
    
    !!! tip
        This is probably not as important or necessary if you use `Annotated`.
    
    Here's a **small trick** that can be handy, but you won't need it often.
    
    If you want to:
    
    * declare the `q` query parameter without a `Query` nor any default value
    * declare the path parameter `item_id` using `Path`
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  7. docs/en/docs/advanced/path-operation-advanced-configuration.md

    Nevertheless, we can declare the expected schema for the request body.
    
    ### Custom OpenAPI content type
    
    Using this same trick, you could use a Pydantic model to define the JSON Schema that is then included in the custom OpenAPI schema section for the *path operation*.
    
    And you could do this even if the data type in the request is not JSON.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 7.7K bytes
    - Viewed (0)
  8. docs/de/docs/advanced/path-operation-advanced-configuration.md

    Dennoch können wir das zu erwartende Schema für den Requestbody deklarieren.
    
    ### Benutzerdefinierter OpenAPI-Content-Type
    
    Mit demselben Trick könnten Sie ein Pydantic-Modell verwenden, um das JSON-Schema zu definieren, das dann im benutzerdefinierten Abschnitt des OpenAPI-Schemas für die *Pfadoperation* enthalten ist.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:27:23 GMT 2024
    - 8.5K bytes
    - Viewed (0)
  9. tests/test_dependency_normal_exceptions.py

        assert state["finally"] is False
        response = client.put("/invalid-user/rick", json="Morty")
        assert response.status_code == 400, response.text
        assert response.json() == {"detail": "Invalid user"}
        assert state["except"] is True
        assert state["finally"] is True
        assert fake_database["rick"] == "Rick Sanchez"
    
    
    def test_dependency_no_exception():
        assert state["except"] is False
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_dependencies/test_tutorial008b_an.py

        assert response.status_code == 400, response.text
        assert response.json() == {"detail": "Owner error: Rick"}
    
    
    def test_get_item():
        response = client.get("/items/portal-gun")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Dec 26 20:37:34 GMT 2023
    - 700 bytes
    - Viewed (0)
Back to top