Skip to content

Add a minimal OpenAPI spec builder and use it in TagMetadataTests - #4664

Merged
Mpdreamz merged 1 commit into
mainfrom
test/minimal-spec-builder
Nov 4, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
test/minimal-spec-builder

Conversation

@akira28

@akira28 akira28 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

TagMetadataTests now builds 19 of its 20 inline OpenAPI specs with a small MinimalSpec builder instead of 25-line JSON literals. The file shrinks by 389 lines, the builder adds 75, and the test count does not change.

Affects: Internals only

Prompt summary: Pilot the minimal-spec JSON builder from the ApiExplorer test refactor list on one file first. The goal is to prove the builder's shape before applying it to the other files that carry inline specs.

Why

Each test in the file repeats the same OpenAPI scaffold (version, info, GET operations with a 200 response) around the two or three lines it is about: the operations, the tags and the tag groups. The API Explorer tests hold 127 inline specs in 40 files. Only 33 of the 121 that parse have this shape (GET operations with a 200 response), and 19 of those are in this file. Most of the rest are schema-only specs, which this builder does not cover.

What

The builder

MinimalSpec describes the operations, tags, tag groups, title, version and response text, and ToJson() returns a JSON string. Tests pass that string to CreateGeneratorWithSpecAsync exactly as before, so the code after each spec is unchanged. It covers GET operations with a 200 response, which is all this file uses.

How the conversion was checked

Before any spec was replaced, a throwaway test compared the builder's JSON with each original, key by key and in order. All 19 matched. That test is not committed.

What stays as JSON

The one spec with a tag that carries externalDocs stays raw, since the builder does not model it.

Out of scope: The other files with inline specs. This PR only settles the builder's shape.

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.

Nineteen of the twenty inline OpenAPI specs in TagMetadataTests repeated the same scaffold around two or three lines that each test is about. MinimalSpec describes the operations, tags and tag groups and returns the same JSON, so the code after each spec is unchanged. Before the specs were replaced, a throwaway test compared the builder's output with every original key by key and in order. The one spec with a tag that carries externalDocs stays as raw JSON. The test count is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28
akira28 requested a review from a team as a code owner November 3, 2026 16:03
@akira28 akira28 added the chore label Nov 3, 2026
@akira28
akira28 requested a review from technige November 3, 2026 16:03
@akira28 akira28 added the chore label Nov 3, 2026
@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/4664/

@akira28

akira28 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@Mpdreamz @reakaleek let me know what you think about this approach, and if we agree we can expand to the rest of tests

@Mpdreamz Mpdreamz 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.

Reviewed the diff. Test-only: MinimalSpec produces the same OpenAPI shape the inline JSON had, and the test count is unchanged. Libra and CI are green.

@Mpdreamz
Mpdreamz merged commit 1203914 into main Nov 4, 2026
48 checks passed
@Mpdreamz
Mpdreamz deleted the test/minimal-spec-builder branch November 4, 2026 12:50
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.

2 participants