What is the swagger in application?
- A swagger framework allows developers to create interactive machine and human readable API documentation
- Swagger is an open source, set of uses, specification and tools for dwelling and describing wasteful API’s documentation
What is the difference between @RestController and @Controller
- Rest Controller is the Combination of two different annotations.@Controller and @ResponseBody.
- When we annotate with @RestController We do not need to annotate with @ResponseBody
- @ResponseBody is required because a REST API Should return the complete HTTP response body.
What are the message converters in spring? What is the default message converter?
- Spring uses Message converter to transform a type of data like json to Java objects and vice versa.
- All message converter, implement HTTPMessageConverter class.
- Json is the Default converter and string uses Jackson library for this.
- These converters ensures that request and response are seamlessly transformed, allowing us to work with data naturally.
What are the various media type Annotations in spring? How can we produce or consume or type of a resource from a web service in spring? How can an End point produce a json in Spring?
The various Media type annotations in spring are
- @Produces
- It defines the endpoints response type.
- For example, if end point gives adjacent response, then we can give annotation about the end point as @Produces(“application/json”)
- @Consumes
- It defines the MIME media type that is service can consume.
- If an end point Takes Jason as Request body then @Consumes(“application/json”)