Content associated with the talk OpenAPIs are everywhere given at EclipseCon Europe 2018 (video)

URLs

Do you want to improve this page? Please edit it on GitHub.

Description

This repository contains the examples and the code demo presented during the talk.

OpenAPI specification

The OpenAPI-Spec folder contains the OpenAPI specification for the Todo-Application.

Open it in Swagger-Editor online:

Postman collection

The postman collection can be found here: Postman/todoapp.postman_collection.json

You can get the same result if you import the todoapp.v2.yaml file into Postman.

Import feature in Postman

Server implementation

There are 2 server implementation based on Thorntail.

To start the application just run following command inside a project:

mvn thorntail:run

The server is started on port 8080.

If you start version with the OpenAPI support the generated spec is available at:

http://localhost:8080/openapi

Client implementation

The OpenAPI-Generator jar is prepared in the todoapp_client folder.

How to generate the client:

java -jar ./openapi-generator-cli-3.3.1.jar generate -i ../OpenAPI-Spec/todoapp.yaml -g java -o out/

Import the project in the out/ in Eclipse IDE.

Edit TaskApiTest class, remove the @Ignore annotation and edit the fist test:

@Test
public void tasksCreateTest() throws ApiException {
    Task task = new Task();
    task.setDescription("Publish slides");
    task.setCompleted(false);
    Task response = api.tasksCreate(task);

    System.out.println(response);
}

Run it.

Talk

Abstract

The OpenAPI Specification (formally known as Swagger) describes APIs in a way that is standardized, machine-readable, and programming language-agnostic. It is an open source project hosted by the Linux Foundation.

There have been many announcements regarding frameworks or tools supporting this standard: For example, Eclipse MicroProfile 1.3 provides a set of annotations that can be used on top of JAX-RS, and version 3.5.2 of Eclipse Vert.x provides automatic requests validation.

The standard is also well-adopted. Many products describe their API as an OpenAPI Specification: Docker, OpenShift, Microsoft Azure, to name a few. The government of Netherlands has adopted the OpenAPI Specification as a national standard.

This talk will provide an overview of the specification format, then it will present some implementation examples with different frameworks. Useful tools; such as an editor based on Eclipse Xtext and a code generator, will also be presented. The examples here are taken from real projects.

All of the tools presented in this talk are open-source.

Video

The presentation was recorded and is availble on YouTube: OpenAPIs are everywhere | EclipseCon Europe 2018.

Get in touch

Use the issue tracker on GitHub.

You can also contact me on Twitter: @j2r2b

License

Code is under Eclipse Public License - v 2.0. Documentation and slides are under the Creative Commons BY-SA 4.0