Here is the generated Church model, see like Channel is used (last attribute) but not imported
import 'package:json_annotation/json_annotation.dart';
part 'church.g.dart';
@JsonSerializable()
class Church {
const Church({
required this.id,
required this.name,
required this.path,
required this.address,
required this.mainChannelId,
this.reportedByUserId,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.mainChannel,
});
factory Church.fromJson(Map<String, Object?> json) => _$ChurchFromJson(json);
/// integer
final int id;
/// string(255)
final String name;
/// string(255): parent-id path ex: '-1-2-6-' for a church of id 6, having church parent id = 2, and church-2 belong its self to 1
final String path;
/// string(255): Describe church location/address
final String address;
/// bigint
@JsonKey(name: 'reported_by_user_id')
final int? reportedByUserId;
/// integer
@JsonKey(name: 'main_channel_id')
final int mainChannelId;
/// datetime
@JsonKey(name: 'created_at')
final DateTime? createdAt;
/// datetime
@JsonKey(name: 'updated_at')
final DateTime? updatedAt;
/// datetime
@JsonKey(name: 'deleted_at')
final DateTime? deletedAt;
final Channel? mainChannel;
Map<String, Object?> toJson() => _$ChurchToJson(this);
}
You can test it with your own openapi json file and you get this error, I got this error each times and for now, I have to import every time myself.
swagger_parser: ^1.5.2
here is my swagger_parser.json
# dart run swagger_parser:generate
# dart run build_runner build -d
swagger_parser:
schema_path: assets/openapi.json # Required. Sets the OpenApi schema path directory for api definition
output_directory: lib/api # Required. Sets output directory for generated files (Clients and Dtos)
language: dart # Optional. Sets the programming language. Current available languages are: dart, kotlin. Default: dart
root_interface: true # Optional (dart only). Set 'true' to generate interface with all clients instances. Default: true
squish_clients: false # Optional. Set 'true' to put all clients in one folder. Default: false
client_postfix: ApiCall # Optional. Set postfix for Client class and file. Default: Client
freezed: false # Optional (dart only). Set 'true' to generate data classes using freezed package. Default: false
enums_to_json: true # Optional. Set 'true' to include toJson() in enums. If set to false, serialization will use .name instead. Default: false
enums_prefix: false # Optional. Set 'true' to set enum prefix from parent component. Default: false
replacement_rules: # Optional. Set regex replacement rules for the names of the generated classes/enums. All rules are applied in order.
# Example of rule
- pattern: "[0-9]+"
replacement: ""
Relationship DTO are not imported, I have to manually do it each time
Here is the generated Church model, see like
Channel
is used (last attribute) but not importedYou can test it with your own openapi json file and you get this error, I got this error each times and for now, I have to import every time myself.
swagger_parser: ^1.5.2
here is my swagger_parser.json