Repository navigation
Read the OpenAPI version index through a domain model - #4899
Merged
Merged
Conversation
The API explorer now loads index.json into a VersionIndex record that keeps today's key order, and the two rules about its monikers live in VersionIndexConstraints. Nothing the build reports or renders changes: the rules run in the loader and their findings are not surfaced yet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4899/ |
The loader no longer turns a null anywhere in the index into a fetch error. The model keeps the null as written, so only a lookup that reaches it throws, and OpenApiGenerator reports that exception as before. Client tests pin both cases against the old behaviour. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 18, 2026
A JSON "version": null under a numeric moniker made the key-matches-version rule throw a NullReferenceException. Main resolves such an entry with a null version, so the rule now skips it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A null version under main or a numeric moniker still resolves on main, so the client keeps working; the model now says what is wrong with it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AutoTest runs every rule over generated legal indexes and proves each rule can fire. A second generator adds blank, case-variant, numeric-looking and null values and checks that no rule throws. AutoTest's counter-example search found that a null Repositories list made Equals, GetHashCode and AllMonikers throw, so they now treat it as empty like the inner records. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
The API explorer now reads the OpenAPI version index into a
VersionIndexrecord with named rules, and every rendered page, diagnostic and fetch stays the same.Affects: Internals only
Stack: 14 of 16 in the split of #4530, on top of the foundation #4888.
Why
The version index is parsed straight into nested dictionaries and has no declared rules, so what makes an index valid is implicit in the client's lookups. #4530 introduces a domain record, a loader and named rules for each config file. This PR does that for the version index only, as a pure refactor.
What
Domain record and rules
VersionIndex,VersionIndexRepository,VersionIndexSpecandVersionMonikerinElastic.Documentation.OpenApikeep every level in the order the index wrote it.VersionIndexConstraintsholds two rules: a moniker ismainor a major number (warning), and a key resolves to a version of its own major (error).Loader and client
VersionIndexLoaderin the API explorer declares oneLoader.Forover the existing JSON wire type.VersionIndexClientreads the response into text, loads it and looks monikers up on the record. Fetch errors, retry, the "declares no repositories" and "no entry for ..." messages keep their text.Configurationmakes its internals visible toElastic.ApiExplorerso the loader can useLoader.Tests
Constraint tests (examples plus a property over valid indexes), loader tests, two client tests that pin the written moniker order and that a rule-breaking index reports nothing, and a property test that the publisher's
VersionIndexBuilderoutput does not depend on key order.Deferred behaviour changes
A JSON null inside the index keeps failing where it does today: the model keeps it as written, and a lookup that reaches it throws
NullReferenceException, whichOpenApiGeneratorreports as "API '...' could not be generated". A null in an unrelated repository or spec has no effect. Two client tests pin this and pass unchanged against the base commit. Reporting a null as a parse error is deferred.VersionIndexPublisherrefusing to write an index that breaks a rule (keeps the openapi-index lambda free of the domain assembly).VersionIndexOrderConstraints): rules cannot live next to the builder outside the domain, so it is a property test here.Verify
No verified snapshot changed.
🤖 Generated with Claude Code
Golden compare
Local builds of the isolated docs, the prod assembler site and the codex example site, this branch against the base commit
a01a289a3(aggregate counts; the output stays local).The isolated build downloads live OpenAPI specs, so it is only comparable between captures taken back to back; these were. The codex build is nondeterministic on unchanged code: recaptures of the base commit differ from each other in
codex/index.htmland in one repository that has bothx.mdandx/index.md, which write the same output path.Found by generated data
version-key-matches-versionthrow (found by review, kept fixed; pinned byANullVersionOfARecognizedMoniker_IsAnErrorNotAThrowand covered by the hostile generator).VersionIndex.Equals,GetHashCodeandAllMonikersthrew on a nullRepositorieslist, which AutoTest's counter-example search builds. They now treat it as empty, like the inner records. The loader never produces it, so main's behaviour is unchanged (AnIndexWithNullRepositories_IsComparedAndWalkedAsAnEmptyOne).