Skip to content

Commit

Permalink
Default Enum Values to Name (#104)
Browse files Browse the repository at this point in the history
* Use key as default value for enums

* Add changelog entry
  • Loading branch information
daogrady authored Nov 13, 2023
1 parent 75b04fa commit b682251
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

### Added
### Fixed
- Now using names of enum values in generated _index.js_ files if no explicit value is present

## Version 0.11.1 - 2023-10-12

### Changed

### Added
### Fixed
Fixed how service names are exported as default export
- Fixed how service names are exported as default export

## Version 0.11.0 - 2023-10-10

Expand Down
2 changes: 1 addition & 1 deletion lib/components/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const propertyToAnonymousEnumName = (entity, property) => `${entity}_${property}
*/
const isInlineEnumType = (element, csn) => element.enum && !(element.type in csn.definitions)

const stringifyEnumImplementation = (name, enm) => `module.exports.${name} = Object.fromEntries(Object.entries(${enm}).map(([k,v]) => [k,v.val]))`
const stringifyEnumImplementation = (name, enm) => `module.exports.${name} = Object.fromEntries(Object.entries(${enm}).map(([k,v]) => [k,v.val??k]))`

/**
* @param {string} name
Expand Down

0 comments on commit b682251

Please sign in to comment.