Add `x-enum-varnames` support
Currently, json-schema-to-typescript uses a custom tsEnumNames extension for naming enum members. However, this extension is specific only to this library. Other major OpenAPI generators (1, 2) have adopted x-enum-varnames for the same purpose, so this PR brings json-schema-to-typescript in line with them.
This PR addresses feature request #200.
@bcherny Would I add the following rule:
rules.set('Convert tsEnumNames -> x-enum-varnames', schema => {
if (schema.tsEnumNames) {
schema['x-enum-varnames'] = schema.tsEnumNames
delete schema.tsEnumNames
}
})
And then be able to always reference ['x-enum-varnames'], even when the spec actually uses .tsEnumNames?
Yup, exactly. Don't forget to validate when you do that too, to make sure the schema doesn't already have conflicting x-enum-varnames and tsEnumNames defined.
Is there a way to log a deprecation warning so that consumers know tsEnumNames may eventually be removed?
@bcherny are you OK with the way I'm handling the existence of both x-enum-varnames and tsEnumNames? I figured throwing an error would be fine
Hi, is there any chance it'll get merged soon?
@galah92 I have a couple open questions for @bcherny. I can pick this back up when he answers
@galah92 I have a couple open questions for @bcherny. I can pick this back up when he answers
Sorry I missed this! The status was Changes Requested, so I missed your comments.
No worries, @bcherny!
I started taking a look at this PR again and I'm having a hard time understanding my changes 😅. I think it'd take some effort to ramp myself back up, unfortunately. If this is something you could bang out quickly, then that's probably best. But if that's not the case then I can try to work on this again