@7nohe/openapi-react-query-codegen 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,6 +52,7 @@ Options:
52
52
  --operationId Use operation ID to generate operation names?
53
53
  --serviceResponse <value> Define shape of returned value from service calls (choices: "body", "response", default: "body")
54
54
  --base <value> Manually set base in OpenAPI config instead of inferring from server value
55
+ --enums <value> Generate JavaScript objects from enum definitions? ['javascript', 'typescript', 'typescript+namespace']
55
56
  --enums <value> Generate JavaScript objects from enum definitions? (choices: "javascript", "typescript")
56
57
  --useDateType Use Date type instead of string for date types for models, this will not convert the data to a Date object
57
58
  --debug Run in debug mode?
package/dist/cli.mjs CHANGED
@@ -29,7 +29,7 @@ async function setupProgram() {
29
29
  .choices(["body", "response"])
30
30
  .default("body"))
31
31
  .option("--base <value>", "Manually set base in OpenAPI config instead of inferring from server value")
32
- .addOption(new Option("--enums <value>", "Generate JavaScript objects from enum definitions?").choices(["javascript", "typescript"]))
32
+ .addOption(new Option("--enums <value>", "Generate JavaScript objects from enum definitions?").choices(["javascript", "typescript", "typescript+namespace"]))
33
33
  .option("--useDateType", "Use Date type instead of string for date types for models, this will not convert the data to a Date object")
34
34
  .option("--debug", "Run in debug mode?")
35
35
  .option("--noSchemas", "Disable generating JSON schemas")
@@ -24,7 +24,7 @@ export const createUseMutation = ({ className, method, jsDoc, }) => {
24
24
  const paramNodes = extractPropertiesFromObjectParam(param);
25
25
  return paramNodes.map((refParam) => ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier(refParam.name), refParam.optional
26
26
  ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
27
- : undefined, ts.factory.createTypeReferenceNode(getShortType(refParam.type.getText(param)))));
27
+ : undefined, ts.factory.createTypeReferenceNode(getShortType(refParam.type?.getText(param) ?? ""))));
28
28
  }))
29
29
  : ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword);
30
30
  const exportHook = ts.factory.createVariableStatement([ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
@@ -38,7 +38,7 @@ export function getRequestParamFromMethod(method, pageParam) {
38
38
  .filter((p) => p.name !== pageParam)
39
39
  .map((refParam) => ({
40
40
  name: refParam.name,
41
- typeName: getShortType(refParam.type.getText()),
41
+ typeName: getShortType(refParam.type?.getText() ?? ""),
42
42
  optional: refParam.optional,
43
43
  }));
44
44
  });
package/dist/generate.mjs CHANGED
@@ -26,6 +26,7 @@ export async function generate(options, version) {
26
26
  services: {
27
27
  export: true,
28
28
  response: formattedOptions.serviceResponse,
29
+ asClass: true,
29
30
  },
30
31
  types: {
31
32
  dates: formattedOptions.useDateType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7nohe/openapi-react-query-codegen",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "OpenAPI React Query Codegen",
5
5
  "keywords": [
6
6
  "codegen",
@@ -31,7 +31,7 @@
31
31
  "examples/*"
32
32
  ],
33
33
  "dependencies": {
34
- "@hey-api/openapi-ts": "0.45.1"
34
+ "@hey-api/openapi-ts": "0.52.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@biomejs/biome": "^1.7.2",
@@ -41,9 +41,9 @@
41
41
  "glob": "^10.3.10",
42
42
  "lefthook": "^1.6.10",
43
43
  "rimraf": "^5.0.5",
44
- "ts-morph": "^22.0.0",
44
+ "ts-morph": "^23.0.0",
45
45
  "ts-node": "^10.9.2",
46
- "typescript": "^5.3.3",
46
+ "typescript": "^5.5.4",
47
47
  "vitest": "^1.5.0"
48
48
  },
49
49
  "peerDependencies": {