Skip to content

fix(cli): configure the json-schema-faker instance prism-http generates with - #2853

Open
enstulen wants to merge 2 commits into
stoplightio:mainfrom
enstulen:fix/faker-options-single-instance
Open

enstulen wants to merge 2 commits into
stoplightio:mainfrom
enstulen:fix/faker-options-single-instance

Conversation

@enstulen

@enstulen enstulen commented Sep 15, 2026

Copy link
Copy Markdown

Addresses #2683

Summary

prism-cli applied x-json-schema-faker options and --json-schema-faker-fillProperties to its own import of json-schema-faker. #2754 bumped only the CLI's dependency to 0.5.9 while prism-http stayed on 0.5.8, so npm installs two copies. The CLI has been configuring an instance the response generator never reads, and every faker option has been a silent no-op since 5.12 (Docker image, npm install, and the monorepo alike).

Visible symptom: prism mock -d --json-schema-faker-fillProperties=false still pads objects without additionalProperties: false with random lorem-ipsum properties such as "deserunt_f": "eu esse".

This moves option setting into prism-http next to resetGenerator and exports it as setJSONSchemaGeneratorOption. The CLI calls that instead of touching json-schema-faker directly, and its direct dependency on json-schema-faker is removed. A future version skew can no longer split the instances.

Verified with the built CLI against a real OpenAPI document: with the flag, responses contain exactly the declared properties across repeated calls; without it, the random extras still appear.

Checklist

  • The basics
    • I tested these changes manually in my local or dev environment
  • Tests
    • Added or updated
  • Event Tracking
    • N/A
  • Error Reporting
    • N/A

Additional context

New tests: packages/cli/src/__tests__/extensions.spec.ts (fails on main, passes here) covers x-json-schema-faker, the CLI parameter, and CLI precedence, all asserted against the generator prism-http uses. packages/http gains a fillProperties disabled case.

…es with

prism-cli set json-schema-faker options (x-json-schema-faker, the
--json-schema-faker-fillProperties flag) on its own import of
json-schema-faker. Since stoplightio#2754 bumped only the CLI's copy to 0.5.9 while
prism-http stayed on 0.5.8, two copies are installed and the CLI has been
configuring an instance the generator never reads. Every option, including
locale and fillProperties, was a silent no-op.

Move option setting into prism-http next to resetGenerator and export it as
setJSONSchemaGeneratorOption, so the CLI can only ever configure the instance
that generates responses. Drop the CLI's direct json-schema-faker dependency.

Closes stoplightio#2683
@enstulen
enstulen requested a review from a team as a code owner September 15, 2026 11:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T11:56:42.338322Z 6b02bf1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b02bf15a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/http/src/mocker/generator/JSONSchema.ts Outdated
Disabling fillProperties switched useDefaultValue on but re-enabling it
never switched it back, so a CLI override of a spec-level
fillProperties: false kept substituting schema defaults. Track the option
both ways, and leave useDefaultValue alone when the user set it explicitly.
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.

1 participant