-
Notifications
You must be signed in to change notification settings - Fork 90
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
Labels
Comments
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
@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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
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.
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.
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
The text was updated successfully, but these errors were encountered: