mocks-server / main

Node.js mock server running live, interactive mocks in place of real APIs
https://www.mocks-server.org
Apache License 2.0
281 stars 14 forks source link

feat: extract example from schemas #492

Open vonBrax opened 3 months ago

vonBrax commented 3 months ago

closes #471

This PR extends the openapi plugin functionality to also make it possible to extract example values from the openapi schemas (current behavior only looks for examples defined under the example or examples keys).

There are 2 limitations for the examples generation:

The current solution uses a custom logic to generate examples, but probably a better approach was to use the existing code from swagger to generate the expected example values (like in the swagger editor), but I couldn't find the part of the code responsible for the examples generation.

I would be more than happy to update this PR if anyone could point me in the right direction.