Skip to content

SpringFox Example for generating Swagger UI from a Swagger JSON file containing API definitions..

Notifications You must be signed in to change notification settings

indrabasak/springfox-ui-from-json-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

SpringFox (Swagger) UI From JSON File Example

This is an example on generating SpringFox/Swagger UI from API definition stored in a static JSON file.

SpringFox Dependency

Only Springfox dependency required in this example is the springfox-swagger-ui JAR.

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>${swagger.version}</version>
</dependency>

Swagger JSON File

A swagger.json file containing the JSON definition is located under resources/config folder. The location of the file can be changed by modifying swagger.json.location property in application.yml file.

Swagger Controller

A custom controller having the following endpoints to meet all the requests from the swagger-ui.html:

  1. /swagger-resources endpoint which returns a JSON string representation of a springfox.documentation.swagger.web.SwaggerResource object.

  2. /swagger-resources/configuration/ui endpoint which returns a JSON string representation of a springfox.documentation.swagger.web.UiConfiguration object.

  3. /swagger-resources/configuration/security endpoint which returns a JSON string representation of a springfox.documentation.swagger.web.SecurityConfiguration object.

  4. /v2/api-docs endpoint which returns a JSON representation of a Swagger API definition.

Build

To build the JAR, execute the following command from the parent directory:

mvn clean install

Run

To run the application fromm command line,

java -jar target/springfox-ui-from-json-example-1.0.0.jar

Access Swagger Endpoints

Swagger UI

You can view the Swagger UI at http://localhost:8080/swagger-ui.html.

Swagger JSON

You can view Swagger JSON doc at http://localhost:8080/v2/api-docs?group=book

About

SpringFox Example for generating Swagger UI from a Swagger JSON file containing API definitions..

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages