dart_swagger_to_models 0.5.2
dart_swagger_to_models: ^0.5.2 copied to clipboard
Generate null-safe Dart models from Swagger/OpenAPI specs with multiple styles and per-file output.
0.5.2 #
Added #
- Spec linting (подсказки по качеству спецификаций)
- Конфигурируемые lint правила в
dart_swagger_to_models.yaml - Поддержка включения/выключения отдельных правил
- Настройка уровня серьёзности (warning vs error) для каждого правила
- Доступные правила:
missing_type- поле без типа и без $refsuspicious_id_field- подозрительное id поле (без required и без nullable)missing_ref_target- отсутствующая цель для $reftype_inconsistency- несогласованность типов (например, integer с format)empty_object- пустой объект (нет properties и additionalProperties)array_without_items- массив без itemsempty_enum- enum без значений
- Пример конфигурации:
lint: enabled: true rules: missing_type: error suspicious_id_field: warning missing_ref_target: error type_inconsistency: warning empty_object: off array_without_items: warning empty_enum: warning
- Конфигурируемые lint правила в
0.5.1 #
Added #
- Incremental generation (инкрементальная генерация)
- Cache system for tracking schema changes:
- Caches schema hashes in
.dart_swagger_to_models.cachefile - Uses SHA-256 hashes to detect schema changes
- Automatically handles new, modified, and deleted schemas
- Caches schema hashes in
--changed-onlyCLI flag:- Regenerates only schemas that have changed since last run
- Significantly improves performance for large specifications
- Automatically removes files for deleted schemas
- Comprehensive tests:
- First run (generates all schemas)
- Incremental run (only changed schemas)
- Adding new schemas
- Removing schemas
- Modifying single schema in large spec
- Example usage:
# First run - generates all schemas dart run dart_swagger_to_models:dart_swagger_to_models \ --input api.yaml \ --changed-only # Subsequent runs - only changed schemas dart run dart_swagger_to_models:dart_swagger_to_models \ --input api.yaml \ --changed-only
- Cache system for tracking schema changes:
0.4.2 #
Added #
- Improved DX and logging
- CLI flags
--verbose/-vfor detailed logs - CLI flag
--quiet/-qfor minimal output - Human-friendly error messages for missing
$reftargets - Warnings about unsupported or ambiguous schema constructs
- Warnings about suspicious specs (e.g.,
idwithoutnullable: truebut norequired) - Summary after generation showing:
- Number of processed schemas
- Number of processed enums
- Number of created/updated files
- Total files generated
- CLI flags
0.4.1 #
Added #
- build_runner integration
SwaggerBuilderclass for generating models as part of build_runner pipeline- Automatic detection of OpenAPI/Swagger specification files in
swagger/,openapi/, orapi/directories - Configuration via
build.yamlfile - Support for all generation styles (plain_dart, json_serializable, freezed)
- Example projects:
example/dart_example/- Pure Dart project demonstrating build_runner integrationexample/flutter_example/- Flutter project with HTTP client integration
- Documentation:
- Added section "Integration with build_runner" to
doc/en/USAGE.md - Added section "Интеграция с build_runner" to
doc/ru/usage.md
- Added section "Integration with build_runner" to
- Usage:
# build.yaml targets: $default: builders: dart_swagger_to_models|swaggerBuilder: enabled: true generate_for: - swagger/** - openapi/** - api/**# Run build_runner dart run build_runner build # or for Flutter flutter pub run build_runner build - Features:
- Automatic model generation when specifications change
- Seamless integration with other code generators (e.g., json_serializable)
- Works with all configuration options (defaultStyle, outputDir, useJsonKey, etc.)
- Generated files are part of project structure for IDE support
0.3.2 #
Added #
@JsonKeygeneration for snake_case JSON keys- Global config option
useJsonKey: true/false - Per-schema override
useJsonKeyin schema overrides - Works with both
json_serializableandfreezedstyles - Automatically detects when JSON key differs from Dart field name
- Global config option
0.3.1 #
Added #
- Pluggable styles (подключаемые стили)
- Public API for registering custom generation styles:
StyleRegistryclass for registering custom stylesStyleRegistry.register()method to register a custom styleStyleRegistry.createCustomStrategy()to create a strategy instance- Support for custom style names in configuration files
- Support for custom style names via CLI
--styleoption
- Example custom style:
example/custom_style_equatable.dart- Complete example of an Equatable style generator
- Documentation:
doc/en/CUSTOM_STYLES.md- Step-by-step guide on creating custom stylesdoc/ru/CUSTOM_STYLES.md- Step-by-step guide in Russian
- Usage:
// Register a custom style StyleRegistry.register('my_style', () => MyCustomGenerator()); // Use in config file // dart_swagger_to_models.yaml: // defaultStyle: my_style // Or via CLI // --style my_style - Features:
- External packages can provide their own
ClassGeneratorStrategyimplementations - Style name → strategy mapping via
StyleRegistry - Custom styles work alongside built-in styles (
plain_dart,json_serializable,freezed) - Clear error messages when using unregistered styles
- External packages can provide their own
- Public API for registering custom generation styles:
0.2.2 #
Added #
- Configuration file support (
dart_swagger_to_models.yaml)- Global options:
defaultStyle,outputDir,projectDir - Per-schema overrides:
className,fieldNames,typeMapping
- Global options:
- CLI option
--config/-cfor specifying custom config file path - Priority system: CLI arguments > config file > defaults
0.2.1 #
Added #
- Improved OpenAPI handling
- Enhanced
oneOf/anyOfsupport:- Safer
dynamicwrappers with clear error messages - Architecture prepared for future union-type generation (especially with
discriminator) - Verbose logging about possible types in
oneOf/anyOfschemas - Detection and logging of
discriminatorusage
- Safer
- Extended
allOfsupport:- Recursive handling of nested
allOfcombinations - Support for multiple inheritance cases
- Detection and prevention of circular dependencies
- Verbose logging for nested
allOfprocessing
- Recursive handling of nested
- Comprehensive tests for complex composed schemas:
- Nested
allOfcombinations - Multiple inheritance through
allOf oneOf/anyOfwith discriminator- Circular dependency handling
- Nested
- Enhanced
