I have a doubt regarding defining types for response.What is the use of defining types.
Simply put: re-use.
When defining multiple resources and payloads, having the ability to re-use, inherit from, and combine defined types (multiple inheritance) helps keep things lean (“DRY” principle). It helps make API definitions and APIs themselves more sturdy as it reduces the surface area of custom/inline definitions (the more there is = the more is prone to errors). From a governance standpoint, it also helps make things more “standard” across the board.