feat: add field descriptions, JSON Schema output, and review fixes - #9
Conversation
Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Implements AST-based parser that walks Go source files and returns []EventSpec values from structs annotated with the asyncapi sentinel blank field pattern. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Remove unreachable `if field.Names != nil` guard in extractEventSpec and replace string-concatenated temp path with filepath.Join in test. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Implements BuildDoc() converting []EventSpec to an AsyncAPIDoc model with channels, send/receive operations, CloudEvents envelope schemas, data schemas, and NATS JetStream bindings. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Adds missing assertion to TestBuildDoc_Operations verifying that the receive operation carries an empty NATS stream (binding is send-only). Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Implements WriteYAML to marshal AsyncAPIDoc to disk with SPDX header and 0o644 permissions. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Replaces the stub main.go with the full CLI entry point that wires ParseFile, BuildDoc, and WriteYAML together. Adds the go:generate directive and asyncapi sentinel tag to events/events.go, and commits the generated api/events/asyncapi.yaml. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Adds generate, asyncapi-lint, and an expanded check task to Taskfile.yml. Fixes NATS binding: stream name moved to x-stream extension (valid per AsyncAPI spec extensions), bindingVersion set to 0.1.0 (was "latest"). Adds nolint directives for gosec G306 on intentional 0o644 file writes. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Extends BuildDoc and the asyncapi-gen CLI with optional -description, -license, -contact-name, and -contact-url flags. Updates the go:generate directive in events/events.go and regenerates api/events/asyncapi.yaml with the full metadata matching the original hand-authored file. Assisted-by: Claude (Anthropic, Claude Sonnet 4.6) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
Add asyncapi-field struct tag for field-level descriptions in generated AsyncAPI and JSON Schema output. Add standalone JSON Schema generation (Draft 2020-12) to api/events/schemas/ for downstream consumer validation. Fix source-of-truth messaging in README, go:generate description, and Taskfile @asyncapi/cli version pin. Changes: - Add Description field to FieldSpec, extracted from asyncapi-field tag - Add jsonschema.go with BuildDataJSONSchema, BuildEnvelopeJSONSchema - Add -schemas-dir CLI flag to asyncapi-gen - Add drift detection integration test for JSON Schema files - Update README to document code-first direction and dev workflow - Fix go:generate description to say spec is generated, not authoritative - Pin @asyncapi/cli@2.16.1 in Taskfile (latest has broken npm dep) Assisted-by: Claude (Anthropic, Claude Opus 4.6) Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
|
@jpower432 this PR depends on merge of PR #8. There were only a couple updates made so the diff between this PR and #8 is relatively small. The JSON Schemas for the envelope and the data are included in this PR (mentioned on Issue #430 here). |
Wire the existing Taskfile asyncapi-lint task into CI so a malformed spec fails on push/PR to main. Satisfies the DoD requirement for automated schema validation via GitHub Actions (ADR-0022). Assisted-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
Document how event contracts evolve without breaking subscribers: version lives in the CloudEvents type and AsyncAPI info.version, the NATS subject stays a stable wildcard address. Cites ADR-0019..0022. Add README pointer under Development. Assisted-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
Address review council findings from code review: - Extract run(opts Options, stdout, stderr io.Writer) error from main() to satisfy AP-002/AP-003 conventions and eliminate CRAP 132 score - Add main_test.go with 6 test cases covering all error paths - Reduce parseAsyncAPITag complexity from 22 to ~10 via struct-slice validation replacing switch-in-loop pattern - Add table-driven tests for goTypeToJSONSchema (11 cases, all branches) - Add buildServers edge case tests (valid URL, malformed, empty) - Add tests for channelName, humanTitle, upperFirst helpers - Add malformed param test and error content assertion for parser - Rename title2 to upperFirst for clarity - Add os.MkdirAll to WriteYAML for resilience on fresh checkouts - Pin Task to 3.40.1 and add setup-node@v4.4.0 in CI for reproducibility - Add CI workflow header comment per CI-011 Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
🔴 Review Council: REQUEST CHANGES
Reviewed at commit TL;DR: Solid, well-tested generator work; 25 verified issues remain, mostly silent generator failures, duplicated sources of truth, and shallow tests. Changes requested. Findings: 🔴 0 Critical, 🟠 0 High, 🟡 17 Medium, 🔵 8 Low
🟡 MEDIUM (17)
🔵 LOW (8)
Produced by Review Council, an open-source multi-persona code reviewer. Spot a wrong call or want the source? File feedback or browse the repository. |
Address HIGH and MEDIUM findings from the review council:
Architect (HIGH):
- Extract DocMeta struct for BuildDoc, replacing 8 positional string
parameters with a named struct per AP-001
SRE/Operator + Tester (HIGH/MEDIUM):
- Add -race -count=1 to Taskfile.yml test task and ci_test.yml per
TC-005 convention
Adversary + Tester (MEDIUM):
- Replace string concatenation with filepath.Join in main_test.go
per SC-003 convention
Code fixes (MEDIUM):
- Error on colonless asyncapi tag segments instead of silent continue
- Handle []slice types as array in goTypeToJSONSchema
- Use envelopeSchemaName() helper instead of inline TrimSuffix
- Fix humanTitle to handle empty-after-trim edge case
- Add $comment provenance marker to generated JSON Schema files
- Restore before sealing lifecycle detail in send operation summary
- Inline writeTestFile/writeFileForTest test helpers (single caller)
- Eliminate hardcoded metadata in integration test by parsing
go:generate directive flags from events.go
Test improvements:
- Add TestParseFlags_AllFlags and TestParseFlags_Defaults unit tests
- Add TestSplitArgs table-driven tests covering quoted strings,
escape sequences, and edge cases
- Add TestRun_SchemaWriteError for untested error path
- Add colonless tag segment error test for parser
- Add []string, []*int, interface{} cases to goTypeToJSONSchema table
- Fix misplaced edge-case comment in TestChannelName
- Add Data edge case to TestHumanTitle table
Documentation:
- Add full asyncapi tag grammar, no-comma constraint, and example to
README Adding a new event type section
- Add prerequisites (Go, Task, Node.js) to README Development section
- Update versioning.md breaking procedure to mention asyncapi tag type
- Add pre-1.0 stability note to versioning.md
- Update Taskfile generate desc to include JSON Schemas
Deferred (noted for follow-up):
- Move business logic from cmd/ to internal/ (Architect HIGH)
- npm supply chain mitigation for npx (SRE HIGH)
- Field examples support (example: key in asyncapi-field tag)
Assisted-by: Claude (Anthropic, Claude Opus 4.6)
Signed-off-by: Hannah Braswell <hbraswel@redhat.com>
@trevor-vaughan updated with review feedback in latest commits. |
Summary
Extends the
asyncapi-gentool with field descriptions, standalone JSON Schema output, CI validation, versioning policy, and review-driven quality improvements.Changes
asyncapi-fieldstruct tag for carrying field-level descriptions into generated AsyncAPI and JSON Schema outputapi/events/schemas/for downstream consumer validation (envelope + data schemas)ci_asyncapi.ymlworkflow validating the generated AsyncAPI spec via@asyncapi/clion push and PR to main. Actions pinned by SHA, Node.js and Task versions pinned for reproducibility. The proposed arduino/setup-task action introduces an unnecessary dependency that expands to a singlenpxcommand. The action call is replaced by thenpxcommand and can be adjusted if necessary based on discussion.docs/versioning.mddefining the four-layer event versioning strategy (NATS subject, CloudEvents type, AsyncAPI info.version, CloudEvents specversion) with decision rules for additive vs breaking changesrun(opts Options, stdout, stderr io.Writer) errorfrommain()per AP-002/AP-003 conventions. Addmain_test.gowith 6 test cases covering all error paths (CRAP score reduced from 132 to testable).parseAsyncAPITagvalidation from switch-in-loop to struct-slice iteration (complexity ~10 vs 22)goTypeToJSONSchema(11 cases, all branches),buildServersedge cases (valid/malformed/empty URL),channelName,humanTitle,upperFirsthelpers, malformed param error path, and error content assertionsos.MkdirAlltoWriteYAMLfor fresh checkout safety, matchingWriteJSONSchemaspattern@asyncapi/cli@2.16.1in Taskfile (latest has broken npm dependency)Related Issues
Review Hints
go test ./...)golangci-lint run— 0 issuesapi/events/schemas/are deterministic — drift detection integration tests verify byte-identical output951376eupdates the channel and data descriptions for readability based on the existing functionality in PR 8.