Skip to content

Commit

Permalink
Merge branch '3.x-line' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jan 15, 2025
2 parents 73d5cc8 + 5728f13 commit 0493600
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 559 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Features:

Documentation:

- Various documentation improvements (:pr:`2757`, :pr:`2759`, :pr:`2765`, :pr:`2774`).
- Various documentation improvements (:pr:`2757`, :pr:`2759`, :pr:`2765`, :pr:`2774`, :pr:`2778`).

Deprecations:

Expand Down
299 changes: 0 additions & 299 deletions docs/examples.rst

This file was deleted.

16 changes: 16 additions & 0 deletions docs/examples/index.rst
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
19 changes: 19 additions & 0 deletions docs/examples/inflection.rst
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'}
Loading

0 comments on commit 0493600

Please sign in to comment.