Content associated with the talk about OpenAPI.
URLs
-
Project home (this page)
-
Session page on the EclipseCon website
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/todo-backend.postman_collection.json
You can get the same result if you import the todo-backend.yaml
file into Postman.
Server implementation
The application illustrates the usage of JPA with Panache, exposed as a JAX-RS application.
Original work: quarkus-deep-dive project by Clement Escoffier and Emmanuel Bernard.
Database
Run:
docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \ --name postgres-quarkus-rest-http-crud -e POSTGRES_USER=restcrud \ -e POSTGRES_PASSWORD=restcrud -e POSTGRES_DB=rest-crud \ -p 5432:5432 postgres:10.5
Application
mvn compile quarkus:dev
Open: http://localhost:8080/ to get the user interface.
The API is available under:
Client implementation
The OpenAPI-Generator jar is prepared in the todoapp_client folder.
How to generate the client:
If the todo-backend server is running:
java -jar ./openapi-generator-cli-4.0.2.jar generate -i http://localhost:8080/openapi -g java -o out/
be aware that because the servers section is not populated in the specification generated by quarkus, you need to change the basePath value in the generated org.openapitools.client.ApiClient class.
|
From the file system:
java -jar ./openapi-generator-cli-4.0.2.jar generate -i ../OpenAPI-Spec/todo-backend.yaml -g java -o out/
Import the project in the out/
in Eclipse IDE.
Edit DefaultApiTest
class, remove the @Ignore
annotation and add a System.out.println
to see what the server is returning:
@Test
public void todoGetAllTest() throws ApiException {
List<Todo> response = api.todoGetAll();
System.out.println(response);
// TODO: test validations
}
Run it.
Talks
-
2019-06-21: Utiliser OpenAPI plutôt qu’un document html quelconque pour décrire son API given at Voxxed Days Luxembourg 2019
-
2019-06-24: Eclipse MicroProfile OpenAPI given at Eclipse DemoCamp Zurich 2019
Get in touch
Use the issue tracker on GitHub.
You can also contact me on Twitter: @j2r2b
License
Code is under Apache 2.0 License. Documentation and slides are under the Creative Commons BY-SA 4.0