openapi_enum_patch 0.2.0
openapi_enum_patch: ^0.2.0 copied to clipboard
Give real names to the integer enums swagger_parser generates from OpenAPI, fill in the enum files it skips, and audit which enums still need naming.
Changelog #
0.2.0 #
- Added the
reorganizecommand: groups the flat modelsswagger_parseremits into per-namespace folders, routes enums into anenums/subfolder, and strips the now-redundant namespace prefix from type names — rewriting every relative import,partdirective, model URI and type reference across your sources. Cross-service name collisions keep their prefix so the result still compiles. Idempotent. - Namespace groups are derived from the schema keys via
RegistryBuilder.namespacePrefixes, so nothing has to be hard-coded; passgroupstoreorganizeModelsto override. - Breaking: the
--configand--overridesdefaults are nowswagger_parser.yamlandenum_overrides.yamlat the project root, instead of paths under aswagger_tools/folder. Pass-c/-oif your files live elsewhere.
0.1.0 #
Initial release.
patchcommand — synthesises the enum filesswagger_parserskips for query-parameter-only enums, and appliesenum_overrides.yamlto the rest.normalizecommand — rewrites{version}path templates to a concrete version and qualifies barecomponents.schemasnames with a namespace prefix, rewriting every matching$ref. Both passes are idempotent.auditcommand — reports integer enums with no override, overrides that do not name every value, and overrides naming values the schema dropped.--strictmakes a non-clean audit exit non-zero, for CI.- Library API —
RegistryBuilder,EnumAuditor,SchemaNormalizer,EnumPatcher— with anEnumEmitterinterface for non-dart_mappableback-ends. - Emitted compute helpers use the
dart_mappablemapper API (XMapper.fromValue,toValue()), which works whenenums_to_json: false.