flap 0.0.7
flap: ^0.0.7 copied to clipboard
OpenAPI → Dart/Flutter client generator for 3.0, 3.1 and Swagger 2.0. Generates Freezed + json_serializable clients, no Java required.
Changelog #
All notable changes to this project will be documented in this file.
0.0.7 #
- Documentation only: README gains a table of contents and an author section. No generator changes; output is identical to 0.0.6.
0.0.6 #
Validated against the full Stripe OpenAPI document (419 paths, 594
operations, 1,454 schemas → ~11,000 generated files): build_runner and
dart analyze are clean for both backends.
Fixed #
- Nested objects are now serialised to maps (
@JsonSerializable(explicitToJson: true)on every generated factory). Previously form-encoded and multipart bodies with nested objects were sent asInstance of …. - OpenAPI parameter serialization is honoured:
style(form,deepObject,spaceDelimited,pipeDelimited) andexplodefor query parameters, and Swagger 2.0collectionFormat. Object-valued query parameters andapplication/x-www-form-urlencodedbodies use bracket keys (created[gte]=1,address[city]=…) as Stripe and most form APIs expect. - Untagged unions whose variant is an inline
enum(Stripe'senum: ['']"clear this field" pattern) no longer emitString.toJson(); the variant is a plainString. - Untagged-union deserialisation no longer triggers
unnecessary_castwarnings.
0.0.5 #
Fixed — generated code #
- Generated models now compile with
freezed3 /json_serializable6.9+: classes areabstract, unions aresealed, and every model imports the types its generated.g.dartneeds (including throughList<T>typedefs). - Enums no longer use the non-existent
@JsonEnum(unknownValue:); they are enhanced enums with avaluefield, anunknownfallback,fromJson/toJson, and@JsonKey(unknownEnumValue:)on every field that uses them. Enum values that are Dart keywords (new,default, …) or collide after case folding get safe, unique names. Optional<T?>tri-state PATCH fields work again: the class opts out of the freezed-generatedtoJson(@Freezed(toJson: false)) and emits one that omitsOptional.absent(); per-type converters replace the generic one thatjson_serializablerejects.package:httpclient: query/header map entries were emitted as bare${...}expressions (a syntax error); the client now builds anhttp.Requestfor every HTTP method, sends query/cookie API keys, setsContent-Typeonly for JSON bodies (multipart uploads work), and throws a typed<Client>Exceptionon non-2xx responses.- Both clients: path parameters are URI-encoded; enum parameters send their
wire value instead of
EnumName.value;DateTimeparameters are ISO 8601; cookie parameters are sent; optional request bodies no longer dereference null; required response headers are null-checked before parsing. - Untagged unions no longer import
package:flutterand expose a public<Name>Converter. - Array/map/alias typedef files import the types they reference.
- Field, parameter, method and class names are sanitised: reserved words
(
class,default,in,hashCode, …), dotted schema names (com.example.Pet), spaces and punctuation inoperationId/titles all produce valid Dart identifiers with@JsonKey(name:)mappings. - Client files import only the models they use;
dart:convertonly when needed.
Fixed — spec loading #
- Swagger 2.0 detection no longer depends on
swagger:being the first line; JSON documents load from disk; YAML merge keys are resolved. $refparameters, request bodies, responses and headers (#/components/...) resolve; path-levelparametersare merged.- Inline object schemas (properties, arrays of objects,
additionalPropertiesobjects) become named classes instead of aborting generation. - Root-level enum and primitive schemas are supported; free-form objects
(
type: object,{},additionalProperties: true) map toMap<String, dynamic>/dynamic;format: binarymaps toList<int>. nullable: true+allOf: [$ref], andoneOf/anyOfwith anullvariant, are recognised as nullable references.- HTTP
basicsecurity schemes are supported; unsupported schemes and non-scalar response headers produce warnings instead of failing the run. - Swagger 2.0: inline arrays/objects in definitions,
formData/fileparameters (→ multipart or form-urlencoded request bodies), globalparameters/responses,schemes,x-nullable, path-level parameters. - Duplicate parameter names across locations no longer panic.
Fixed — CLI and Dart wrapper #
- Null-safe and null-unsafe output were written to the same directory, so the
second pass overwrote the first with code Dart 3 cannot compile. Null-safe
output now goes to
<out>/<spec>/; legacy null-unsafe output is opt-in via--null-unsafeand lands in<out>/<spec>/null_unsafe/. flap --help/--versionwork; unknown flags are rejected.- Lockfiles fingerprint the spec content (SHA-256) instead of mtime + size.
- The client class name is a valid identifier for any API title
(
Petstore 3.1→Petstore31Client). - The Dart wrapper downloaded the
v0.0.1binary regardless of the package version; the version is now a single constant checked againstpubspec.yamlandCargo.tomlby tests. FLAP_BINARYenvironment variable points the wrapper at a locally built generator; download/platform failures exit with code 70 instead of an uncaught exception.- Linux arm64 binaries are published and recognised.
Added #
- Fixtures and Rust integration tests covering unions, inline objects, Swagger 2.0, JSON input, multipart, form bodies, cookies and response headers.
- Dart unit tests for the wrapper package.
0.0.4 #
- Fixing pub points
0.0.3 #
- Fixing pub points
0.0.2 #
- Simple version update
0.0.1 #
- Initial pub.dev release.
- Supports OpenAPI 3.0, OpenAPI 3.1, and Swagger 2.0 spec formats.
- Generates
@freezedDart/Flutter client libraries from any valid spec. - Two HTTP client backends:
package:dio(default) andpackage:http. - Sound null-safe output (
null_safe/) and legacy null-unsafe output (null_unsafe/) generated side-by-side. - Full security scheme support:
apiKey(header/query/cookie), HTTP bearer, HTTP basic, OAuth 2.0, OpenID Connect. - PATCH tri-state semantics via
Optional<T?>fornullable: true+ optional fields. - Typed Dart 3 named-record return types for operations with declared response headers.
- Discriminated unions (
oneOf+discriminator) →@Freezedsealed classes. - Untagged unions (
anyOf/oneOfwithout discriminator) → try-each deserialization. allOfinheritance detection withSchema.extendssurfaced in the IR.- Recursive schema detection and
is_recursiveflag onField. - String and integer
enum:values withunknownsentinel. default:field values emitted as@Default(...)Freezed annotations.format: date-time→DateTime,format: float/double→double.multipart/form-datarequest bodies.- Multiple
servers:→ constants class (abstract final class FooClientUrls). x-*vendor extensions captured on every IR node.--type-map/--import-mapflags to replace spec schemas with hand-written types.--template-dirflag for Jinja2 template overrides.- Incremental builds with lockfile per output mode + backend.
- Pre-generation validation accumulates all errors and reports them together.
