"components": {
"schemas": {
"Channel": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "integer",
"nullable": false,
"example": 1566687616
},
"name": {
"type": "string",
"description": "string(255): Whatsapp, Telegram, etc",
"nullable": false,
"example": "string"
},
"slug": {
"type": "string",
"description": "string(255)",
"nullable": false,
"example": "string"
},
"description": {
"type": "string",
"description": "string(255)",
"nullable": true,
"example": "string"
}
},
"required": [
"id",
"name",
"slug"
]
},
"Church": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "integer",
"nullable": false,
"example": 1232951869
},
"name": {
"type": "string",
"description": "string(255)",
"nullable": false,
"example": "string"
},
"path": {
"type": "string",
"description": "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",
"nullable": false,
"example": "string"
},
"address": {
"type": "string",
"description": "string(255): Describe church location/address",
"nullable": false,
"example": "string"
},
"reported_by_user_id": {
"type": "integer",
"format": "int64",
"description": "bigint",
"nullable": true,
"example": 1725148829
},
"main_channel_id": {
"type": "integer",
"description": "integer",
"nullable": false,
"example": 1641752488
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "datetime",
"nullable": true,
"example": "string"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "datetime",
"nullable": true,
"example": "string"
},
"deleted_at": {
"type": "string",
"format": "date-time",
"description": "datetime",
"nullable": true,
"example": "string"
},
"mainChannel": {
"type": "object",
"$ref": "#/components/schemas/Channel"
}
},
"required": [
"id",
"name",
"path",
"address",
"main_channel_id"
]
},
....
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.