Having an annotation that extends from another abstract annotation with fields, isn't possible to get the field from the children with _parentAnnotationTypeChecker.firstAnnotationOf(methodElement).
Acceptance Criteria:
GIVEN
abstract class Bind {
const Bind([this.path = '']);
/// The path to bind the property to.
/// If not set, the entire route would be by [Controller].
final String path;
}
class Get extends Bind {
const Get([super.path]);
}
WHEN
city_controller.dart
@Controller('/cities')
class CityController {
CityController(this._cityService);
final CityService _cityService;
@Get()
Response getCities(Request request) {
return Response.ok(jsonEncode(_cityService.getCities()));
}
@Get('/<id>')
Response getCity(@PathParam() int id) {
return Response.ok(_cityService.getCity(id));
}
}
controller_generator.dart
const _bindType = TypeChecker.fromRuntime(Bind);
final controllerPath = controllerAnnotation.read('path').stringValue;
final bind = _bindType.firstAnnotationOf(methodElement);
final path = '$controllerPath${bind?.getField('path')?.toStringValue() ?? ''}';
Having an annotation that extends from another abstract annotation with fields, isn't possible to get the field from the children with
_parentAnnotationTypeChecker.firstAnnotationOf(methodElement)
.Acceptance Criteria:
GIVEN
WHEN city_controller.dart
controller_generator.dart
OUTPUT
['/cities','/cities']
EXPECTED
['/cities','/cities/<id>']