protoc-gen-foravocab

command
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Command protoc-gen-foravocab is a buf/protoc plugin that reads the FORA vocabulary options off every annotated field and enum value and emits, per axis and per SDK language (Go, TypeScript, Python), a typed package/module with one string constant per registered token, an All/ALL collection, and an IsRegistered/isRegistered/is_registered membership check.

Two pairs of options carry the data, one pair per descriptor kind — the repeated tokens and the scalar generated-package name:

  • (fora.v1.vocab) / (fora.v1.vocab_package) — FieldOptions extensions 50001/50003, on fields whose axis is the field itself (Pricing.unit, Quota.metric).
  • (fora.v1.vocab_enum) / (fora.v1.vocab_enum_package) — EnumValueOptions extensions 50002/50004, on enum values that SELECT an axis (RestrictionKind values select the function / geography / user-type token lists carried in Restriction.permitted/prohibited).

Everything — the tokens AND the target package name — is authored in exactly one place, the options on the field or enum value, so the generated constants, the membership check, and the package layout all derive from the proto and cannot drift. There is no hand-maintained axis→package table in this plugin. The plugin reads the options STRUCTURALLY (it does not parse CEL).

A generic plugin binary does not have fora.v1's extensions registered in its global proto registry, so reading options through the global registry would silently miss them. To read them, the plugin builds a dynamicpb-backed extension resolver from the FileDescriptorProtos carried in the CodeGeneratorRequest and re-parses each descriptor's raw options bytes through that resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL