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

add json schema faker fill properties param #2355

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

brendarearden
Copy link
Contributor

@brendarearden brendarearden commented Aug 10, 2023

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 in x-json-schema-faker

Additional Background
When using dynamic mocking, if additionalProperties is not set on each properties in a schema, json schema faker will fill in additional properties due to Prism's current global setting for fillProperties 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 details

Checklist

  • The basics
    • I tested these changes manually in my local or dev environment
  • Tests
    • Added or updated
    • N/A
  • Event Tracking
    • I added event tracking and followed the event tracking guidelines
    • N/A
  • Error Reporting
    • I reported errors and followed the error reporting guidelines
    • N/A

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.

@brendarearden brendarearden force-pushed the fix/2046-mock-contains-random-fields branch from 62443cd to 4543a1a Compare August 11, 2023 18:04
@brendarearden brendarearden marked this pull request as ready for review August 11, 2023 19:36
@brendarearden brendarearden requested a review from a team as a code owner August 11, 2023 19:36
@brendarearden brendarearden requested review from EdVinyard and removed request for a team August 11, 2023 19:36
@brendarearden brendarearden marked this pull request as draft August 11, 2023 19:43
@brendarearden brendarearden force-pushed the fix/2046-mock-contains-random-fields branch from 4543a1a to b9456cc Compare August 11, 2023 19:48
Copy link
Contributor

@EdVinyard EdVinyard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only questions and minor suggestions; feel free to use them or ignore them.

packages/cli/src/commands/mock.ts Show resolved Hide resolved
packages/cli/src/extensions.ts Show resolved Hide resolved
packages/cli/src/util/createServer.ts Show resolved Hide resolved
packages/cli/src/util/createServer.ts Outdated Show resolved Hide resolved
@brendarearden brendarearden force-pushed the fix/2046-mock-contains-random-fields branch from b9456cc to 2158588 Compare August 11, 2023 21:14
@brendarearden brendarearden marked this pull request as ready for review August 11, 2023 21:17
@brendarearden brendarearden force-pushed the fix/2046-mock-contains-random-fields branch from 2158588 to cb4d64e Compare August 14, 2023 23:11
@brendarearden brendarearden merged commit 4c19204 into master Aug 15, 2023
6 checks passed
@brendarearden brendarearden deleted the fix/2046-mock-contains-random-fields branch August 15, 2023 15:02
@chohmann chohmann mentioned this pull request Aug 17, 2023
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

3 participants