Skip to content

Add JSON schema envelope and normalize all output fields#289

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
json-schema-envelope
Jun 25, 2026
Merged

Add JSON schema envelope and normalize all output fields#289
AndreyVMarkelov merged 1 commit into
masterfrom
json-schema-envelope

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add ok, schema_version, and command fields to every JSON response (success and error)
  • Remove omitempty from operation result fields — status/kind default to "unknown", input/result default to {}
  • Add explicit status constants for account (found), du (reported), version (reported), rm (deleted/permanently_deleted), cp (copied), mv (moved)
  • Publish formal JSON Schema files under docs/json-schema/v1/ with contract tests validating them
  • Validate error schema code enum matches all defined error code constants
  • Assert every command schema has at least one non-unknown status

Test plan

  • All existing tests pass
  • TestPublicJSONSchemaFiles validates schema files match code (required fields, properties, const values, error code enum)
  • TestStructuredOutputGoldenSchemaAudit validates updated schemas with new envelope fields and explicit statuses
  • TestStructuredOutputGoldenSuccessOutputAudit validates updated golden examples with envelope
  • TestRenderCommandErrorWritesJSONErrorToStdout verifies schema_version and command on errors
  • TestRenderJSONOperationOutput verifies ok/schema_version/command on success
  • TestNewJSONOperationResultNormalizesEmptyFields verifies unknown defaults
  • assertGoldenCommandStatuses ensures no command has empty or "unknown" status list
  • gofmt, go vet, golangci-lint all pass

Stamp ok, schema_version, and command on JSON success and error envelopes. Normalize operation results so status, kind, input, and result are always present, with explicit statuses for account, du, version, rm, cp, and mv.

Publish top-level JSON schema files, validate schema/error-code drift in contract tests, forbid unknown result statuses in command schemas, and document partial-success behavior for recursive and multi-target commands.
@AndreyVMarkelov AndreyVMarkelov merged commit 0e82916 into master Jun 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant