Repository navigation
Add a minimal OpenAPI spec builder and use it in TagMetadataTests - #4664
Merged
Merged
Conversation
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>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4664/ |
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
approved these changes
Nov 4, 2026
Mpdreamz
left a comment
Member
There was a problem hiding this comment.
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.
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.
TagMetadataTestsnow builds 19 of its 20 inline OpenAPI specs with a smallMinimalSpecbuilder 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
MinimalSpecdescribes the operations, tags, tag groups, title, version and response text, andToJson()returns a JSON string. Tests pass that string toCreateGeneratorWithSpecAsyncexactly 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
externalDocsstays 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 lintThe test run reports 1,408 tests: 1,407 passed and 1 skipped, the same as
main.