Skip to content

Add typed JSON output to doc fetch - #8797

Open
isaacroldan wants to merge 1 commit into
mainfrom
codex/doc-fetch-json
Open

isaacroldan wants to merge 1 commit into
mainfrom
codex/doc-fetch-json

Conversation

@isaacroldan

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

doc fetch prints Markdown or saves a file, but scripts cannot request a typed result or discover its schema.

WHAT is this pull request doing?

Add --json and schema discovery. Keep document retrieval separate from presentation, preserve the default Markdown output, and return a file receipt after a successful write. The output file still contains the original Markdown.

Both examples show the same document excerpt; the remaining Markdown is omitted.

Default output:

---
title: Shopify CLI

JSON output:

{
  "document": {
    "url": "https://shopify.dev/docs/api/shopify-cli",
    "content": "---\ntitle: Shopify CLI\n"
  }
}

Validation: 36 focused tests, build, type-check, and lint pass. Live command checks and adversarial review cover stdout/stderr, file bytes and receipts, schema discovery, and failure exits.

How to manually test your changes?

pnpm shopify doc fetch --url https://shopify.dev/docs/api/shopify-cli
pnpm shopify doc fetch --url https://shopify.dev/docs/api/shopify-cli --json
pnpm shopify doc fetch --url https://shopify.dev/docs/api/shopify-cli --output ./shopify-cli.md --json
pnpm shopify doc fetch --json-schema

Compare the inline Markdown with the JSON document. For file output, check the receipt on stdout and the Markdown in shopify-cli.md.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • Added a minor changeset for the new JSON flag.

@isaacroldan
isaacroldan requested review from a team as code owners October 6, 2026 13:17
@isaacroldan isaacroldan mentioned this pull request Oct 6, 2026
1 of 4 tasks
@isaacroldan
isaacroldan added this pull request to stack #8799 October 6, 2026 13:18
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 6, 2026
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@Suleimanlatrsh Suleimanlatrsh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tophatted locally, default / --json / --output / --language all look good and the saved file matches the JSON content exactly. Nice split between fetching and printing, much easier to follow. Couple things:

  • needs a rebase, conflicts with #8790 in json-output-command-exceptions.js
  • not from this PR, but --output docs/ (a folder) comes back as type: "bug" with a stack trace instead of an abort. Same if the parent is a file. The write-failure test only checks for error, so it'd be nice to assert the type there. Fine as a follow-up

}

outputResult(body)
return {document: {url, content: await response.text()}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: shopify.dev redirects a lot (/docs/api/admin lands on /docs/api/admin-graphql) and this returns the URL that was passed in, not where we ended up. Would response.url be more useful here so scripts get the real page? Fine either way since the schema says "requested" URL

@isaacroldan
isaacroldan force-pushed the codex/doc-fetch-json branch from ba8a795 to 06f6a6b Compare October 7, 2026 16:01
@isaacroldan
isaacroldan added this pull request to the merge queue Oct 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants