Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casing function #564

Closed
P0lip opened this issue Sep 18, 2019 · 2 comments · Fixed by #712
Closed

Casing function #564

P0lip opened this issue Sep 18, 2019 · 2 comments · Fixed by #712
Assignees
Labels
enhancement New feature or request p/high

Comments

@P0lip
Copy link
Contributor

P0lip commented Sep 18, 2019

User story.
As a ruleset maintainer, I would like to have a built-in casing function I could make use of in my own rulesets.
For the time being, in order to enforce casing, you need to use pattern function and come up with a regular expression.

Describe the solution you'd like
We could make enforcing naming convention in Spectral easier by providing casing function with pre-defined set of regular expressions, such as:

  • pascal case
  • camel case
  • kebab case
  • snake case
  • etc.

casing function could also take a custom regular expression, same as pattern does.

Here is an example rule definition:

given: $.paths[*].[*].[*].operationId # I know it looks weird, it's not important though
then:
      function: casing
      functionOptions:
        case: pascal

Additional context
It's a complementary functionality to #405

@P0lip P0lip added the enhancement New feature or request label Sep 18, 2019
@P0lip P0lip self-assigned this Sep 18, 2019
@jerzyn
Copy link

jerzyn commented Sep 18, 2019

take into account the difference of allowed characters in paths, JSON Schema properties, OAS params, query parameters, etc. (for one case convention)

@philsturgeon
Copy link
Contributor

The goal here is to make the core functions, then let #405 create the rules? I'm game for that, let's get this one done sooner rather than later. It's a major use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p/high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants