add json schema faker fill properties param #2355
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.
Addresses #2046
Summary
In an effort to make it easier to set the json schema faker
fillProperties
to false, without having to modify individual schemas, a new cli parameter has been added for mocking.With this change you can now run
prism mock -d --json-schema-faker-fillProperties=false api.oas3.yaml
to ensure additional properties that are not explicitly named in your spec aren't returned when mocking. Setting this value with the command line will take priority over the value set inx-json-schema-faker
Additional Background
When using dynamic mocking, if
additionalProperties
is not set on eachproperties
in a schema, json schema faker will fill in additional properties due to Prism's current global setting forfillProperties
being set to true.Adding a
x-json-schema-faker
object at the top level of your schema allows you to change Prism's global settings per schema if you don't want to set it at the cli level. See documentation for further detailsChecklist
Screenshots
If applicable, add screenshots or gifs to help demonstrate the changes. If not applicable, remove this screenshots
section before creating the PR.
Additional context
Add any other context about the pull request here. Remove this section if there is no additional context.