Here is a spectral rule by Tyler Liu, which you can find here. Thanks Tyler!
rules:
ensure-paths-kebab-case:
description: Paths must be in kebab-case.
message: '{{description}} (lower case and separated with hyphens)'
formats: [oas3]
type: style
severity: error
given: $.paths[*]~
then:
function: pattern
functionOptions:
match: "^(\/|[a-z0-9-.]+|{[a-zA-Z0-9]+})+$"
It will match
/products/{productId}
/products
It will not match
/products/{product-id}
You can try out the regex on https://regex101.com/ .