-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
253 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
******** | ||
Examples | ||
******** | ||
|
||
The below examples demonstrate how to use marshmallow in various contexts. | ||
To run each example, you will need to have `uv <https://docs.astral.sh/uv/getting-started/installation/>`_ installed. | ||
The examples use `PEP 723 inline metadata <https://peps.python.org/pep-0723/>`_ | ||
to declare the dependencies of each script. ``uv`` will install the | ||
dependencies automatically when running these scripts. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
validating_package_json | ||
quotes_api | ||
inflection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
***************************** | ||
Inflection (camel-cased keys) | ||
***************************** | ||
|
||
HTTP APIs will often use camel-cased keys for their input and output representations. This example shows how you can use the | ||
`Schema.on_bind_field <marshmallow.Schema.on_bind_field>` hook to automatically inflect keys. | ||
|
||
.. literalinclude:: ../../examples/inflection_example.py | ||
:language: python | ||
|
||
To run the example: | ||
|
||
.. code-block:: shell-session | ||
$ uv run examples/inflection_example.py | ||
Loaded data: | ||
{'first_name': 'David', 'last_name': 'Bowie'} | ||
Dumped data: | ||
{'firstName': 'David', 'lastName': 'Bowie'} |
Oops, something went wrong.