Enum is not generated
See original GitHub issueHi,
I like this tool a lot, but I hit a limitation I can’t work around. My interfaces are generated from other service and I can’t refactor them to avoid enums. And, as header says, enums are not generated properly by ts-interface-builder.
interface and enum source:
export interface LimitInput {
amount: number;
period?: Period | null;
periodEnds?: string | null;
}
export enum Period {
MONTH = "MONTH",
WEEK = "WEEK",
}
generated checkers:
export const LimitInput = t.iface([], {
"amount": "number",
"period": t.opt(t.union("Period", "null")),
"periodEnds": t.opt(t.union("string", "null")),
});
const exportedTypeSuite: t.ITypeSuite = {
LimitInput
};
As you see Period enum is used in validation, but is not included in exportedTypeSuite
. Is this a bug? Or are there any options I can use to include enums in output? Do I miss something?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Swagger-codegen not generating enums as enum type
It seems once I set stringEnums to true in the openapi-generator, it actually generates enums and not type.
Read more >enum — Support for enumerations — Python 3.11.1 ...
Enumerations are created either by using class syntax, ... Even though we can use class syntax to create Enums, Enums are not normal...
Read more >Enums - Swagger
You can use the enum keyword to specify possible values of a request parameter or a model property. For example, the sort parameter...
Read more >Enum Types - Java™ Tutorials
Note: All enums implicitly extend java.lang.Enum . Because a class can only extend one parent (see Declaring Classes), the Java language does not...
Read more >KJS: .d.ts generation not working for enum classes : KT-37916
A proper Typescript definition should be generated instead of any . Kotlin code: @JsExport enum class TestEnum { FOO, BAR, BAZ }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Enum support added in v0.1.6 of ts-interface-builder, and v0.1.5 of ts-interface-checker. Closing this request, but please open a new one if it’s not enough for what you need.
OK OK, I think it’s not too hard. I’ll give it a shot 😃