Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extract example from schemas #492

Open
wants to merge 5 commits into
base: release
Choose a base branch
from

Conversation

vonBrax
Copy link

@vonBrax vonBrax commented Mar 18, 2024

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 an object type, otherwise examples are not generated
  • The pattern property (type string) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants