Especially things like the Unification of Italy, Fascist Italy, WWII, and Napoleon invading Italy.
http://www.amateurradiodx.com/wp-content/uploads/2015/02/san-marino.jpg
it is not the easiest place to take.
http://www.sanmarinotour.com/g/san-marino.jpg
seriously thou, it has been occupie dby cesare borgia in 1503 till his death. http://web.educazione.sm/scuola/servizi/CD_virtuali/lavori_scuole/sanmarino/borgia.htm
in 1719 cardinal Albertoni tried to annex it to the church's state but civil disobedience, protests to the pope Clemente XII and the pressure of foreigen potences made him back off. http://www.libertas.sm/libri/Alberoni/Alb_0_2.htm and follow the links in page
during ww2 it has been occuped by both axes and allied forces. http://www.storiaxxisecolo.it/fascismo/fascismo1c.htm
Napoleon was friendly with the city and offered to expand its bordes to the sea but they refused. this allowed them to not being condieded france allies during Wien Congress http://www.libertas.sm/Storia_generale/It/Storia_San_Marino_9.htm
during 1849, while tring to reach Venezia, garibaldi's army was surrounded by four hostile armies and he recived the permission to enter RSM's terrytory if he pleaded to do not engage in hostile activities. after that it was looked with suspect by Austria and Church State and they tried to annex it with arms, but the intervention of Napoleon's 3rd france bloked that.
they signed a friendship treaty with italy in 1862 that concord the indipendece of the republic. http://www.esteri.sm/on-line/home/trattati-internazionali/convenzioni-bilaterali/convenzioni-bilaterali---accordi-bilaterali-con-litalia.html specifically this pdf http://www.esteri.sm/on-line/home/trattati-internazionali/convenzioni-bilaterali/convenzioni-bilaterali---accordi-bilaterali-con-litalia/documento1075147.html