mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 20:37:46 +00:00
This PR updates the examples for Connexion 3.0 and merges them for OpenAPI and Swagger. 2 examples required some changes to make them work: - The reverse proxy example required some fixes to the SwaggerUIMiddleware to leverage the `root_path` correctly. This is included in the PR. - The enforced defaults example requires the json validator to adapt the body and pass it on. We currently pass on the original body after validation, and I'm not sure if we should change this. I'll submit a separate PR to discuss this.
24 lines
819 B
ReStructuredText
24 lines
819 B
ReStructuredText
========================
|
|
Custom Validator Example
|
|
========================
|
|
|
|
.. warning::
|
|
|
|
This example is outdated. Currently validation no longer adapts the body.
|
|
TODO: decide if validation should adapt body or how we want to enable defaults otherwise.
|
|
|
|
In this example we fill-in non-provided properties with their defaults.
|
|
Validator code is based on example from `python-jsonschema docs`_.
|
|
|
|
Running:
|
|
|
|
.. code-block:: bash
|
|
|
|
$ python app.py
|
|
|
|
Now open your browser and go to http://localhost:8080/v1/ui/ to see the Swagger
|
|
UI. If you send a ``POST`` request with empty body ``{}``, you should receive
|
|
echo with defaults filled-in.
|
|
|
|
.. _python-jsonschema docs: https://python-jsonschema.readthedocs.io/en/latest/faq/#why-doesn-t-my-schema-that-has-a-default-property-actually-set-the-default-on-my-instance
|