Spectral: Rules for checking if an operationId is a camelCase

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:
descripti…


This content originally appeared on DEV Community and was authored by suin

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

Example of detecting errors:

Image description


This content originally appeared on DEV Community and was authored by suin


Print Share Comment Cite Upload Translate Updates
APA

suin | Sciencx (2022-04-13T00:36:52+00:00) Spectral: Rules for checking if an operationId is a camelCase. Retrieved from https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/

MLA
" » Spectral: Rules for checking if an operationId is a camelCase." suin | Sciencx - Wednesday April 13, 2022, https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/
HARVARD
suin | Sciencx Wednesday April 13, 2022 » Spectral: Rules for checking if an operationId is a camelCase., viewed ,<https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/>
VANCOUVER
suin | Sciencx - » Spectral: Rules for checking if an operationId is a camelCase. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/
CHICAGO
" » Spectral: Rules for checking if an operationId is a camelCase." suin | Sciencx - Accessed . https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/
IEEE
" » Spectral: Rules for checking if an operationId is a camelCase." suin | Sciencx [Online]. Available: https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/. [Accessed: ]
rf:citation
» Spectral: Rules for checking if an operationId is a camelCase | suin | Sciencx | https://www.scien.cx/2022/04/13/spectral-rules-for-checking-if-an-operationid-is-a-camelcase/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.