Regarding submarines from the pre 30s, I my most material is about Kraut-boats, so you want to compare the dates with the D-class.
The first German boat with a deck gun was U3, launched in 1909. The boats at this time, had no real class names, U4 was also the same model. So you may call it U3/4 class.
They both had a revolver cannon, U4 changed it to a 5cm cannon in 1915, U3 sank in '11 through an accident. I can't find the model/calibre of the auto cannon, if you wish I can also try to check this out. My bet would be on a 3.7 cm.
The first boat with a big (5cm) gun from the beginning was U 14, launched in '12 , from the "U13-U15 class"
Source: Möller/Brack: Enzyklopädie deutscher U-boote, Stuttgart, 2002
If the info on wiki about D1 is right, she was launched already in 1908, so now you have to find out if she had a cannon from the start or if they were attached later.
Damned, seems like the Tommys beat us even in the deck gun race...
