Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.


typescript-service-generator is a tool for creating strongly typed typescript http interfaces from jxrs annotated java interfaces.

For each such java interface, a corresponding .ts class is generated that contains

  • Interfaces for all DTO objects used by the java interface, created using the typescript-generator project (
  • A class, ready to be instantiated with a simple "bridge" object (defined later) that has a callable method for each endpoint in the java class

For example for these Java files:

package com.palantir.code.ts.generator.examples;


public interface MyService {
    MyObject helloWorld();
package com.palantir.code.ts.generator.examples;

 * Note that MyObject is jackson serializable
public class MyObject {
    private String payload = "hello world";

    public String getPayload() {
        return payload;

typescript-service-generator outputs this TypeScript file:

// A potential copyright header
// A desired generated message
module Foundry.Http.MyService {

    export interface IMyObject {
        payload: string;

    export interface IMyService {
        helloWorld(): HttpTypeWrapper<IMyObject>;

    export class MyService implements IMyService {

        private httpApiBridge: IHttpApiBridge;
        constructor(restApiBridge: IHttpApiBridge) {
            this.httpApiBridge = restApiBridge;

        public helloWorld() {
            var httpCallData = <IHttpEndpointOptions> {
                serviceIdentifier: "myService",
                endpointPath: "myservice/foo_get",
                method: "GET",
                mediaType: "application/json",
                requiredHeaders: [],
                pathArguments: [],
                queryArguments: {
                data: null
            return this.httpApiBridge.callEndpoint<IMyObject>(httpCallData);

See for all details on this example

Instantiating the generated class requires an implementation of IHttpApiBridge


This is an interface that serves as a "bridge" between the generated typescript service classes. The contract of this interface is that it should know how to issue http calls given the inputs, and returns an object of a configurable type (see TypescriptServiceGeneratorConfiguration.genericEndpointReturnType). Any generated service class can be instantiated by constructing it with an implementation of the httpApiBridge. For an example, see the end of output/angularHttpApiBridge.ts


The typescript-service-generator generates 1.8.x+ typescript code. This restriction is inherited from one of its dependencies, typescript-generator.


  • Write your code
  • Add tests for new functionality
  • Fill out the Individual or Corporate Contributor License Agreement and send it to
    • You can do this easily on a Mac by using the Tools - Annotate - Signature feature in Preview.
  • Submit a pull request

Depending on Published Artifacts

typescript-service-generator is hosted on bintray. To include in a gradle project:

Add bintray to your repository list:

repositories { maven { url '' } }

Add the typescript-service-generator-core dependency to projects:

dependencies { compile "com.palantir.ts:typescript-service-generator-core:x.x.x" }