Repository navigation
Generate deterministic, indented OpenAPI JSON - #1699
Closed
Wassim Chegham (manekinekko) wants to merge 1 commit into
Closed
Wassim Chegham (manekinekko) wants to merge 1 commit into
Wassim Chegham (manekinekko) wants to merge 1 commit into
Conversation
Share canonical serialization between website generation and snapshot enforcement, preserve array order, and cover stable output and localized diffs. Regenerate the website artifact without changing its parsed content. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Wassim Chegham (manekinekko)
requested a review
from Cedric Vidal (cedricvidal)
as a code owner
November 23, 2026 16:23
Test Results (Node.js 22)test: Run #619
🎉 All tests passed! |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the deterministic OpenAPI artifact serialization change.
No open issues 🎉
What changed in this PR
Addresses #1685 by making Scope’s generated website OpenAPI JSON readable and deterministic, reducing diff churn from small schema changes without changing runtime API serialization.
Changes:
- Adds a shared serializer with stable recursive object-key ordering, two-space indentation, LF line endings, and one trailing newline while preserving array order.
- Uses the serializer for generation and snapshot enforcement, with regression tests for determinism, input preservation, and localized diffs.
- Documents the generated-artifact format and refresh contract.
| File | Description |
|---|---|
website/README.md |
Documents deterministic output in refresh instructions. |
docs/architecture/app-design.md |
Defines the shared artifact serialization contract. |
apps/api/src/openapi/serialize.ts |
Implements stable, indented OpenAPI serialization. |
apps/api/src/openapi/serialize.test.ts |
Tests formatting, determinism, preservation, and localized diffs. |
apps/api/src/openapi/generate.ts |
Writes the website specification using the shared serializer. |
apps/api/src/openapi-snapshot.test.ts |
Enforces artifact formatting and repeatable generation. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The committed website OpenAPI specification was a single minified line, so even small API changes replaced the entire document in diffs.
Use a shared serializer for generation and website-file snapshot enforcement: deterministic recursive object-key ordering, two-space indentation, LF line endings, and exactly one trailing newline. Arrays retain their original order. Focused regressions cover insertion-order independence, unchanged inputs/content, and a one-line schema-description diff.
The regenerated artifact is a one-time formatting migration. Its parsed OpenAPI content is unchanged, and runtime API behavior is unaffected.
Fixes: #1685
Demos
N/A - generated-artifact formatting, no Portal/CLI interaction changes.
Before
N/A - the generated specification was one minified line.
After
N/A - the specification is indented with stable keys; small schema changes produce localized line diffs.
Testing
Validation used the available supported Node runtimes after restoring locked dependencies; the default Node 20.18.0 could not start the installed Vitest.
pnpm exec vitest run apps/api/src/openapi/serialize.test.ts apps/api/src/openapi-snapshot.test.ts apps/api/src/openapi/openapi.test.ts- passed, 40 tests across 3 files using Node 22.21.1.pnpm --filter api exec tsc --noEmit- passed.pnpm --filter api generate:openapi- passed after building the telemetry prerequisite withpnpm --filter telemetry build; repeated generation produced byte-identical bytes.assert.deepStrictEqualcomparison of parsed regenerated JSON againstgit show HEAD:website/src/openapi/scope-openapi.jsonbefore committing - passed, no schema-content changes.npx --yes pnpm@10.29.1 testfromwebsite/- passed, 22 tests.npx --yes pnpm@10.29.1 buildfromwebsite/- blocked by an existing tooling path-encoding issue: the schema resolver converts this worktree's~~into%7E%7Eand cannot open the file. The same command passed against an identical temporary copy of the website sources in a path without those characters, building 227 pages. Temporary copy removed afterward.git diff --check- passed.Documentation and compatibility
Updated the generated-artifact contract in
docs/architecture/app-design.mdand the refresh instructions inwebsite/README.md.Breaking changes: None. No API/CLI, dependency, database, or runtime serialization changes. No upgrade steps; the initial generated-file formatting diff is expected.
Checklist
up()/down()and keep it CosmosDB-compatible. N/A - no database changes.NOTICE/NOTICE-REVIEW.txtwithpnpm noticeas needed. N/A - dependencies and lockfiles unchanged.