Parliament is an API document center for microservice architecture based on SpringFox and Swagger. It aims to manage all APIs of individual microservices in one place.
The idea comes from GrokOla who provides a featured Wiki for dev teams. If you find Parliament is not enough for you, please take a look at GrokOla.
This project is implemented using Spring Boot, and MongoDB for database.
- Java 1.8
- Maven
- MongoDB
Modify MongoDB configurations in application.properties:
spring.data.mongodb.host = _MongoDB address_
spring.data.mongodb.database = _MongoDB database name_
spring.data.mongodb.port = _MongoDB port_
Use following command to start:
mvn package && java -jar target/Parliament-1.0.0.jar
This section is only for Spring Boot application.
To publish API information to Parliament server, please use:
- springfox-swagger2 from SpringFox
- khs-spring-boot-publish-swagger-starter which build from https://github.com/burnettzhong/khs-spring-boot-publish-swagger-starter
CAUTION: for khs-spring-boot-publish-swagger-starter, please do not use original one from Keyhole Software, since there are several bugs. I have created pull request to them, if they merge my code, I will update this section.
-
Build and add khs-spring-boot-publish-swagger-starter dependency, run following command:
git clone https://github.com/burnettzhong/khs-spring-boot-publish-swagger-starter cd khs-spring-boot-publish-swagger-starter mvn clean install
-
Add maven dependencies
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>com.keyholesoftware</groupId> <artifactId>khs-spring-boot-publish-swagger-starter</artifactId> <version>1.0.2</version> </dependency>
-
Configure your Spring Boot application for Swagger and push API information to Parliament server. Simply add @EnableSwagger2 and @PublishSwagger annotations.
@EnableSwagger2 @PublishSwagger public class ServiceApplication { ... }
For more information about Swagger2 usage, please visit Springfox Reference Documentation.
-
Add the following properties your application.yml file:
swagger: publish: publish-url: http://{_Parliament server address_}/swagger/publish/ swagger-url: http://127.0.0.1:${server.port}/v2/api-docs
That's all! Now you can start your Spring Boot application, the API information will be published to Parliament Server automatically.
Open http://{Parliament Server address}/index.html, you will see a list of all your microservices, then you can see more details if click on them.
Copyright 2017 Han Zhong - @burnettzhong
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0