main
main copied to clipboard
feat: extract example from schemas
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:
- When using
allOf
, all schemas inside of it must have anobject
type, otherwise examples are not generated - The
pattern
property (typestring
) is not yet supported, example just resolves to"string"
.
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.