[REQ] Standardize vendor extension naming conventions
Is your feature request related to a problem? Please describe.
Vendor extensions are not intuitive, and are case sensitive. They're also not fully documented on the wiki at https://github.com/OpenAPITools/openapi-generator/wiki/Vendor-Extensions
Describe the solution you'd like
- We should standardize this to avoid confusion, probably kebab lower case (
x-objc-operationid
rather thanx-objc-operationId
). - We may want to require that all words are separated by hyphen (
x-objc-operation-id
rather thanx-objc-operationid
).
Describe alternatives you've considered
none
Additional context
The issue is apparent in a vendor extension such as x-mysqlSchema
. If someone mistakenly defines this as x-mysql-schema
or x-mysqlschema
, the configuration will not be accepted. However, if we normalize from the current x-mysqlSchema
to kebab-cased then lower-case this, the result is x-mysql-schema
.
Test examples:
@Test
public void testVendorExtensionConventionConversion(){
String input = "x-mysqlSchema";
CaseFormat formatter = CaseFormat.LOWER_CAMEL;
String output = formatter.converterTo(CaseFormat.LOWER_HYPHEN).convert(input);
Assert.assertEquals(output, "x-mysql-schema");
}
@Test
public void testVendorExtensionConventionNoop(){
String input = "x-mysql-schema";
CaseFormat formatter = CaseFormat.LOWER_CAMEL;
String output = formatter.converterTo(CaseFormat.LOWER_HYPHEN).convert(input);
Assert.assertEquals(output, "x-mysql-schema");
}
@Test
public void testVendorExtensionUnknown(){
String input = "x-mySQLSchema";
List<String> supportedVendorExtensions = Arrays.asList("x-mysql-schema");
CaseFormat formatter = CaseFormat.LOWER_CAMEL;
String output = formatter.converterTo(CaseFormat.LOWER_HYPHEN).convert(input);
// In implementation, we'd want to log a warning.
Assert.assertFalse(supportedVendorExtensions.contains(output), "Invalid vendor extension should fail.");
}
We could easily make the change in 5.0 and maintain currently documented extensions. We'd want to wait for 5.0, though, because templates will need to be updated to lower cased vendor extensions.