I have a Java server application, which uses Jackson to generically serialize DTO's using the reflection API. For example for this DTO interface:
package com.acme.library;
public interface Book {
com.acme.library.Author getAuthor();
String getTitle();
}
From the POJO implementation of this interface, Jackson will generically serialize the following entity:
{
"author": { "name": "F. Scott Fitzgerald"},
"title": "The Great Gatsby"
}
This payload will be recieved using a HTTP GET from my TypeScript application, which is AngularJS-based:
$http.get("http://localhost/books/0743273567")
.success((book: Book) => { ... });
So that I am able to use the strongly-typed nature of TypeScript, I find myself hand-coding the following typescript interface:
module com.acme.library {
export interface Book {
author: com.acme.library.Author;
title: String;
}
}
As a result, I have to maintain two copies of this same interface -- which is cumbersome at best. This gets particularly nasty, as I'd like to have the same javadoc/jsdoc comments on both interfaces, which involves a whole heap of copy&paste.
I would like to find a mechanism for automating this process.
Java is my main development language. As such, I'd like to find some tool which is capable of converting from the Java interface declaration (via the reflection API?) to the relevant TypeScript interface.
The only tool I have discovered in this domain is the NPM package ts-java. However, this is far too heavyweight for my use-case. It adds methods from the Object hierarchy to each interface, e.g. hashCode(), wait(), getClass(), etc.