Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 2.42 KB

File metadata and controls

61 lines (39 loc) · 2.42 KB

BookStore—OpenAPI Support

What You Learn

What you need

  • Understand tutorial BookStore - Using a Repository because we explain only new aspects
  • 30 minutes
  • JDK 25 (or higher) installed
  • Swagger UI
  • Maven 3.6 (or higher) installed
  • A postgres DB (if you start the application with running infrastructure)

Enable OpenAPI

In general OpenAPI support can be enabled for all objects that can be accessed via the RESTfulRPCAdapter. To enable OpenAPI support, you need to define an OpenAPI-path either in the properties or when starting the application. The corresponding parameter is io.jexxa.rest.openapi.path.

mvn clean install
java -jar "-Dio.jexxa.config.import=./src/test/resources/jexxa-test.properties" target/bookstore-jar-with-dependencies.jar```
You will see following (or similar) output
```console
...
[main] INFO io.jexxa.utils.JexxaBanner - Access Information: 
[main] INFO io.jexxa.utils.JexxaBanner - Listening on: http://0.0.0.0:7503
[main] INFO io.jexxa.utils.JexxaBanner - OpenAPI available at: http://0.0.0.0:7503/swagger-docs/swagger.json

Explore OpenAPI

You can use Swagger UI to explore the documentation. Just start Swagger UI, enter the URL and press explore button.

Note: In case you start Swagger UI not on the same machine as your BookStore-application, or from a docker image, you have to use the public IP address of the machine running BookStore-application.

As a result, you should get the following overview with available operations:

OpenAPI-Docu

Now, let's start to execute some methods.

Get a list of books

To get a list of available books, you first have to select the corresponding methods. As soon as you pressed it, you will get detailed information such as including parameters and responses.

OpenAPI-getBooks

Now, you can execute the method getBooks and Swagger-UI will show you all available books.

OpenAPI-getBooksResult

From these results, you can play around with remaining methods provided by this application.

That’s it!