To be able to get a good workout from swimming you should swim for at least 30 minutes per day or 30 minutes at a time.
If you can swim more often per day and longer than 30 minutes per day then that would give your body an even better workout and keep you much healthier.
Swimming is a good sport and great exercise too and can help with weight loss, heart health, gives you a good cardio workout.
Swimming for 30 minutes at a time can help your body shape as well and tone your body and your overall health will be improved as a result of swimming.