flutter_api_contract 0.1.1
flutter_api_contract: ^0.1.1 copied to clipboard
Catch drift between your Dart/Flutter models and the backend's OpenAPI or Swagger schema before it crashes in production.
Changelog #
0.1.1 #
Fewer false positives on generated (NestJS) specs.
- A bare
{"type": "object"}(noproperties,additionalProperties,$refor composition), which@nestjs/swaggeremits forstring | nulland unknown types, is now "any": never atype-mismatch. - Enums whose own parser ends in a default constant (
raw == 'A' ? E.a : E.b, a finalreturn E.b;) count as having a fallback, and parsers that upper/lower-case the input match schema values case-insensitively.enum-unhandledwith a fallback is now info, not warning. - Reads guarded by a check on the same key (
json['x'] is Map ? ... : json['x'] as String?,json['x'] != null && ...,if (json['x'] is Map) {...}) no longer reportnullable-mismatch/type-mismatch, including the implicit parent-map reads. - Pairing: schemas only used as request bodies are never matched to a model;
XResponseprefersXResponseDtooverXDto; a name match covering under half of a model's keys is replaced by a schema holding at least 90% of them, else its missing keys drop to info. New info findingambiguous-matchexplains either case.
0.1.0 #
First release.
- Reads OpenAPI 3.0 / 3.1 and Swagger 2.0 specs, JSON or YAML, from a file or a URL
(with
--headerfor protected docs). - Reads Dart models with
package:analyzer: hand-writtenfromJson(json['key'], casts,??, null guards, nestedjson['a']['b'], aliases, enums viavalues.byName/firstWhere(orElse:)),json_serializable(@JsonKey, class andbuild.yamlfield_rename, constructor defaults,unknownEnumValue, converters) andfreezed(@Default,@JsonKey, unions). - Pairs models with schemas by name (suffixes stripped), by explicit mapping or by endpoint
(
GET /me#data). - Findings:
missing-in-schema(with a rename suggestion),required-ignored,nullable-mismatch,type-mismatch,enum-unhandled,enum-extra,unmatched-model,unknown-schema. - Output as text, Markdown, JSON or GitHub annotations; exit code 1 on errors
(
--fail-on). - Shrink-only baseline (
--baseline,--update-baseline).