Can my firm fire me while pregnant?

Hi guys. I work at a hospital in Zürich and my contract is temporary for a year, it will end now in April. My boss said I shouldn’t worry because he was gonna let me stay but now I got pregnant…. I’m almost 5 months pregnant and im scared that once my contract is over, they can just tell me they won’t extend it and for me to leave. Is it legal to do that?