Skip to content

AmayaFramework/amaya-swagger

Repository files navigation

amaya-swagger amaya-swagger

The Amaya Framework module that integrates Swagger/OpenAPI document serving and UI support.

Getting Started

To install it, you will need:

Features

  • Serving OpenAPI documents (JSON / YAML) with configurable roots
  • Automatic content negotiation and compression support
  • Integration with any openui-compatible UI module (e.g. Swagger UI or custom)
  • Configurable root path for UI and exposed documents
  • Simple fluent API for setup

Installing

Gradle dependency

dependencies {
    implementation group: 'io.github.amayaframework', name: 'amaya-core', version: '3.5.0'
    implementation group: 'io.github.amayaframework', name: 'amaya-swagger', version: '2.1.0'
    // choose any OpenUI implementation:
    implementation group: 'io.github.amayaframework', name: 'swagger-ui-bundle', version: '2.0.0'
}

Maven dependency

<dependencies>
    <dependency>
        <groupId>io.github.amayaframework</groupId>
        <artifactId>amaya-core</artifactId>
        <version>3.5.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.amayaframework</groupId>
        <artifactId>amaya-swagger</artifactId>
        <version>2.1.0</version>
    </dependency>
    <!-- choose any OpenUI implementation -->
    <dependency>
        <groupId>io.github.amayaframework</groupId>
        <artifactId>open-ui-bundle</artifactId>
        <version>2.0.0</version>
    </dependency>
</dependencies>

Example

import io.github.amayaframework.core.WebBuilders;
import io.github.amayaframework.swaggerui.SwaggerUiFactory;

public class Main {
    public static void main(String[] args) throws Throwable {
        var app = WebBuilders.create()
                .withServerFactory(/*your server factory*/)
                .configureApplication(Swagger.configurer(cfg -> cfg
                        .uiFactory(new SwaggerUiFactory())
                        .root("/swagger")
                        .addDocument(Sources.of("https://petstore.swagger.io/v2/swagger.json", "Petstore")))
                )
                .build();
        app.bind(8080);
        app.run();
    }
}

Run and open http://localhost:8080/swagger to see Swagger UI with the Petstore API.

Built With

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

About

The amaya framework module that implements the standalone swagger SPA.

Resources

License

Stars

Watchers

Forks

Packages

No packages published