Skip to content

fix(enums): take in and pass correct values to service generator #73

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

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Options:
-c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
--request <value> Path to custom request file
--useDateType Use Date type instead of string for date types for models, this will not convert the data to a Date object
--enums Generate JavaScript objects from enum definitions?
--enums <value> Generate JavaScript objects from enum definitions? ['javascript', 'typescript']
--base <value> Manually set base in OpenAPI config instead of inferring from server value
--serviceResponse <value> Define shape of returned value from service calls ['body', 'generics', 'response']
--operationId Use operation ID to generate operation names?
Expand Down
9 changes: 7 additions & 2 deletions src/cli.mts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ async function setupProgram() {
"--base <value>",
"Manually set base in OpenAPI config instead of inferring from server value"
)
.option("--enums", "Generate JavaScript objects from enum definitions?")
.addOption(
new Option(
"--enums <value>",
"Generate JavaScript objects from enum definitions?"
).choices(["javascript", "typescript"])
)
.option(
"--useDateType",
"Use Date type instead of string for date types for models, this will not convert the data to a Date object"
Expand All @@ -54,7 +59,7 @@ async function setupProgram() {

const options = program.opts<LimitedUserConfig>();

generate(options, version);
await generate(options, version);
}

setupProgram();
2 changes: 2 additions & 0 deletions src/generate.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export async function generate(options: UserConfig, version: string) {
(acc as any)[typedKey] = true;
} else if (value === "false") {
(acc as any)[typedKey] = false;
} else {
(acc as any)[typedKey] = typedValue;
}
return acc;
},
Expand Down