Open navy1978 opened 4 years ago
Hi I will look on angular2-jsonapi library and I will let you know on Monday thanks for interest in this project Tomek
Hi "First of all : Is possible to accomplish that with your library?" YES :) please checkout branch "version-1.2.4-angular2-jsonapi" I created for You new converter ModelClassesToTsAngular2JsonApiConverter which do already most of the job, please run it in example Angular2JsonApiTest
You was right, new converter was needed
Property is a mean to collect java field and methods which have impact on TypeScript field. In jackson/fasterxml You can make crazy things with mapping java field and getters/setters to JSON field So java annotations are on java field or getter or setter which are kept by Property class instance. Please look at ModelClassesToTsAngular2JsonApiConverter.addAngular2JsonApiDecorators in this method I'm adding Decorators to TS field and it seems that You don't need any java annotation for it except JsonApiModelConfig where field "type" value must be set, now I'm generating such value, so for this purpose I will add class level annotations and from this annotation set TS decorator value (method createJsonApiModelConfigDecorator)
I'm new to angular2-jsonapi I don't know if you need to generate only model or some controller proxies are also required, please feel free to develop in branch "version-1.2.4-angular2-jsonapi" I would like to help You achieve proper implementation.
You can reach me on skype tomaszwozniak@interia.pl Tomek
Thank you very much, I'm going to give it a try... And I will add you on skype ;)
How can I add annotation to the ts files? I need to use an Angular library (angular2-jsonapi) that needs class and fileds to be annotated with a specific annotation. Like the following: `import { JsonApiModelConfig, JsonApiModel, Attribute, HasMany, BelongsTo } from 'angular2-jsonapi';
@JsonApiModelConfig({ type: 'examples',
}) export class Example extends JsonApiModel { @Attribute() id: string;
@Attribute() title: string;`
I was thinking to add a special annotation in Java and get what I want in ts. But not clear to me how to proceed.
First of all : Is possible to accomplish that with your library? Do we need to implement a special Converter, right?
I'm thinking to put some extra logic in a custom: "ModelClassesAbstractConverter" and in the method: "getClassProperties" check if my JavaClass contain a special(custom) annotation @MyAnnotation like this:
if (javaClass.isAnnotationPresent(MyAnnotation.class)) { System.out.println("Found annotation in the class!"); }
if (field.isAnnotationPresent(MyAnnotation.class)) { System.out.println("Found annoatation in the field") }
But I don't see some special setting in the Property class that can be used later on to add the annotation into the ts file... Can you please provide an example?Thank you in advance.