Some cameras will not focus at close range. You will need to experiment. If indirect light is bright enough, you will get the best detail without a flash, but rather than having the gun is bright reflecting light, put it in a shadow and use the flash. Don't have the sun behind you or in front of you. The sun should be coming from the side.
Cloudy days are the best for detailed photos.
Put the gun to be photographed in a well lit place, but make sure that when you look at it through the view finder that there are no bright reflections. If there are you can change the angle of the gun to the light source and the reflections will go away. If you use a flash and get too close to the gun, the flash will wash detail. Experiment with distance. Take a couple of photos changing your distance and settings.