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

Adding an option to generate typescript enum instead of union of strings #308

Merged
merged 4 commits into from
Oct 28, 2022
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ oazapfts <spec> [filename]
Options:
--exclude, -e tag to exclude
--include, -i tag to include
--optimistic
--useEnumType
```

Where `<spec>` is the URL or local path of an OpenAPI or Swagger spec (in either json or yml) and `<filename>` is the location of the `.ts` file to be generated. If the filename is omitted, the code is written to stdout.

Use the `useEnumType` option to generate typescript enums instead of union of values.

## Overriding the defaults

The generated file exports a `defaults` constant that can be used to override the `basePath`, provide a custom `fetch` implementation or to send additional headers with each request:
Expand Down
1 change: 1 addition & 0 deletions demo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type Pet = {
tags?: Tag[];
status?: "available" | "pending" | "sold";
animal?: true;
size?: "P" | "M" | "G";
};
export type ApiResponse = {
code?: number;
Expand Down
Loading