Repository navigation
Conversation
…hemas All 22 inline specs in UnionVariantTests have no operations and repeat the same scaffold around their schemas. TestSpecs.WithSchemas supplies the scaffold and takes the schemas as raw JSON, which stay in the test because they are what it checks. Before the specs were replaced, a throwaway test compared the wrapper's output with each of the 19 non-interpolated originals key by key and in order. The 3 interpolated specs only interpolate inside their schemas, so they move unchanged. The test count is unchanged. 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/4665/ |
This branch was successfully deployed
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.
UnionVariantTestsnow builds its 22 schema-only OpenAPI specs with a newTestSpecs.WithSchemashelper, so each test shows only the schemas it checks. The file shrinks by 129 lines, the helper adds 15, and the test count does not change.Affects: Internals only
Prompt summary: Pilot a wrapper for the schema-only specs on one file. The earlier minimal-spec builder showed that most remaining inline specs have no operations and are mostly schema JSON, so they need a different, smaller helper.
Why
All 22 inline specs in the file have no operations. Each repeats the same nine lines of scaffold (version, info, empty paths,
components,schemas) around the schemas, which are the only part the test is about. The 64 schema-only specs across the API Explorer tests do the same.What
The helper
WithSchemastakes the schemas as raw JSON and returns the full spec as a JSON string. Tests pass that string on exactly as before. The schemas stay as JSON in the test, since they are the input being checked, and the parameter is marked as JSON so editors still highlight it. The OpenAPI version is an optional argument, used by the two specs that need 3.1.0.How the conversion was checked
Before any spec was replaced, a throwaway test compared the helper's output with each of the 19 plain originals, key by key and in order. All 19 matched. That test is not committed. The 3 interpolated specs only interpolate inside their schemas, which move unchanged, so their own tests are the check.
Out of scope: The other files with schema-only specs, which are
ApiBodyContentTests,AllOfCompositionTests,SharedListingTests,NullableTestsandMultiTypeTests. By this file's ratio they could save roughly another 250 lines in total; that is an estimate, not a measurement.Verify
dotnet test --project tests/Elastic.ApiExplorer.Tests ./build.sh lintThe test run reports 1,408 tests: 1,407 passed and 1 skipped, the same as
main.