[ 
https://issues.apache.org/jira/browse/AVRO-1764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15133245#comment-15133245
 ] 

ASF GitHub Bot commented on AVRO-1764:
--------------------------------------

Github user asfgit closed the pull request at:

    https://github.com/apache/avro/pull/61


> Allow YAML files as Map to be added in RecordSchema
> ---------------------------------------------------
>
>                 Key: AVRO-1764
>                 URL: https://issues.apache.org/jira/browse/AVRO-1764
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: Tiago Lima
>
> I did this little improvement to allow me to add annotations to generated 
> files. 
> So, if I want to add persistence's annotation to the generated files, I will 
> have to add some "javaAnnotations` in schema. This is a bad idea, because my 
> client also will have these annotations. Maybe I just have to create a *new 
> layer* using the *Decorator Pattern* to add those annotations, but I don't 
> want this level of complexity in my application. I just want that my Avro 
> Objects have some custom annotations.
> Because of that, we should have the opportunity to add custom configuration 
> to be accessed via velocity template (record.vm). So, I added an attribute in 
> RecordSchema (called metadata) that read an YAML file, which has the same 
> name of the Record, to be loaded as a Map. Now, I just have to overwrite the 
> record.vm from velocity to call metadata.
> {code:title=record.vm|borderStyle=solid}
> #set ($indexName = 
> $schema.getMetadata().get('persistence').get('elasticsearch').get('indexName'))
> #set ($type = 
> $schema.getMetadata().get('persistence').get('elasticsearch').get('type'))
> @Document(indexName = "$indexName", type = "$type")
> {code}
> This can also be used to add validations and any kind of behaviour to the 
> Avro Object.
> I just opened a PR that is just a preview of a solution.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to