This need was revealed during the review of depending netopeer2 package: https://bugzilla.redhat.com/show_bug.cgi?id=2088450#c6 It seems to me %{_datadir}/yang/modules should belong to (some sub)package of yang library and netopeer2 should depend only on that.
This change has been implemented upstream and will be included in the next libyang release.
FEDORA-2022-d7fe26bc9e has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-d7fe26bc9e
FEDORA-2022-d7fe26bc9e has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report.