feat(db): add examples
to metaschema fields
#11731
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces a new field attribute called
examples
in the metaschema. Theexamples
attribute is designed to provide example values for fields in schemas.examples
is an array so you can specify multiple example values for a single field.Adding examples would like this:
kong/db/schema/typedefs.lua
and
But also in plugin schemas, examples help illustrate what the data is supposed to look like.
For example:
kong/plugins/response-ratelimiting/schema.lua
for
redis_port
or
redis_password
Why
Improved automation
We've already invested in automation for generating API specs and the plugin configuration reference. The inclusion of example fields is a natural extension of this effort in my eyes. By providing concrete examples in the Lua schemas, we can generate more informative and accurate specs/docs automatically.
Communication
Examples illustrate what data should look like, this makes it easier for people to understand the intended structure and format of fields in our schemas.
Plugins
Currently, we offer descriptions, sometimes default values in our plugin configuration reference docs. We could add examples and sometimes we do within the description field, but that information grows stale. My theory is that providing accurate examples in the schemas, and subsequently in the docs, would help users onboard with plugins.