Various deep learning (DL) techniques have found application in the respiratory sound classification to effectively alleviate the diagnostic pressure of physicians. However, DL-based respiratory sound classification methods are mostly based on convolutional neural networks (CNN). Due to the inherent locality of convolution operations, CNN generally extracts only local features of 2D spectrogram representations. A respiratory sound has wide frequency bands and long time spans. It is important to obtain both global and local information. To address this problem, we propose a novel Swin Transformer network for respiratory sound classification. Experimental results on the ICBHI2017 dataset demonstrate that the proposed model achieves 77.3% specificity, 41.1% sensitivity, 59.2% ICBHI score and outperforms the state-of-the-art methods.