florval 0.2.3
florval: ^0.2.3 copied to clipboard
Generate type-safe Flutter/Dart API clients from OpenAPI specs. Freezed models, status-code Union types, and Riverpod 3.x integration.
0.2.3 #
Bug Fixes #
- Fix ambiguous exports for union type subclass names: Resolve
dart analyzeerrors caused by union variant subclass names (e.g.,RequestDataRoomInvitation) being exported from both the union type file and a standalone model file. Implemented 3-layer defense:- Clean output directory before generation to remove stale files from previous runs
- Pre-filter
variantSchemaNames()to exclude discriminator union variants from standalone model generation - Barrel-level deduplication via
unionSubclassNames()as a safety net to remove colliding names from exports
- Fix variant schema filtering for inline unions: Only use component schemas (not inline union schemas from response bodies) for variant filtering, preventing independent component schemas like
EventNotFoundErrorDtofrom being incorrectly excluded
0.2.2 #
Improvements #
- Update package description to be more concise and highlight core features (Freezed models, status-code Union types, Riverpod 3.x)
- Add encer.co.jp vision statement to README
0.2.1 #
Features #
- Inline enum generation: Generate Dart enums from inline OpenAPI
enumproperties, instead of requiring top-level schema definitions readOnly/writeOnlysupport: Read OpenAPIreadOnlyandwriteOnlyflags on schema fields and propagate them to the intermediate representation- Doc comments and example output: Generate
///doc comments from OpenAPIdescriptionfields and/// Example: ...fromexamplevalues on models, fields, enums, and endpoints defaultvalue support: Read OpenAPIdefaultvalues and generate@Default(...)annotations in freezed models. Supports string, integer, number, boolean, empty array, and enum types. DateTime and non-empty array defaults emit a warning and are skipped. Fields with bothrequiredanddefaultuse@Default(...)(freezed does not allow both)deprecatedflag support: Read OpenAPIdeprecatedflags at schema, property, operation, and parameter levels and generate@Deprecated('')annotations. Schema-level deprecated applies to class/enum definitions; property-level deprecated applies to individual fields; operation/parameter-level deprecated applies to client methods and their parameters- Schema title fallback for doc comments: Use schema
titleas doc comment whendescriptionis not available
Bug Fixes #
- Preserve properties in
_applyAbsentable: Fixexample,readOnly, andwriteOnlyfields being lost when_applyAbsentabletransforms optional fields for PATCH/PUT request bodies - Operation/Parameter deprecated field name: Fix incorrect property name used when reading the
deprecatedflag from Operation and Parameter objects - Null safety in doc comment generation: Fix null safety operator for
descriptionandexamplein doc comment generation
0.2.0 #
Breaking Changes #
- Rename response Union types from
{Op}Responseto{Op}ApiResponseto structurally resolve name collisions with model classes - Switch response Union types from freezed to plain Dart sealed classes (copyWith/equality/fromJson not needed, eliminates build_runner dependency for response types)
Features #
- JsonOptional<T> for PATCH/PUT partial updates: Generate
JsonOptional<T>sentinel type that distinguishes "key absent" (unchanged) from "key is null" (clear value) at the type level. Optional fields in PATCH/PUT request bodies are wrapped inJsonOptional<T>with@Default(JsonOptional<T>.absent()). CustomfromJsonusesjson.containsKey()for 3-state restoration; customtoJsonexcludes absent keys.@Freezed(fromJson: false, toJson: false)bypasses json_serializable entirely for absentable schemas. POST request bodies and response models are unaffected. - Inline anyOf/oneOf union type support: Detect anyOf/oneOf declared inline within schema properties and automatically generate Union types for them
- Restore freezed for discriminator union types: Generate
@Freezed(unionKey: '...')+@FreezedUnionValue('...')with variant fields inlined into factory constructors - Non-discriminator union fromJson/toJson: For oneOf/anyOf without a discriminator, generate fromJson that tries each variant sequentially and toJson that branches on runtimeType
- Logger warnings: Emit warnings when an array type is missing
itemsor when an unsupported content-type is encountered
Bug Fixes #
- anyOf/oneOf nullable
$refpattern: FixanyOf: [{$ref: '#/.../Foo'}, {type: 'null'}]incorrectly resolving toMap<String, dynamic>instead of a nullable type - additionalProperties typed Map: Generate correct
Map<String, T>type whenadditionalPropertiesspecifies a schema - ResponseAnalyzer nullable anyOf: Fix false detection of nullable anyOf patterns during response analysis
_extractTypedynamic fallback: Fix dynamic fallback handling when type extraction fails- Inline object fallback: Fix inline object schemas incorrectly falling back to
Map<String, dynamic>instead of generating proper types - Inline oneOf/anyOf responses: Fix inline oneOf/anyOf in endpoint response definitions falling back to
Map<String, dynamic> - allOf + nullable
$ref: Fix resolution of nullable$refentries within allOf compositions List<dynamic>type error: Fix type inference error inflorval_runnerschemas variable- Name collision structural fix: Resolve response Union type vs. model class name collisions using import prefix splitting and barrel file separation
json_serializablesealed class error: Fixjson_serializableerrors on sealed class fields with discriminator.g.dartpart directive exclusion: Skip unnecessary.g.dartpart directive generation for sealed classes with discriminator- Library import prefix lint: Remove leading underscores from generated import prefixes to fix
no_leading_underscores_for_library_prefixeslint violation includeIfNull: falserevert: Revert@JsonSerializable(includeIfNull: false)addition due to incompatibility with demo-api default values; fix applied on API side instead
Refactoring #
- Analyzers as pure functions: Convert
SchemaAnalyzer,EndpointAnalyzer, andResponseAnalyzerto stateless pure functions for improved testability (+477/-305 lines) - FlorvalRunner phase splitting: Clearly separate Parse → Resolve → Analyze → Generate → Write phases with an
AnalysisResultintermediate representation - Generator layer deduplication: Extract shared status code conversion and import collection logic from
client_generator/response_generatorintoutils/status_code.dartandutils/import_collector.dart(+72/-115 lines) - Import deduplication: Reduce unnecessary import generation in provider generator
- Test readability improvements: Unify formatting and structure in
model_generator_test, remove unnecessary forced unwraps inresponse_analyzer_test - Deduplicate toJson serialization logic: Unify
_writeToJsonFieldand_toJsonValueExpressionin ModelGenerator —_writeToJsonFieldnow delegates to_toJsonValueExpression, eliminating duplicated type-dispatch logic (DateTime, enum, List, reference types) - Barrel file separation: Exclude
api_responses.dartfromapi.dartre-exports, keeping only models/clients/providers
Demo / Example #
- Add demo-api server: Hono + @hono/zod-openapi based mock API server with full endpoint coverage (auth, CRUD, file upload, notifications)
- Add Flutter Web project: Flutter Web example app connecting to demo-api at localhost:3000
- Add CLI verification script:
example/lib/verify.dartfor integration testing against demo-api - Update example generated code: Regenerate all code based on demo-api OpenAPI spec (6 tags, 15 response types, 35 models)
- Remove unused files: Delete petstore-derived API client, model, provider, and response files
0.1.1 #
Bug Fixes #
- Fix mutation helpers missing query parameters
- Fix List request body calling
toJson()which doesn't exist onList - Fix empty-property schema causing
build_runnererror - Fix double
??in generated nullable optional parameters - Fix null-aware operator on enum query params inside null-check guard
- Fix Schema enum property name:
$enum→enumValues
Improvements #
- Expand Riverpod reserved name handling with generated super params
- Rename Riverpod reserved param names in generated providers
- Handle non-ASCII characters in field names and enum values
- Generate mutation helper functions even when no GET endpoints exist in tag
- Remove unnecessary
dart:asyncimport from generated providers - Skip unused request body imports in mutation-only providers
- Always generate
partdirective andriverpod_annotationimport in providers
Other #
- Remove deprecated pagination examples and related schemas from openapi.yaml
0.1.0 #
- Initial release
- OpenAPI 3.0 / 3.1 spec parsing with automatic v3.0 → v3.1 normalization
- Swagger 2.0 partial support (auto-normalized to 3.1)
$refresolution with circular reference detection- freezed 3.x data model generation (abstract class)
- Status-code Union type generation (freezed sealed class)
- Dart 3 switch expression support (no when/map)
- dio API client generation (no Retrofit dependency)
- DioException handling with status-code routing
- Riverpod 3.x provider generation (optional)
- GET →
@riverpodNotifier with build() parameters - POST/PUT/DELETE/PATCH →
Mutation<T>()constants - Auto-invalidation of GET providers after mutations
@Riverpod(retry:)support from config
- GET →
- Cursor-based pagination with
fetchMore()andPaginatedData<T> - multipart/form-data support with
MultipartFile - oneOf / anyOf / allOf / discriminator support
- Watch mode for auto-regeneration on spec changes
florval initcommand for config template generationflorval.yamlconfiguration with validation- Custom template headers and imports
- Tag-based endpoint grouping
- Barrel file generation