Creating a JSON API with Athena & Granite


That’s pretty neat. Thanks for sharing!

Btw, it’s very well-written. Great job!

1 Like

This has since been updated to work with the newest Athena version.

field updated_at : Time, annotations: [
      "@[CrSerializer::Options(expose: true, readonly: true)]",

annotations can not be on macro?

@[CrSerializer::Options(expose: true, readonly: true)]
field updated_at : Time

in a string is not good.


but property also is a macro.

JSON::Field also on it.


Athena is more like spring mvc.


Unfortunately it’s a limitation with how Granite builds out its properties. Since the field macro does not create the property itself, having it just above it does not work. However i’m getting closer to having my annotation ORM prototype done, then it would look more like

property updated_at : Time?

Which is just another ivar property with an annotation, much cleaner looking, also the type/name is infered from the ivar itself. the annotation could also be used to have alternate DB column names, like @[TBD::Column(name: "updatedAt")]

Similar in the way they use annotations, although it was originally based on Symfony.


code first like .net EF?


Possibly. It’s still in the early stages. I did put in some time into making a pretty decent migrator, so it should be possible to generate the tables based on the model definitions. We’ll see how it goes :stuck_out_tongue: