As soon as you build an API including a few operations, you will realize that is hard to maintain code and documentation in sync. Therefore you can use a tool like Swagger. It can generate easly a high quality documentation for you.
Swagger is both a specification and a framework implementation. The strength of Swagger is its hability to keep in sync the code and the documentation. Once you integrate Swagger with your server app, it will generate a live RESTful documentation which will let you navigate and test without coding a single line.
How to integrate your Spring Boot Application with Swagger
First step: Enabling Swagger
Including this annotation in a configuration class
Only works for those spring beans present in the test class. If you need to inject the mock in every bean that depends on, you must declare and autowire all those beans ( although you do not require them ).
Mocks are injected after all the Spring initializations and post-processing. If you are using @PostConstruct, FactoryBean or similar, your mocks will be injected too late and will not be invoked.
An alternative is to use @MockedBean and @EnableMockedBean. By means of these annotations, mocks are created and directly injected into the Spring Context. The original beans are replaced by the mocks, before any initialization and post-processing happen.
Spring Boot supports the use of YAML files to externalize configuration. YAML is a superset of JSON, human-readable and very convenient for specifying hierarchical configuration data. This is an example of yaml
You may also want to use Spring Cloud ZooKeeper Config and having your configuration distributed along your cluster. To get it you have to create a tree structure of nodes in ZooKeeper that is equivalent to the content of your yaml configuration files. It can be done through creation scripts for zkCli but is easier to use zookeeperdump. Zookeeperdump is a tool intended to help loading configurations for Spring Cloud ZooKeeper Config.
It can be downloaded with this maven command.
Zookeeperdump is a groovy script which requires that groovy binaries have been installed previously in your system. I recommend the use of gvm for managing groovy tools and versions.
To view all the tool options execute zookeeperdump.groovy without parameters:
For example to import a yaml file into ZooKeeper is only needed this command.
Apache ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. It is used as a cluster coordination service for demanding systems such as Hadoop, Kafka, Storm, Akka, Neo4j, Talend ESB and so on.
ZooKeeper is a very versatile tool and a perfect partner for a microservice architecture. These are its most common uses:
Spring Cloud ZooKeeper Config has a specific Spring PropertySource that loads transparently the configuration properties from ZooKeeper. It enables me to switch the source of my properties without affecting my application.