Skip to content

fix: remove x-codeSamples so playground examples update live (#1015) (backport to release/1.17.0) - #1018

Merged
RiskeyL merged 1 commit into
release/1.17.0from
backport/release/1.17.0/pr-1015
Sep 1, 2026
Merged

fix: remove x-codeSamples so playground examples update live (#1015) (backport to release/1.17.0)#1018
RiskeyL merged 1 commit into
release/1.17.0from
backport/release/1.17.0/pr-1015

Conversation

@RiskeyL

@RiskeyL RiskeyL commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to release/1.17.0:

Hand-written x-codeSamples blocks on 11 endpoints replaced Mintlify's auto-generated request samples with static cURL, so the playground ignored typed values and offered no other language tabs. Headless-browser tests confirmed autogen now covers every case they were added for: multipart renders --form samples and typed values appear live in all snippet languages.

Remove all 33 blocks (en/zh/ja), invert the lint guard to flag any x-codeSamples occurrence, rewrite the spec-conventions rule, add a curl -N tip to the SSE streaming guide (the only content the removed samples uniquely carried), and link the guide from the Stream Workflow Events description.

(cherry picked from commit 236fcaa)
Copilot AI lite review requested due to automatic review settings September 1, 2026 05:19
@RiskeyL RiskeyL self-assigned this Sep 1, 2026

Copilot AI 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.

Pull request overview

This backport removes hand-written x-codeSamples from the Service API OpenAPI specs so Mintlify’s API playground can auto-generate request examples that update live as users type, and it adds supporting guidance + linting to prevent reintroduction.

Changes:

  • Remove x-codeSamples blocks from {en,zh,ja}/api-reference/openapi_service.json operations and add an inline link to the SSE streaming guide from the workflow events streaming endpoint description.
  • Add an SSE streaming guide tip in {en,zh,ja}/api-reference/guides/streaming.mdx recommending curl -N/--no-buffer.
  • Update tools/api-pipeline/lint_specs.py to flag any operation that includes x-codeSamples, and update the API reference spec conventions accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
en/api-reference/openapi_service.json Removes x-codeSamples so the playground uses live auto-generated snippets; adds link to the SSE guide for streaming events.
zh/api-reference/openapi_service.json Same as English spec changes, localized link target.
ja/api-reference/openapi_service.json Same as English spec changes, localized link target.
en/api-reference/guides/streaming.mdx Adds a Tip about using curl -N/--no-buffer for real-time SSE output.
zh/api-reference/guides/streaming.mdx Adds the corresponding translated Tip.
ja/api-reference/guides/streaming.mdx Adds the corresponding translated Tip.
tools/api-pipeline/lint_specs.py Changes linting behavior to forbid x-codeSamples on operations.
.claude/skills/dify-docs-api-reference/references/spec-conventions.md Updates the written convention around x-codeSamples usage/removal.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 164 to +166
## x-codeSamples

Mintlify's playground auto-generates request samples from the schema; do not duplicate it. Add a hand-written `x-codeSamples` entry only where autogen fails: `multipart/form-data`, binary bodies, and SSE consumption. House format: `{"lang": "bash", "label": "cURL", "source": "curl --request …"}` with `{api_base_url}`, `{api_key}`, `{user}` placeholders. Code samples are identical across languages.
Do not add `x-codeSamples`; `lint_specs` flags any occurrence. A hand-written sample replaces Mintlify's generated snippets for the whole operation: the playground stops reflecting typed values, and readers lose every language tab but the one provided. Autogen handles all body types — `multipart/form-data` renders as `--form`, typed values appear live, and the pristine snippet draws from schema `default`s and the request-body example. A query parameter without a `default` is absent until typed; accept that gap rather than invent a `default` the API does not have. SSE consumption mechanics (curl's `--no-buffer`) live in the [SSE Streaming guide](/en/api-reference/guides/streaming).
@RiskeyL
RiskeyL merged commit 98e1bd8 into release/1.17.0 Sep 1, 2026
5 checks passed
@RiskeyL
RiskeyL deleted the backport/release/1.17.0/pr-1015 branch September 1, 2026 05:24
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.

2 participants