Skip to content

Add a schema-only spec wrapper and use it in UnionVariantTests - #4665

Open
akira28 wants to merge 1 commit into
mainfrom
test/schema-only-spec-wrapper
Open

akira28 wants to merge 1 commit into
mainfrom
test/schema-only-spec-wrapper

Conversation

@akira28

@akira28 akira28 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

UnionVariantTests now builds its 22 schema-only OpenAPI specs with a new TestSpecs.WithSchemas helper, 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

WithSchemas takes 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, NullableTests and MultiTypeTests. 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 lint

The test run reports 1,408 tests: 1,407 passed and 1 skipped, the same as main.

…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>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4665/

This branch was successfully deployed

2 active deployments
docs-preview — 524b0198 Deployed Nov 3, 2026 by github-actions[bot]
assembler-preview — 524b0198 Deployed Nov 3, 2026 by github-actions[bot]
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.

1 participant