Skip to content

Commit

Permalink
Wrap type keys with quotes when includes a dash (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
annajolly authored Oct 23, 2024
1 parent 2378a4b commit 8475614
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ A major release with breaking changes. Involves updating type signatures to matc
## 3.4.0

- Update all packages

## 3.5.1

- Fix types generator when yaml file key includes dashes
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rapini",
"version": "3.5.0",
"version": "3.5.1",
"description": "Generate React Query hooks, SWR hooks, Axios requests and Typescript types from OpenAPI files",
"bin": "dist/cli.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions spec/common/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type Cat = Pet & {
};
export type Dog = Pet & {
bark?: string;
"is-cute"?: boolean;
};
export type MyResponseType = Cat | Dog;
export type MyResponseTypeTwo = Cat | Dog;
Expand Down Expand Up @@ -194,6 +195,9 @@ describe("makeTypes", () => {
bark: {
type: "string",
},
"is-cute": {
type: "boolean",
},
},
},
],
Expand Down
4 changes: 3 additions & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function createPropertySignature(
) {
return ts.factory.createPropertySignature(
/*modifiers*/ undefined,
/*name*/ ts.factory.createIdentifier(name),
/*name*/ name.includes("-")
? ts.factory.createStringLiteral(name)
: ts.factory.createIdentifier(name),
/*questionToken*/ required
? undefined
: ts.factory.createToken(ts.SyntaxKind.QuestionToken),
Expand Down

0 comments on commit 8475614

Please sign in to comment.