Opensource Projects

rsd - remote service description

What is RSD

RSD is a comparable to Typespec allowing developers to define Types and Services in a developer friendly format (unlike eg OpenAPI).

From the RSD-Definitions developers can generated:

  • Server-Code (eg JAX-RS Services)
  • DTOs (Java, Typescript/JavaScript, ...)
  • OpenAPI.json
  • ...

Example

The following lines define a simple CRUD-Service

error NotFound;

patchable record Person {
  @id key: string
  firstname: string
  lastname: string
  birthdate?: local-date
}

service Person {
  operation create(person: Person);
  operation get(key: string): Person throws NotFound;
  operation list(): Person[];
  operation update(key: string, @patch Person) throws NotFound;
  operation delete(key: string) throws NotFound
}

In contrast to Typespec to map the above definition to a concrete technology is done with a secondary DSL who just containst the concepts of the target system. As everything this has a pros and cons but we to use it is more important to not clutter the simple and elegant definition above with technical stuff required to map the service to a certain technology.

To expose the above service as a REST-Endpoint looks like this:

resource Person     at '/api/person' {
  POST create       at '' => {
    201
  }
  GET get           at '${key}' => {
    200
    404: NotFound
  }
  GET list          at ''
  PATCH update		at '${key}' => {
    204
    404: NotFound
  }
  DELETE delete     at '${key}'
}
Previous
quti