Skip to content

OpenAPI with WildFly

Marco Prescher edited this page May 3, 2022 · 30 revisions

Setup OpenAPI on WildFly Server

After starting the WildFly with the standalone.bat you can reach the server on http://localhost:9990/.

1. Navigate

On the Homepage navigate to the tab Configuration then on the left tabs Subsystems -> MicroProfile Config then click on View.

2. Add configuration values

To add configurations values you just have to clock on the Add button on the right side of the your view. image

Config Source

Name -> Enter a name for your configuration e.g. "OpenAPI"
Source -> Select "Properties"

image

Next

Attributes

Add the following three Properties
(Note: Press ↵ to add and ⌫ to remove them.)

  • mp.openapi.extensions.enabled=true
  • mp.openapi.extensions.path=/openapi
  • mp.openapi.extensions.servers.relative=true

It should look like this then image

Next

Ordinal

You can leave Ordinal empty :)

Finish

3. Check entry

You should have an entry like in the following picture.

image

Project backend dependencies

Now we need to add some swagger dependencies.

Gradle

Mandatory

  • implementation 'io.swagger.core.v3:swagger-jaxrs2:2.2.0'
  • implementation 'io.swagger.core.v3:swagger-jaxrs2-servlet-initializer:2.2.0'

Optional

  • implementation 'org.webjars:swagger-ui:4.10.3'

Maven

Mandatory

<dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-jaxrs2</artifactId>
    <version>2.2.0</version>
</dependency>
<dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
    <version>2.2.0</version>
</dependency>

Optional

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>swagger-ui</artifactId>
    <version>4.10.3</version>
</dependency>

Viewing OpenAPI

After setting up the above two points you can start your WildFly Remote Deployment
Visit the link http://localhost:8080/musicshop-1.0/api/openapi.json

Enjoy the unformatted JSON ;) (non-Firefox users)

Clone this wiki locally