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

Add explicit control of case convention for paths and schema #40

Closed
aspear opened this issue May 29, 2019 · 1 comment
Closed

Add explicit control of case convention for paths and schema #40

aspear opened this issue May 29, 2019 · 1 comment
Labels

Comments

@aspear
Copy link
Contributor

aspear commented May 29, 2019

Hi! This tool is awesome, and it would be really nice to have explicit control over case conventions for paths, and then schema objects and enums. As it is, the only control over this is the global boolean "snake_case_only" which is only useful for one convention (presumably IBMs). In my company (VMware) we have many APIs that come from different products that all have their own ways of handing paths for example, one lower_camel_case, another lower_snake_case.

I propose (and have already implemented!) a couple of small backwards compatible additions:

  1. in the paths section, add a new config option "paths_case_convention" that allows explict control. The .defaultsForValidator.js changes to:
    'paths': {
    'missing_path_parameter': 'error',
    'snake_case_only': 'warning',
    'paths_case_convention': ['off', 'lower_snake_case']
    },
    The idea here is that a user could set snake_case_only to off, and then use paths_case_convention in a similar manner to the existing param_name_case_convention to explicitly control the selection for paths.

  2. Add two additional options in the spirit of the change above for the schemas section:
    'schemas': {
    ...
    'property_case_convention': [ 'off', 'lower_snake_case'],
    'enum_case_convention': [ 'off', 'lower_snake_case']
    },
    This allows you to have one convention for properties of objects (e.g. lower_snake_case), and then a separate convention for enums (e.g. upper_snake_case, 'MY_ENUM_VALUE')

This fixes #38 btw.

  1. Add additional case convention values upper_snake_case and upper_dash_case (note that my company uses upper_snake_case for enums. We don't use upper_dash_case, but while I was touching the code I figured I might as well add it so that all cases were covered)

I already have this implemented in a fork. I am implementing tests right now. I would be very happy to submit a pull request for it if you are open.

thanks,
Aaron Spear, VMware

aspear added a commit to aspear/openapi-validator that referenced this issue May 29, 2019
…perties and schema enums

This change adds support for a couple of new case conventions to round out case convention
support, upper_snake_case and upper_dash_case.  Additionally it includes support for explicit
and independent control of the case convention for paths (paths_case_convention), schema
properties (property_case_convention), and schema enums (enum_case_convention).  These options
are disabled by default so as not to impact current usage of snake_case_only and thus are
backwards compatible. In order to use them, a user must turn off the corresponding
'snake_case_only' option and enable these options.  Full automated tests are included.

Closes IBM#38, IBM#40
@dpopp07
Copy link
Member

dpopp07 commented May 29, 2019

@aspear Thanks for the issue, so glad you like the tool! Making all of the current case convention validations configurable is something we really want to do and it's been sitting in our backlog for a while - we just haven't gotten around to it. We definitely welcome that PR, I will review it soon

aspear added a commit to aspear/openapi-validator that referenced this issue May 30, 2019
…perties and schema enums

This change adds support for a couple of new case conventions to round out case convention
support, upper_snake_case and upper_dash_case.  Additionally it includes support for explicit
and independent control of the case convention for paths (paths_case_convention), schema
properties (property_case_convention), and schema enums (enum_case_convention).  These options
are disabled by default so as not to impact current usage of snake_case_only and thus are
backwards compatible. In order to use them, a user must turn off the corresponding
'snake_case_only' option and enable these options.  Full automated tests are included.

Closes IBM#38, IBM#40
dpopp07 pushed a commit that referenced this issue May 31, 2019
# [0.7.0](v0.6.0...v0.7.0) (2019-05-31)

### Features

* added explicit control of case conventions in paths, schema properties and schema enums ([ecde7da](ecde7da)), closes [#38](#38) [#40](#40)
@dpopp07 dpopp07 closed this as completed May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants