View on GitHub

Microservice DSL (MDSL)

A Domain-Specific Language (DSL) to specify (micro-)service contracts, their data representations and API endpoints.

TL;DR

Microservice Domain-Specific Language (MDSL) abstracts from technology-specific interface description languages such as Swagger, WSDL and Protocol Buffers.

If the URI of this page is https://socadk.github.io/MDSL/index, you are looking at the GitHub pages of the next version (technology preview)! Please refer to https://microservice-api-patterns.github.io/MDSL-Specification/index for the current, publicly released open source version.

Quick links:

Getting Started with MDSL

MDSL supports the API Description pattern from Microservice API Patterns (MAP). It picks up MAP concepts such as API endpoint, operation, client and provider, and features patterns as decorators (a.k.a. stereotypes): <<pagination>>.

A First Example

The Hello World of MDSL models an API with a single endpoint HelloWorldEndpoint that exposes a single operation called sayHello:

API description HelloWorldAPI

data type SampleDTO {ID, D} 

endpoint type HelloWorldEndpoint
exposes 
  operation sayHello 
    expecting payload D<string>  
    delivering payload SampleDTO

API provider HelloWorldAPIProvider
  offers HelloWorldEndpoint

API client HelloWorldAPIClient
  consumes HelloWorldEndpoint

sayHello accepts a single scalar string value D<string> as input. This operation returns a Data Transfer Object (DTO) called SampleDTO as output, which is modeled explicitly so that its specification can be reused. SampleDTO is specified incompletely as an identifier-data pair {ID, D}: the names of the two “parameters” and the type of the data value D have not been specified yet. In addition to the endpoint type (a.k.a. service contract) HelloWorldEndpoint, an API client and an API provider working with this contract are defined (on an abstract level).

Take a look at Hello World in Swagger/Open API Specification in comparison. You can find such contract specification example here (admittedly, this Open API specification contains some more details about te HTTP binding of the abstract contract).

Design Goals

A contract language for (micro-)service API design should:

Design Principles

To achieve the above design goals, we decided that:

MDSL Tools

At present, the following tools are available (see tools page for more information):

A Closer Look

Where and when to use MDSL

Let us visualize the usage context of MDSL specifications with two hexagons, as suggested by the microservices community:2

Solution Sketch of API Integration

If you want to leverage and promote microservices tenets such as polyglot programming and use multiple integration protocols, e.g., an HTTP resource API and message queuing, then MDSL is for you. The request and response message representations in the diagram can be specified with MDSL data contracts; the provided interface supports an MDSL endpoint type.

Language specification elements

  1. Service endpoint contract types follow this template: endpoint type ... exposes operation ... expecting ... delivering ...
  2. Data contracts (schemas): data type SampleDTO {ID, V} in the above example
  3. Optional instance-level concepts:
    • API Provider with protocol bindings and, optionally, Service Level Agreements and evolution strategies such as Two in Production
    • API Client instances consuming the contracts exposed by providers
    • API Gateways (or intermediaries) acting both in client and in provider role; note that gateways are not featured in the simple example above

See these concepts in action in the tutorial, the quick reference and on the example page.

Usage of and support for Microservice API Patterns (MAP)

MDSL supports all Microservice API Patterns one way or another:

The four types of decorators/annotations and stereotypes are optional; if present, they make the API description more expressive and can be processed by tools such as API linters/contract validators, code/configuration generators, MDSL to Open API or WSDL converters (work in progress).

More Information

MDSL Git Pages (this website)

Copyright: Olaf Zimmermann, 2018-2020. All rights reserved. See license information.

  1. The service and the data contract languages can be used independently of each other; for instance, data contracts for operations in contract types can also be specified in JSON Schema (but might not be supported by MDSL tools in that case). 

  2. Octogons, as used to denote cells in Cell-Based Architectures (CBAs), look cool too ;-)