require "uri"
require "athena-serializer"
struct Website
include ASR::Serializable
@[ASRA::Accessor(getter: get_url)]
property url : URI = URI.new()
def get_url : String
return @url.host || ""
end
def initialize(@url : URI)
end
end
website = Website.new(URI.parse("https://example.com"))
puts ASR.serializer.serialize website, :json
Code in macro 'included'
27 | {% if true %}
^
Called macro defined in macro 'included'
27 | {% if true %}
Which expanded to:
> 32 | external_name: "url",
> 33 | annotation_configurations: ADI::AnnotationConfigurations.new({} of ADI::AnnotationConfigurations::Classes => Array(ADI::AnnotationConfigurations::ConfigurationBase)),
> 34 | value: get_url,
^
Error: expected argument 'value' to 'Athena::Serializer::PropertyMetadata(URI, URI, Website).new' to be URI, not String
This leads to a compile error instead of the expected {"url": "example.com"}
This can be worked around by using a VirtualProperty but I feel like this pattern is more natural
This leads to a compile error instead of the expected
{"url": "example.com"}This can be worked around by using a VirtualProperty but I feel like this pattern is more natural