kontent-ai / kontent-ai/model-generator-js

Support Optional Elements

Open
#39 4 comments 1 reaction 1 assignee Claimed by @Enngage View on GitHub
enhancement on-hold
Dominant language
TypeScript
Stars
13
Forks
11
PR merge metrics
No merged PRs in 30d

Description

### Motivation

Currently, all content element properties are generated like they are required, i.e. that they will always have a value, yet kontent.ai allows you to mark whether a content element is required or not. Non required properties should be optional in the model.

### Proposed solution

`myElement: Type` for required elements and `myElement?: Type` for optional elements.

### Additional Comments

This is likely a breaking change for consumers, especially those running strict Typescript because they will now have to write code to handle checking whether optional properties have a value or not.

This could potentially be offset by adding a CLI flag for supporting optional elements so this feature is opt in.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.