Schema and generator upgrades (prerequisite for write endpoints) #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Plan 6: Schema and generator upgrades (prerequisite for write endpoints)
Goal
Give
api.yamland the generator the knobs needed for the next batch of endpoints,and fix the generated type name prefix.
6a — Rename generated type prefix (do first, while surface is small)
Generated names like
GetTestParams,GetDomainModifyResultembed the HTTP method.That becomes wrong once POST endpoints exist.
Change: drop the method prefix from generated type names.
GetTestParams→TestParamsGetDomainModifyResult→DomainModifyResultGetQueryDomainListParams→QueryDomainListParamsFiles:
dmapi/api.go.template, thengo generate ./....No logic changes — pure rename.
6b — HTTP method per endpoint
Currently everything is GET. The template hardcodes
http.MethodGet.YAML addition:
Generator: already reads
Endpoint.Method; the template already has:So this is already wired — just start using it in api.yaml.
Audit: check
domain-modify,contact-create/modify/delete,ns-create/modify/delete,domain-register/renew/delete,dns-zone-put,grants-invite/revoke— all should be POST.6c — Enum param types
Some params accept only a fixed set of values (e.g.
status: production,privacy: basic|pro). Currentvalues.Stringaccepts anything.Option A (simple): add validation in YAML:
Generator emits a
Validate()that checks the set. Reuses the existingrequired[T]/Validate()pattern.Option B (skip for now): document the constraint in
help:text only.Simpler, fine for a first pass.
6d — Mutually exclusive param groups
query-whoisrequires exactly one ofdomain,contact,host.YAML addition:
Generator emits a group-level
Validate()on the Params struct.Only needed for
query-whois;query-objectis deprecated so skip it.6e — Endpoint aliases
ns-create=host-create,ns-modify=host-modify,ns-delete=host-delete.YAML addition:
Generator registers both names in
APICallspointing to the same*APICall.AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex