Skip to content

Commit

Permalink
chore: use optional chain
Browse files Browse the repository at this point in the history
  • Loading branch information
princerajpoot20 committed Oct 3, 2023
1 parent 21948c7 commit 20f5eed
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions examples/csharp-overwrite-enum-naming/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { CSharpGenerator } from '../../src';
import { DefaultEnumKeyConstraints } from '../../src/generators/csharp/constrainer/EnumConstrainer';

const generator = new CSharpGenerator({
constraints: {
enumKey: ({ enumModel, enumKey }) => {
// Lets see if an enum has an associated custom name
const hasCustomName =
enumModel.originalInput !== undefined &&
enumModel.originalInput['x-enumNames'] !== undefined;
const hasCustomName = enumModel?.originalInput?.['x-enumNames'] !== undefined;
if (hasCustomName) {
// Lets see if the specific value has an associated name
const customName = enumModel.originalInput['x-enumNames'][enumKey];
Expand Down

0 comments on commit 20f5eed

Please sign in to comment.