innerMap method
Generates the detailed OpenAPI schema for the response.
Creates a nested map structure including description and content schema. If properties exist, generates a detailed JSON schema; otherwise, provides a basic object schema.
Implementation
Map<String, dynamic> innerMap() {
final responseMap = <String, dynamic>{};
if (description != null) {
responseMap['description'] = description;
}
// Handle properties if provided
if (properties != null && properties!.isNotEmpty) {
responseMap['content'] = {
'application/json': {
'schema': {
'type': 'object',
'properties': {
for (final field in properties!) field.name: fieldToSchema(field),
},
'required': properties!
.where((field) => field.isRequired)
.map((field) => field.name)
.toList(),
},
},
};
} else {
// Default schema if no properties are specified
responseMap['content'] = {
'application/json': {
'schema': {'type': 'object'},
},
};
}
return responseMap;
}