Skip to content

Helidon MP with Swagger-like UI using OpenAPI. This example shows the usage to Swagger UI to a Helidon MP built project.

License

Notifications You must be signed in to change notification settings

ksurendra/helidon-mp-swagger

Repository files navigation

Helidon MP With Swagger Example

Sample Helidon MP project with Swagger / OpenAPI.

Built a new project using Helidon MP 2.3.4

mvn -U archetype:generate -DinteractiveMode=false \
    -DarchetypeGroupId=io.helidon.archetypes \
    -DarchetypeArtifactId=helidon-quickstart-mp \
    -DarchetypeVersion=2.3.4 \
    -DgroupId=io.helidon.examples \
    -DartifactId=helidon-mp-swagger \
    -Dpackage=io.helidon.examples.mp.swagger

Build and run

With JDK11+

mvn package
java -jar target/helidon-mp-swagger.jar

Using the example

Sample Open API details are added to the class src/main/java/io/helidon/examples/mp/swagger/GreetResource.java as:

 @Path("/greeting")
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @RequestBody(name = "greeting",
            required = true,
            content = @Content(mediaType = "application/json",
                    schema = @Schema(type = SchemaType.STRING, example = "{\"greeting\" : \"Hola\"}")))
    @APIResponses({
            @APIResponse(name = "normal", responseCode = "204", description = "Greeting updated"),
            @APIResponse(name = "missing 'greeting'", responseCode = "400",
                    description = "JSON did not contain setting for 'greeting'")})
    public Response updateGreeting(JsonObject jsonObject) { ... }

Use the below URL to see the API details, like in Swagger-UI:

http://localhost:9393/openapi-ui/index.html

helidon-mp-swagger-screenshot

Known issue

  1. The url redirects/maps to http://[::1]:8080/openapi-ui/index.html

About

Helidon MP with Swagger-like UI using OpenAPI. This example shows the usage to Swagger UI to a Helidon MP built project.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published