Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Replace "behavioral" marker types with a tag #2709

Open
flobernd opened this issue Jul 11, 2024 · 0 comments
Open

Proposal: Replace "behavioral" marker types with a tag #2709

flobernd opened this issue Jul 11, 2024 · 0 comments

Comments

@flobernd
Copy link
Member

We currently have some generic marker types defined which are used to provide "behavioral" context to the generators:

/**
 * Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior
 * is used to capture this behavior while keeping the semantics of the field type.
 *
 * Depending on the target language, code generators can keep the union or remove it and leniently parse
 * strings to the target type.
 */
export type Stringified<T> = T | string

/**
 * A set of flags that can be represented as a single enum value or a set of values that are encoded
 * as a pipe-separated string
 *
 * Depending on the target language, code generators can use this hint to generate language specific
 * flags enum constructs and the corresponding (de-)serialization code.
 */
export type PipeSeparatedFlags<T> = T | string

Instead of modelling (de-)serialization behavior like this, we should introduce a proper tag to avoid unnecessary complexity (especially for languages that do not support generics).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant