Skip to content

feat: auto generate jsonschema for public usage - #70

Open
thisisibrahimd wants to merge 3 commits into
OpenSLO:mainfrom
thisisibrahimd:gen-jsonschema
Open

thisisibrahimd wants to merge 3 commits into
OpenSLO:mainfrom
thisisibrahimd:gen-jsonschema

Conversation

@thisisibrahimd

Copy link
Copy Markdown
  • created go script to auto gen jsonschema from go structs with a bit of massaging to add more context for all slo versions v1alpha to v2alpha.
  • stored generated jsonschema files in docs/jsonschema/.
  • updated Makefile target to include jsonschema generation.

Add internal/cmd/jsonschema generator using invopop/jsonschema with
Go comment extraction. Produces 16 schema files across v1alpha, v1,
and v2alpha versions.

Custom JSONSchema() methods handle tricky types:
- DurationShorthand: string with pattern ^[0-9]+[mhdwMQY]$
- Label (v1): oneOf string/array
- Union types (SLOAlertPolicy, AlertPolicyCondition,
  AlertPolicyNotificationTarget): inline oneOf schemas

Wire into Makefile via generate/jsonschema target.
@thisisibrahimd

Copy link
Copy Markdown
Author

updated this branch with new go comments from pr #66
jsonschema now have description for almost all schemas.

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