@sebspark/openapi-typegen 1.11.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -13
  2. package/package.json +5 -7
package/dist/index.js CHANGED
@@ -28,14 +28,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  classname: () => classname,
34
34
  filename: () => filename,
35
35
  generate: () => generate2,
36
36
  generateTypescript: () => generateTypescript
37
37
  });
38
- module.exports = __toCommonJS(src_exports);
38
+ module.exports = __toCommonJS(index_exports);
39
39
  var import_promises = require("fs/promises");
40
40
  var import_node_path = require("path");
41
41
  var import_change_case2 = require("change-case");
@@ -379,13 +379,12 @@ var argsOptional = (args) => (
379
379
 
380
380
  // src/generator/client.ts
381
381
  var generateClient = (name, paths) => {
382
- var _a;
383
382
  const groupedCalls = {};
384
383
  for (const path of paths) {
385
384
  if (!groupedCalls[path.method]) {
386
385
  groupedCalls[path.method] = [];
387
386
  }
388
- (_a = groupedCalls[path.method]) == null ? void 0 : _a.push(generateCall(path));
387
+ groupedCalls[path.method]?.push(generateCall(path));
389
388
  }
390
389
  const client = [];
391
390
  const methods = Object.keys(groupedCalls).map(serializeValue).join(OR);
@@ -578,7 +577,6 @@ var parseSchema = (name, schemaOrRef, generateDocs2 = true) => {
578
577
  }
579
578
  };
580
579
  var parseObjectSchema = (name, schema) => {
581
- var _a;
582
580
  const type = {
583
581
  name,
584
582
  type: "object",
@@ -599,7 +597,7 @@ var parseObjectSchema = (name, schema) => {
599
597
  if (schema.anyOf) {
600
598
  type.oneOf = schema.anyOf.flatMap((s) => parsePropertyType(s));
601
599
  }
602
- if ((_a = schema.discriminator) == null ? void 0 : _a.mapping) {
600
+ if (schema.discriminator?.mapping) {
603
601
  const mapping = {};
604
602
  for (const [prop, ref] of Object.entries(schema.discriminator.mapping)) {
605
603
  mapping[prop] = { type: parseRef(ref) };
@@ -727,8 +725,7 @@ var parseParameter = (name, schema) => {
727
725
 
728
726
  // src/parser/args.ts
729
727
  var parseArgs = (path, components) => {
730
- var _a, _b;
731
- if (!((_a = path.parameters) == null ? void 0 : _a.length) && !((_b = path.security) == null ? void 0 : _b.length) && !path.requestBody)
728
+ if (!path.parameters?.length && !path.security?.length && !path.requestBody)
732
729
  return void 0;
733
730
  const args = joinArgs([
734
731
  parseParameters2(path.parameters, components),
@@ -837,7 +834,6 @@ var parseParameters2 = (parameters = [], components = {}) => {
837
834
  return args;
838
835
  };
839
836
  var parseRequestBody = (requestBody, components = {}) => {
840
- var _a, _b;
841
837
  const args = {};
842
838
  if (!requestBody) return args;
843
839
  const ref = requestBody.$ref;
@@ -868,7 +864,7 @@ var parseRequestBody = (requestBody, components = {}) => {
868
864
  }
869
865
  }
870
866
  }
871
- if (((_a = bodyArgs.allOf) == null ? void 0 : _a.length) || ((_b = bodyArgs.oneOf) == null ? void 0 : _b.length) || bodyArgs.properties.length) {
867
+ if (bodyArgs.allOf?.length || bodyArgs.oneOf?.length || bodyArgs.properties.length) {
872
868
  args.body = bodyArgs;
873
869
  }
874
870
  }
@@ -885,14 +881,13 @@ var parseResponseBodies = (responses = {}) => {
885
881
  return bodies;
886
882
  };
887
883
  var parseResponseBody = (name, response) => {
888
- var _a, _b;
889
884
  const ref = response.$ref;
890
885
  if (ref) return { type: parseRef(ref) };
891
886
  const responseObject = response;
892
887
  const body = {};
893
888
  if (name) body.name = name;
894
889
  if (responseObject.description) body.description = responseObject.description;
895
- if ((_b = (_a = responseObject.content) == null ? void 0 : _a["application/json"]) == null ? void 0 : _b.schema) {
890
+ if (responseObject.content?.["application/json"]?.schema) {
896
891
  const schema = responseObject.content["application/json"].schema;
897
892
  body.data = parseSchema(void 0, schema);
898
893
  }
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@sebspark/openapi-typegen",
3
- "version": "1.11.0",
3
+ "version": "2.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "bin": {
8
- "openapi-typegen": "./cli.mjs"
9
- },
7
+ "bin": "./cli.mjs",
10
8
  "files": [
11
9
  "dist",
12
10
  "cli.mjs"
@@ -19,7 +17,7 @@
19
17
  "typecheck": "vitest --typecheck.only --passWithNoTests"
20
18
  },
21
19
  "devDependencies": {
22
- "@types/yargs": "17.0.32",
20
+ "@types/yargs": "17.0.33",
23
21
  "tsconfig": "*"
24
22
  },
25
23
  "dependencies": {
@@ -27,8 +25,8 @@
27
25
  "boxen": "<6",
28
26
  "chalk": "<5",
29
27
  "change-case": "4.1.2",
30
- "prettier": "3.3.2",
31
- "yaml": "2.5.0",
28
+ "prettier": "3.5.2",
29
+ "yaml": "2.7.0",
32
30
  "yargs": "17.7.2"
33
31
  }
34
32
  }