Skip to content

fix(api-reference): convert flow-style YAML to JSON on download - #10545

Merged
hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/flow-yaml-json-download
Oct 8, 2026
Merged

hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/flow-yaml-json-download

Conversation

@charan-rathore

@charan-rathore charan-rathore commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

The public downloadDocument helper treated any input beginning with { or [ as JSON. Flow-style YAML could therefore be downloaded unchanged with a .json extension and application/json MIME type.

For example, this complete OpenAPI document is valid YAML:

{openapi: 3.1.0, info: {title: Test, version: 1.0.0}, paths: {}}
import { downloadDocument } from '@scalar/api-reference/helpers'

await downloadDocument(
  '{openapi: 3.1.0, info: {title: Test, version: 1.0.0}, paths: {}}',
  'openapi',
  'json',
)

Before this change, the downloaded content remained YAML and failed JSON.parse. The helper now verifies JSON by parsing it, so flow-style YAML is converted to valid JSON when JSON is requested. Downloads that need no format conversion preserve their original content.

Ticket

Fixes #10541

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: be95d57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@scalar/api-reference Patch
@scalarapi/docker-api-reference Patch
@scalar/aspire Patch
@scalar/aspnetcore Patch
@scalar/aws-lambda Patch
@scalar/azure-functions Patch
@scalar/fastify-api-reference Patch
@scalar/java-integration Patch
@scalar/nuxt Patch
scalar_api_reference Patch
@scalar/api-reference-react Patch
@scalar/server-side-rendering Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hanspagel
hanspagel force-pushed the fix/flow-yaml-json-download branch from 35c0cbe to c55dadc Compare October 8, 2026 08:52
@hanspagel
hanspagel enabled auto-merge (squash) October 8, 2026 08:53

@hanspagel hanspagel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks

@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 08:55 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 08:55 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 08:55 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 08:55 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 08:55 — with GitHub Actions Inactive
downloadDocument detected JSON with a brace/bracket heuristic, so
flow-style YAML starting with { or [ was exported unchanged when JSON
was requested. Detect JSON by parsing instead, and fall back to the
YAML path for flow-style documents.

Fixes #10541

Signed-off-by: Charan Rathore <[email protected]>
@hanspagel
hanspagel force-pushed the fix/flow-yaml-json-download branch from c55dadc to be95d57 Compare October 8, 2026 09:54
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 09:57 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 09:57 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 09:57 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 09:57 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 8, 2026 09:57 — with GitHub Actions Inactive
@hanspagel
hanspagel merged commit 7e8e190 into scalar:main Oct 8, 2026
31 checks passed
@charan-rathore
charan-rathore deleted the fix/flow-yaml-json-download branch October 8, 2026 10:03
@scalar-release-bot scalar-release-bot Bot mentioned this pull request Oct 8, 2026
charan-rathore added a commit to charan-rathore/charan-rathore that referenced this pull request Oct 8, 2026

This branch was previously deployed

1 inactive deployment
production-netlify — be95d571 Deployed Oct 8, 2026 by hanspagel via test-cdn-snapshots #3335
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.

downloadDocument exports flow-style YAML unchanged as JSON

2 participants