{
"openapi": "3.0.1",
"info": {
"title": "Health",
"version": "1.0"
},
"paths": {
"/api/Health/Subscribe": {
"get": {
"tags": [
"Health"
],
"summary": "Retrieves the status of the services and their dependencies",
"responses": {
"200": {
"description": "Successfully determined the status of the services and their dependencies",
"content": {
"text/event-stream": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"ServiceStatus": {
"enum": [
0,
1,
2
],
"type": "integer",
"format": "int32",
"description": "The status of the service (0 - Stopped, 1 - Issue, 2 - Running)"
},
"ServiceStatusChain": {
"type": "object",
"description": "The return object for a service status request",
"properties": {
"status": {
"$ref": "#/components/schemas/ServiceStatus"
},
"dependencies": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/ServiceStatusChain",
"description": "The list of service dependencies (other services, servers, databases, etc.)"
},
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
It generates like this:
service_status_chain.dart
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dependencies.dart';
import 'service_status.dart';
part 'service_status_chain.freezed.dart';
part 'service_status_chain.g.dart';
/// The return object for a service status request
@Freezed()
class ServiceStatusChain with _$ServiceStatusChain {
const factory ServiceStatusChain({
ServiceStatus? status,
Dependencies? dependencies,
}) = _ServiceStatusChain;
factory ServiceStatusChain.fromJson(Map<String, Object?> json) => _$ServiceStatusChainFromJson(json);
}
I was expecting it to be Dictionary/Map return type: Map<String, ServiceStatusChain>? dependencies:
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dependencies.dart';
import 'service_status.dart';
part 'service_status_chain.freezed.dart';
part 'service_status_chain.g.dart';
/// The return object for a service status request
@Freezed()
class ServiceStatusChain with _$ServiceStatusChain {
const factory ServiceStatusChain({
ServiceStatus? status,
Map<String, ServiceStatusChain>? dependencies,
}) = _ServiceStatusChain;
factory ServiceStatusChain.fromJson(Map<String, Object?> json) => _$ServiceStatusChainFromJson(json);
}
Given the Schema:
It generates like this:
service_status_chain.dart
I was expecting it to be Dictionary/Map return type:
Map<String, ServiceStatusChain>? dependencies
: