If the Brotherhood are all attacking you, then the faction is currently hostile to you. This would make Danse attack you as well, as he is part of the faction.
If this is due to a quest decision, like going too far with the Institute to still be at peace with the Brotherhood, then you can't really do anything about it.
If this is due to some recent actions, like shooting at members of the faction, then it should go away after a few days. Try waiting or sleeping. You'll probably want to dismiss Danse during this time. Go back to the Prydwen afterward, and see if they still attack you. If they've stopped, then you're all good.