Videos
Basically... Are most or all REST API's just JSON data?
Im noticing that any public REST API I look at (google maps, github, etc...) is just an array of javascript objects.
So, is that true? Are REST API's always just data in JSON format?
Thanks!
I finally finished my task by creating my own Java object creator. To help other people who has the same issue, I added this project into GitHub:
ObjectTreeCreator
After this project, the remaining tasks are simple:
- find all API methods by Java reflection
- find return class type on every API method by Java reflection
- call ObjectTreeCreator to generate an object from the class type
- call Jackson ObjectMapper.writeValueAsString to generate Json string from this object
Now my RESTful doc generator works very well. it only needs about 10 seconds to generate html document for about 300 RESTful APIs.
I also added into my maven build process. So every time my build server automatically find all APIs and generate RESTful doc for me.
The generated JSON structure is exact the same as real API response.
By the way I also used Integration testing result if it exists.
ObjectTreeCreator is only used when Integration testing doesn't exist.
You can try spring-restdocs:
https://github.com/spring-projects/spring-restdocs
http://docs.spring.io/spring-restdocs/docs/current/reference/html5/
It generates documentation snippets based on tests of your endpoints (via RestAssured or MockMvc). This way you have a programmatic link between your code and your documentation.