Generate examples with jsf (#1891)

Fixes https://github.com/spec-first/connexion/issues/1719 .

Builds on work of https://github.com/spec-first/connexion/pull/1718,
pulling in external library to provide the fake data from JSON schema.

Changes proposed in this pull request:

* Use JSF library to generate sample data for mocking APIs without
examples.
* Add this as a new extra dependency "mock"

See discussion on https://github.com/spec-first/connexion/pull/1870

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
This commit is contained in:
Mark Perryman
2024-03-20 21:27:14 +00:00
committed by GitHub
parent e56bc3b42c
commit e6ceb1fc0a
9 changed files with 231 additions and 59 deletions

View File

@@ -47,7 +47,10 @@ Running a mock server
---------------------
You can run a simple server which returns example responses on every request.
The example responses must be defined in the ``examples`` response property of the OpenAPI specification.
The example responses can be defined in the ``examples`` response property of
the OpenAPI specification. If no examples are specified, and you have installed connexion with the `mock` extra (`pip install connexion[mock]`), an example is generated based on the provided schema.
Your API specification file is not required to have any ``operationId``.
.. code-block:: bash