Spectral: Rules for checking if an operationId is a camelCase

suin - Apr 13 '22 - - Dev Community

This rule checks if operationId is camelCase in spectral.

extends: spectral:oas
aliases:
  PathItem:
    - $.paths[*]
  OperationObject:
    - "#PathItem[get,put,post,delete,options,head,patch,trace]"
rules:
  operation-id-camel-case:
    description: Operation IDs must be camelCase since some generators (e.g. RTK Query) don't support kebab-cases.
    message: "Operation ID \"{{value}}\" must be camelCase since some generators (e.g. RTK Query) don't support kebab-cases."
    given: "#OperationObject"
    severity: error
    then:
      field: operationId
      function: casing
      functionOptions:
        type: camel
Enter fullscreen mode Exit fullscreen mode

Example of detecting errors:

Image description

. . . . . . . . . . . . . . .
Terabox Video Player