diff --git a/changelog.md b/changelog.md index 9c72486..7f628f1 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/package-lock.json b/package-lock.json index 40bfd48..1d10e55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rapini", - "version": "3.5.0", + "version": "3.5.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rapini", - "version": "3.5.0", + "version": "3.5.1", "license": "Apache-2.0", "dependencies": { "@apidevtools/swagger-parser": "^10.1.0", diff --git a/package.json b/package.json index cec3c62..91b69c4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/spec/common/types.spec.ts b/spec/common/types.spec.ts index c9fc4f9..8e2d7e5 100644 --- a/spec/common/types.spec.ts +++ b/spec/common/types.spec.ts @@ -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; @@ -194,6 +195,9 @@ describe("makeTypes", () => { bark: { type: "string", }, + "is-cute": { + type: "boolean", + }, }, }, ], diff --git a/src/common/types.ts b/src/common/types.ts index 78b5673..3cd0914 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -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),