|
24 | 24 | - [Latency Profiles](#latency-profiles) |
25 | 25 | - [Inspecting and Clearing Latency](#inspecting-and-clearing-latency) |
26 | 26 | - [Code Generation](#code-generation) |
| 27 | + - [Partial-failure error generation](#partial-failure-error-generation) |
| 28 | + - [Version-Scoped Generation](#version-scoped-generation) |
| 29 | + - [Contributing Spec Fixes Upstream](#contributing-spec-fixes-upstream) |
| 30 | + - [Generation Guards](#generation-guards) |
27 | 31 | - [Demo](#demo) |
28 | 32 | - [Verification Matrix](#verification-matrix) |
29 | 33 | - [Individual Verifications](#individual-verifications) |
@@ -493,6 +497,44 @@ Version flags accept an optional operator prefix (`>=`, `>`, `<=`, `<`). When om |
493 | 497 |
|
494 | 498 | When items are excluded by version filtering, breadcrumb comments are left in the generated code explaining the reason (e.g., `// cat.masterPath: deprecated in OpenSearch 2.0.0 (treated as removed).`). Breadcrumb visibility is configurable per category via `-version-breadcrumb-*` flags. |
495 | 499 |
|
| 500 | +### Contributing Spec Fixes Upstream |
| 501 | + |
| 502 | +Most generated code defects are not generator bugs. The spec is the input, so a missing doc comment, a wrong type, or an absent version annotation usually has to be fixed in [`opensearch-api-specification`](https://github.com/opensearch-project/opensearch-api-specification) to benefit every language client. |
| 503 | + |
| 504 | +Missing doc comments are the common case. Generated types and fields carry the `description` from their schema, and the generator emits 3,060 of the 3,187 property descriptions the spec provides; the remainder simply have none upstream. To see the gaps: |
| 505 | + |
| 506 | +``` |
| 507 | +make report-missing-descriptions |
| 508 | +``` |
| 509 | + |
| 510 | +This generates into a temporary directory and prints a report to stderr, so the checked-in generated files are untouched. Output is grouped into types, struct fields, and string-enum members, with the spec component key in brackets: |
| 511 | + |
| 512 | +``` |
| 513 | + - SearchProcessorExecutionDetail [_core.search___ProcessorExecutionDetail] |
| 514 | + - ScrollResp.ProcessorResults json:"processor_results" [_core.search___SearchResponse] |
| 515 | +
|
| 516 | +SUMMARY: 1274 types, 3471 fields, 20 enum members; 4765 total |
| 517 | +``` |
| 518 | + |
| 519 | +The bracketed key is what to search for upstream. A gap is reported at both the reference site and the `$ref` target, so adding a description to one shared schema often resolves many lines at once. |
| 520 | + |
| 521 | +> **Editing `opensearch-openapi.yaml` locally.** The vendored spec may be edited for correctness (a wrong type, a missing required field), but changes are visible to every client generated from it, so renames and cosmetic edits belong upstream rather than here. Send a corresponding PR to `opensearch-api-specification` for anything kept locally. |
| 522 | +
|
| 523 | +### Generation Guards |
| 524 | + |
| 525 | +Two checks run before any file is written, so a regression aborts generation instead of landing in the tree. Each pins its permitted set in a reviewed, checked-in allowlist: |
| 526 | + |
| 527 | +| Guard | Allowlist | What it catches | |
| 528 | +| ------------------ | ------------------------------------ | --------------------------------------------------------------------- | |
| 529 | +| `json.RawMessage` | `cmd/osgen/rawmessage_allowlist.txt` | A type the generator could not resolve, widening the raw-JSON surface | |
| 530 | +| Duplicate JSON tag | `cmd/osgen/tagshadow_allowlist.txt` | A struct redeclaring a JSON tag its embedded type already carries | |
| 531 | + |
| 532 | +The duplicate-tag guard covers a defect nothing else catches. `encoding/json` resolves a duplicate tag at differing depths in favor of the shallower field, so an outer redeclaration wins and the embedded declaration is never populated -- which is how the per-hit search envelope (`_id`, `_seq_no`, `sort`) became unreachable. `go vet`'s `structtag` analyzer only checks duplicates within one struct, and `golangci-lint` relaxes generated files. |
| 533 | + |
| 534 | +When a guard fails, read the offender it names and decide whether the change is intended. If it is, add the entry with `-update-tagshadow-allowlist` (or `-update-raw-message-allowlist`) and review the resulting allowlist diff as part of the change: adding an entry asserts the shadow is deliberate. |
| 535 | + |
| 536 | +> **`make regen` deletes generated files before writing.** An aborted generation therefore leaves the tree empty. Recover with `git checkout -- opensearchapi/ plugins/ internal/`. |
| 537 | +
|
496 | 538 | See [`cmd/osgen/README.md`](cmd/osgen/README.md) for the full flag reference and subcommand details. |
497 | 539 |
|
498 | 540 | ## Lint |
|
0 commit comments