@codewithagents/openapi-server 1.5.0 → 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.
@@ -1,16 +1,5 @@
1
- /** The parsed result of CLI arguments. */
2
- export type CliAction = {
3
- action: 'help';
4
- } | {
5
- action: 'version';
6
- } | {
7
- action: 'run';
8
- configFile?: string;
9
- cwd: string;
10
- } | {
11
- action: 'error';
12
- message: string;
13
- };
1
+ import { type CliAction } from '@codewithagents/openapi-gen/cli-core';
2
+ export type { CliAction };
14
3
  /**
15
4
  * Parse raw process.argv into a structured action.
16
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAEA,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GACjB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAExC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CA8BnE"}
1
+ {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,sCAAsC,CAAA;AAEvF,YAAY,EAAE,SAAS,EAAE,CAAA;AAIzB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAEnE"}
package/dist/cli-args.js CHANGED
@@ -1,4 +1,5 @@
1
- import { resolve, dirname } from 'node:path';
1
+ import { parseBaseCliArgs } from '@codewithagents/openapi-gen/cli-core';
2
+ const USAGE = 'Usage: openapi-server [--config <path-to-config.json>]';
2
3
  /**
3
4
  * Parse raw process.argv into a structured action.
4
5
  *
@@ -8,30 +9,6 @@ import { resolve, dirname } from 'node:path';
8
9
  * @param cwd the working directory to resolve paths against
9
10
  */
10
11
  export function parseCliArgs(argv, cwd) {
11
- const args = argv.slice(2);
12
- if (args.includes('--help') || args.includes('-h')) {
13
- return { action: 'help' };
14
- }
15
- if (args.includes('--version') || args.includes('-v')) {
16
- return { action: 'version' };
17
- }
18
- const configIdx = args.indexOf('--config');
19
- if (configIdx !== -1) {
20
- const next = args[configIdx + 1];
21
- if (next === undefined || next.startsWith('--')) {
22
- return {
23
- action: 'error',
24
- message: [
25
- 'Error: --config requires a file path argument',
26
- 'Usage: openapi-server [--config <path-to-config.json>]',
27
- ].join('\n'),
28
- };
29
- }
30
- const configFile = resolve(cwd, next);
31
- // Relative paths inside the config resolve from the config file's directory,
32
- // not from the shell's CWD. This matches how most tooling works.
33
- return { action: 'run', configFile, cwd: dirname(configFile) };
34
- }
35
- return { action: 'run', cwd };
12
+ return parseBaseCliArgs(argv, cwd, USAGE);
36
13
  }
37
14
  //# sourceMappingURL=cli-args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAS5C;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,GAAW;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAE1B,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;IAC3B,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC1C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;QAChC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE;oBACP,+CAA+C;oBAC/C,wDAAwD;iBACzD,CAAC,IAAI,CAAC,IAAI,CAAC;aACb,CAAA;QACH,CAAC;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QACrC,6EAA6E;QAC7E,iEAAiE;QACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAA;IAChE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;AAC/B,CAAC"}
1
+ {"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAIvF,MAAM,KAAK,GAAG,wDAAwD,CAAA;AAEtE;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,GAAW;IACtD,OAAO,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC"}
package/dist/cli.cjs CHANGED
@@ -18799,7 +18799,7 @@ function refToName(ref) {
18799
18799
  function extractPathParamsFromPath(path) {
18800
18800
  const matches = path.match(/\{([^}]+)\}/g);
18801
18801
  if (matches === null) return [];
18802
- return matches.map((m) => sanitizeOperationId(m.slice(1, -1)));
18802
+ return matches.map((m) => sanitizeOperationId2(m.slice(1, -1)));
18803
18803
  }
18804
18804
  function resolveParam(p, spec) {
18805
18805
  if (!isRef3(p)) return p;
@@ -18819,7 +18819,7 @@ function deriveServiceName(spec) {
18819
18819
  if (safePascal.endsWith("Service")) return safePascal;
18820
18820
  return `${safePascal}Service`;
18821
18821
  }
18822
- function sanitizeOperationId(id) {
18822
+ function sanitizeOperationId2(id) {
18823
18823
  const parts = id.replace(/'/g, "").split(/[^a-zA-Z0-9]+/).filter(Boolean);
18824
18824
  if (parts.length === 0) return "unknown";
18825
18825
  const [first = "", ...rest] = parts;
@@ -18828,11 +18828,11 @@ function sanitizeOperationId(id) {
18828
18828
  }
18829
18829
  function deriveMethodName(operationId, method, path) {
18830
18830
  if (operationId !== void 0 && operationId.length > 0) {
18831
- return sanitizeOperationId(operationId);
18831
+ return sanitizeOperationId2(operationId);
18832
18832
  }
18833
- return deriveOperationName(method, path);
18833
+ return deriveOperationName2(method, path);
18834
18834
  }
18835
- function deriveOperationName(method, path) {
18835
+ function deriveOperationName2(method, path) {
18836
18836
  const prefixMap = {
18837
18837
  get: "get",
18838
18838
  post: "create",
@@ -18846,13 +18846,13 @@ function deriveOperationName(method, path) {
18846
18846
  const paramMatches = seg.match(/\{([^}]+)\}/g);
18847
18847
  if (paramMatches !== null && !(seg.startsWith("{") && seg.endsWith("}"))) {
18848
18848
  return paramMatches.map((m) => {
18849
- const name = sanitizeOperationId(m.slice(1, -1));
18849
+ const name = sanitizeOperationId2(m.slice(1, -1));
18850
18850
  return "By" + name.charAt(0).toUpperCase() + name.slice(1);
18851
18851
  }).join("");
18852
18852
  }
18853
18853
  if (seg.startsWith("{") && seg.endsWith("}")) {
18854
18854
  const name = seg.slice(1, -1);
18855
- const sanitized = sanitizeOperationId(name);
18855
+ const sanitized = sanitizeOperationId2(name);
18856
18856
  return "By" + sanitized.charAt(0).toUpperCase() + sanitized.slice(1);
18857
18857
  }
18858
18858
  return toTypeName(seg);
@@ -19062,7 +19062,7 @@ function deriveServiceName2(spec) {
19062
19062
  if (safePascal.endsWith("Service")) return safePascal;
19063
19063
  return `${safePascal}Service`;
19064
19064
  }
19065
- function sanitizeOperationId2(id) {
19065
+ function sanitizeOperationId3(id) {
19066
19066
  const parts = id.replace(/'/g, "").split(/[^a-zA-Z0-9]+/).filter(Boolean);
19067
19067
  if (parts.length === 0) return "unknown";
19068
19068
  const [first = "", ...rest] = parts;
@@ -19071,11 +19071,11 @@ function sanitizeOperationId2(id) {
19071
19071
  }
19072
19072
  function deriveMethodName2(operationId, method, path) {
19073
19073
  if (operationId !== void 0 && operationId.length > 0) {
19074
- return sanitizeOperationId2(operationId);
19074
+ return sanitizeOperationId3(operationId);
19075
19075
  }
19076
- return deriveOperationName2(method, path);
19076
+ return deriveOperationName3(method, path);
19077
19077
  }
19078
- function deriveOperationName2(method, path) {
19078
+ function deriveOperationName3(method, path) {
19079
19079
  const prefixMap = {
19080
19080
  get: "get",
19081
19081
  post: "create",
@@ -19089,13 +19089,13 @@ function deriveOperationName2(method, path) {
19089
19089
  const paramMatches = seg.match(/\{([^}]+)\}/g);
19090
19090
  if (paramMatches !== null && !(seg.startsWith("{") && seg.endsWith("}"))) {
19091
19091
  return paramMatches.map((m) => {
19092
- const name = sanitizeOperationId2(m.slice(1, -1));
19092
+ const name = sanitizeOperationId3(m.slice(1, -1));
19093
19093
  return "By" + name.charAt(0).toUpperCase() + name.slice(1);
19094
19094
  }).join("");
19095
19095
  }
19096
19096
  if (seg.startsWith("{") && seg.endsWith("}")) {
19097
19097
  const name = seg.slice(1, -1);
19098
- const sanitized = sanitizeOperationId2(name);
19098
+ const sanitized = sanitizeOperationId3(name);
19099
19099
  return "By" + sanitized.charAt(0).toUpperCase() + sanitized.slice(1);
19100
19100
  }
19101
19101
  return toTypeName(seg);
@@ -19799,9 +19799,9 @@ async function generate2(cwd, configPath) {
19799
19799
  console.log(`Done! Generated ${generatedFiles.length} file(s).`);
19800
19800
  }
19801
19801
 
19802
- // src/cli-args.ts
19802
+ // ../openapi-gen/dist/cli-core.js
19803
19803
  var import_node_path3 = require("node:path");
19804
- function parseCliArgs(argv, cwd) {
19804
+ function parseBaseCliArgs(argv, cwd, usage) {
19805
19805
  const args = argv.slice(2);
19806
19806
  if (args.includes("--help") || args.includes("-h")) {
19807
19807
  return { action: "help" };
@@ -19815,10 +19815,7 @@ function parseCliArgs(argv, cwd) {
19815
19815
  if (next === void 0 || next.startsWith("--")) {
19816
19816
  return {
19817
19817
  action: "error",
19818
- message: [
19819
- "Error: --config requires a file path argument",
19820
- "Usage: openapi-server [--config <path-to-config.json>]"
19821
- ].join("\n")
19818
+ message: ["Error: --config requires a file path argument", usage].join("\n")
19822
19819
  };
19823
19820
  }
19824
19821
  const configFile = (0, import_node_path3.resolve)(cwd, next);
@@ -19827,6 +19824,12 @@ function parseCliArgs(argv, cwd) {
19827
19824
  return { action: "run", cwd };
19828
19825
  }
19829
19826
 
19827
+ // src/cli-args.ts
19828
+ var USAGE = "Usage: openapi-server [--config <path-to-config.json>]";
19829
+ function parseCliArgs(argv, cwd) {
19830
+ return parseBaseCliArgs(argv, cwd, USAGE);
19831
+ }
19832
+
19830
19833
  // src/cli.ts
19831
19834
  var parsed = parseCliArgs(process.argv, process.cwd());
19832
19835
  if (parsed.action === "help") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codewithagents/openapi-server",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Generate typed server-side service interfaces and framework routers from OpenAPI 3.1",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "openapi-types": "^12.1.3",
20
20
  "prettier": "^3.5.3",
21
- "@codewithagents/openapi-gen": "4.8.0"
21
+ "@codewithagents/openapi-gen": "4.9.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@stryker-mutator/core": "^9.6.1",