@zuplo/cli 6.62.7 → 6.62.9

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 (134) hide show
  1. package/README.md +36 -4
  2. package/dist/__tests__/import-openapi-utils.test.js +1 -2
  3. package/dist/__tests__/import-openapi-utils.test.js.map +1 -1
  4. package/dist/__tests__/import-openapi.test.js +1 -5
  5. package/dist/__tests__/import-openapi.test.js.map +1 -1
  6. package/dist/cli.js +2 -0
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cmds/open-api/convert.d.ts +9 -0
  9. package/dist/cmds/open-api/convert.d.ts.map +1 -0
  10. package/dist/cmds/open-api/convert.js +66 -0
  11. package/dist/cmds/open-api/convert.js.map +1 -0
  12. package/dist/cmds/open-api/index.d.ts +4 -0
  13. package/dist/cmds/open-api/index.d.ts.map +1 -0
  14. package/dist/cmds/open-api/index.js +15 -0
  15. package/dist/cmds/open-api/index.js.map +1 -0
  16. package/dist/cmds/open-api/merge.d.ts +9 -0
  17. package/dist/cmds/open-api/merge.d.ts.map +1 -0
  18. package/dist/cmds/open-api/merge.js +57 -0
  19. package/dist/cmds/open-api/merge.js.map +1 -0
  20. package/dist/cmds/open-api/overlay.d.ts +9 -0
  21. package/dist/cmds/open-api/overlay.d.ts.map +1 -0
  22. package/dist/cmds/open-api/overlay.js +85 -0
  23. package/dist/cmds/open-api/overlay.js.map +1 -0
  24. package/dist/cmds/source/import-openapi.d.ts +1 -0
  25. package/dist/cmds/source/import-openapi.d.ts.map +1 -1
  26. package/dist/cmds/source/import-openapi.js +6 -9
  27. package/dist/cmds/source/import-openapi.js.map +1 -1
  28. package/dist/cmds/source/migrate.js +1 -1
  29. package/dist/cmds/source/migrate.js.map +1 -1
  30. package/dist/common/file-format.d.ts +25 -0
  31. package/dist/common/file-format.d.ts.map +1 -0
  32. package/dist/common/file-format.js +72 -0
  33. package/dist/common/file-format.js.map +1 -0
  34. package/dist/common/runner.d.ts.map +1 -0
  35. package/dist/common/runner.js.map +1 -0
  36. package/dist/common/utils/stringify-config.d.ts.map +1 -0
  37. package/dist/common/utils/stringify-config.js.map +1 -0
  38. package/dist/common/utils/stringify-config.test.d.ts.map +1 -0
  39. package/dist/common/utils/stringify-config.test.js.map +1 -0
  40. package/dist/open-api/convert/convert-engine.d.ts +26 -0
  41. package/dist/open-api/convert/convert-engine.d.ts.map +1 -0
  42. package/dist/open-api/convert/convert-engine.js +20 -0
  43. package/dist/open-api/convert/convert-engine.js.map +1 -0
  44. package/dist/open-api/convert/convert-engine.spec.d.ts +2 -0
  45. package/dist/open-api/convert/convert-engine.spec.d.ts.map +1 -0
  46. package/dist/open-api/convert/convert-engine.spec.js +268 -0
  47. package/dist/open-api/convert/convert-engine.spec.js.map +1 -0
  48. package/dist/open-api/convert/handler.d.ts +9 -0
  49. package/dist/open-api/convert/handler.d.ts.map +1 -0
  50. package/dist/open-api/convert/handler.js +54 -0
  51. package/dist/open-api/convert/handler.js.map +1 -0
  52. package/dist/open-api/convert/handler.spec.d.ts +2 -0
  53. package/dist/open-api/convert/handler.spec.d.ts.map +1 -0
  54. package/dist/open-api/convert/handler.spec.js +291 -0
  55. package/dist/open-api/convert/handler.spec.js.map +1 -0
  56. package/dist/open-api/merge/ajv.d.ts.map +1 -0
  57. package/dist/open-api/merge/ajv.js.map +1 -0
  58. package/dist/open-api/merge/handler.d.ts +9 -0
  59. package/dist/open-api/merge/handler.d.ts.map +1 -0
  60. package/dist/{source/import-openapi → open-api/merge}/handler.js +16 -42
  61. package/dist/open-api/merge/handler.js.map +1 -0
  62. package/dist/open-api/merge/handler.spec.d.ts +2 -0
  63. package/dist/open-api/merge/handler.spec.d.ts.map +1 -0
  64. package/dist/open-api/merge/handler.spec.js +335 -0
  65. package/dist/open-api/merge/handler.spec.js.map +1 -0
  66. package/dist/open-api/merge/interfaces.d.ts.map +1 -0
  67. package/dist/open-api/merge/interfaces.js.map +1 -0
  68. package/dist/open-api/merge/merge-engine.d.ts +23 -0
  69. package/dist/open-api/merge/merge-engine.d.ts.map +1 -0
  70. package/dist/open-api/merge/merge-engine.js +33 -0
  71. package/dist/open-api/merge/merge-engine.js.map +1 -0
  72. package/dist/open-api/merge/merge-engine.spec.d.ts +2 -0
  73. package/dist/open-api/merge/merge-engine.spec.d.ts.map +1 -0
  74. package/dist/open-api/merge/merge-engine.spec.js +117 -0
  75. package/dist/open-api/merge/merge-engine.spec.js.map +1 -0
  76. package/dist/open-api/merge/utils.d.ts.map +1 -0
  77. package/dist/open-api/merge/utils.js.map +1 -0
  78. package/dist/open-api/overlay/handler.d.ts +10 -0
  79. package/dist/open-api/overlay/handler.d.ts.map +1 -0
  80. package/dist/open-api/overlay/handler.js +92 -0
  81. package/dist/open-api/overlay/handler.js.map +1 -0
  82. package/dist/open-api/overlay/handler.spec.d.ts +2 -0
  83. package/dist/open-api/overlay/handler.spec.d.ts.map +1 -0
  84. package/dist/open-api/overlay/handler.spec.js +304 -0
  85. package/dist/open-api/overlay/handler.spec.js.map +1 -0
  86. package/dist/open-api/overlay/overlay-engine.d.ts +55 -0
  87. package/dist/open-api/overlay/overlay-engine.d.ts.map +1 -0
  88. package/dist/open-api/overlay/overlay-engine.js +280 -0
  89. package/dist/open-api/overlay/overlay-engine.js.map +1 -0
  90. package/dist/open-api/overlay/overlay-engine.spec.d.ts +2 -0
  91. package/dist/open-api/overlay/overlay-engine.spec.d.ts.map +1 -0
  92. package/dist/open-api/overlay/overlay-engine.spec.js +609 -0
  93. package/dist/open-api/overlay/overlay-engine.spec.js.map +1 -0
  94. package/dist/source/migrate/dev-portal/handler.d.ts.map +1 -0
  95. package/dist/{cmds/source/migrate → source/migrate/dev-portal}/handler.js +53 -4
  96. package/dist/source/migrate/dev-portal/handler.js.map +1 -0
  97. package/dist/{cmds/source/migrate → source/migrate/dev-portal}/types.d.ts +12 -1
  98. package/dist/source/migrate/dev-portal/types.d.ts.map +1 -0
  99. package/dist/source/migrate/dev-portal/types.js.map +1 -0
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/package.json +5 -4
  102. package/dist/cmds/source/migrate/handler.d.ts.map +0 -1
  103. package/dist/cmds/source/migrate/handler.js.map +0 -1
  104. package/dist/cmds/source/migrate/runner.d.ts.map +0 -1
  105. package/dist/cmds/source/migrate/runner.js.map +0 -1
  106. package/dist/cmds/source/migrate/stringify-config.d.ts.map +0 -1
  107. package/dist/cmds/source/migrate/stringify-config.js.map +0 -1
  108. package/dist/cmds/source/migrate/stringify-config.test.d.ts.map +0 -1
  109. package/dist/cmds/source/migrate/stringify-config.test.js.map +0 -1
  110. package/dist/cmds/source/migrate/types.d.ts.map +0 -1
  111. package/dist/cmds/source/migrate/types.js.map +0 -1
  112. package/dist/source/import-openapi/ajv.d.ts.map +0 -1
  113. package/dist/source/import-openapi/ajv.js.map +0 -1
  114. package/dist/source/import-openapi/handler.d.ts +0 -13
  115. package/dist/source/import-openapi/handler.d.ts.map +0 -1
  116. package/dist/source/import-openapi/handler.js.map +0 -1
  117. package/dist/source/import-openapi/interfaces.d.ts.map +0 -1
  118. package/dist/source/import-openapi/interfaces.js.map +0 -1
  119. package/dist/source/import-openapi/utils.d.ts.map +0 -1
  120. package/dist/source/import-openapi/utils.js.map +0 -1
  121. /package/dist/{cmds/source/migrate → common}/runner.d.ts +0 -0
  122. /package/dist/{cmds/source/migrate → common}/runner.js +0 -0
  123. /package/dist/{cmds/source/migrate → common/utils}/stringify-config.d.ts +0 -0
  124. /package/dist/{cmds/source/migrate → common/utils}/stringify-config.js +0 -0
  125. /package/dist/{cmds/source/migrate → common/utils}/stringify-config.test.d.ts +0 -0
  126. /package/dist/{cmds/source/migrate → common/utils}/stringify-config.test.js +0 -0
  127. /package/dist/{source/import-openapi → open-api/merge}/ajv.d.ts +0 -0
  128. /package/dist/{source/import-openapi → open-api/merge}/ajv.js +0 -0
  129. /package/dist/{source/import-openapi → open-api/merge}/interfaces.d.ts +0 -0
  130. /package/dist/{source/import-openapi → open-api/merge}/interfaces.js +0 -0
  131. /package/dist/{source/import-openapi → open-api/merge}/utils.d.ts +0 -0
  132. /package/dist/{source/import-openapi → open-api/merge}/utils.js +0 -0
  133. /package/dist/{cmds/source/migrate → source/migrate/dev-portal}/handler.d.ts +0 -0
  134. /package/dist/{cmds/source/migrate → source/migrate/dev-portal}/types.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-engine.spec.js","sourceRoot":"","sources":["../../../src/open-api/convert/convert-engine.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;YACrD,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,CAAC;YAClE,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;YACrD,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,CAAC;YAClE,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,G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CAAC;YAClE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,CAAC,WAAW,CAChB,kBAAkB,CAAC,2BAA2B,EAAE,MAAM,CAAC,EACvD,2BAA2B,CAC5B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;YACtE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it } from \"node:test\";\nimport assert from \"node:assert\";\nimport {\n detectFormat,\n parseContent,\n serializeContent,\n convertDocument,\n generateOutputPath,\n} from \"./convert-engine.js\";\n\ndescribe(\"OpenAPI Convert Engine\", () => {\n describe(\"detectFormat\", () => {\n it(\"should detect JSON format from .json extension\", () => {\n assert.strictEqual(detectFormat(\"api.json\"), \"json\");\n assert.strictEqual(detectFormat(\"/path/to/openapi.json\"), \"json\");\n assert.strictEqual(detectFormat(\"FILE.JSON\"), \"json\");\n });\n\n it(\"should detect YAML format from .yaml extension\", () => {\n assert.strictEqual(detectFormat(\"api.yaml\"), \"yaml\");\n assert.strictEqual(detectFormat(\"/path/to/openapi.yaml\"), \"yaml\");\n assert.strictEqual(detectFormat(\"FILE.YAML\"), \"yaml\");\n });\n\n it(\"should detect YAML format from .yml extension\", () => {\n assert.strictEqual(detectFormat(\"api.yml\"), \"yaml\");\n assert.strictEqual(detectFormat(\"/path/to/openapi.yml\"), \"yaml\");\n assert.strictEqual(detectFormat(\"FILE.YML\"), \"yaml\");\n });\n\n it(\"should return null for unknown extensions\", () => {\n assert.strictEqual(detectFormat(\"api.txt\"), null);\n assert.strictEqual(detectFormat(\"api\"), null);\n assert.strictEqual(detectFormat(\"api.xml\"), null);\n });\n });\n\n describe(\"parseContent\", () => {\n it(\"should parse JSON content\", () => {\n const content = '{\"openapi\": \"3.1.0\", \"info\": {\"title\": \"Test\"}}';\n const result = parseContent(content, \"json\");\n\n assert.deepStrictEqual(result, {\n openapi: \"3.1.0\",\n info: { title: \"Test\" },\n });\n });\n\n it(\"should parse YAML content\", () => {\n const content = `openapi: 3.1.0\ninfo:\n title: Test\n version: 1.0.0`;\n const result = parseContent(content, \"yaml\");\n\n assert.deepStrictEqual(result, {\n openapi: \"3.1.0\",\n info: { title: \"Test\", version: \"1.0.0\" },\n });\n });\n\n it(\"should throw error for invalid JSON\", () => {\n const content = \"{invalid json}\";\n assert.throws(() => parseContent(content, \"json\"), {\n name: \"SyntaxError\",\n });\n });\n\n it(\"should throw error for invalid YAML\", () => {\n const content = \":\\ninvalid: : yaml\";\n assert.throws(() => parseContent(content, \"yaml\"));\n });\n\n it(\"should handle arrays\", () => {\n const jsonContent = \"[1, 2, 3]\";\n const yamlContent = \"- 1\\n- 2\\n- 3\";\n\n assert.deepStrictEqual(parseContent(jsonContent, \"json\"), [1, 2, 3]);\n assert.deepStrictEqual(parseContent(yamlContent, \"yaml\"), [1, 2, 3]);\n });\n\n it(\"should handle nested structures\", () => {\n const content = {\n openapi: \"3.1.0\",\n paths: {\n \"/users\": {\n get: {\n summary: \"Get users\",\n parameters: [{ name: \"limit\", in: \"query\" }],\n },\n },\n },\n };\n\n const jsonContent = JSON.stringify(content);\n const result = parseContent(jsonContent, \"json\");\n\n assert.deepStrictEqual(result, content);\n });\n });\n\n describe(\"serializeContent\", () => {\n const testDocument = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n };\n\n it(\"should serialize to JSON with proper formatting\", () => {\n const result = serializeContent(testDocument, \"json\");\n\n assert.strictEqual(typeof result, \"string\");\n assert.strictEqual(result.includes('\"openapi\": \"3.1.0\"'), true);\n assert.strictEqual(result.includes('\"title\": \"Test API\"'), true);\n assert.strictEqual(result.endsWith(\"\\n\"), true);\n\n // Verify it's valid JSON\n const parsed = JSON.parse(result);\n assert.deepStrictEqual(parsed, testDocument);\n });\n\n it(\"should serialize to YAML with proper formatting\", () => {\n const result = serializeContent(testDocument, \"yaml\");\n\n assert.strictEqual(typeof result, \"string\");\n assert.strictEqual(result.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(result.includes(\"title: Test API\"), true);\n assert.strictEqual(result.includes(\"version: 1.0.0\"), true);\n });\n\n it(\"should handle arrays in JSON\", () => {\n const doc = { items: [1, 2, 3] };\n const result = serializeContent(doc, \"json\");\n\n assert.strictEqual(result.includes('\"items\": [\\n'), true);\n const parsed = JSON.parse(result);\n assert.deepStrictEqual(parsed, doc);\n });\n\n it(\"should handle arrays in YAML\", () => {\n const doc = { items: [1, 2, 3] };\n const result = serializeContent(doc, \"yaml\");\n\n assert.strictEqual(result.includes(\"items:\"), true);\n assert.strictEqual(result.includes(\"- 1\"), true);\n });\n\n it(\"should handle special characters in YAML\", () => {\n const doc = {\n description: 'This has a colon: and quotes \"test\"',\n };\n const result = serializeContent(doc, \"yaml\");\n\n assert.strictEqual(typeof result, \"string\");\n // Should be properly escaped\n assert.strictEqual(result.includes(\"description:\"), true);\n });\n\n it(\"should handle null values\", () => {\n const doc = { value: null };\n const jsonResult = serializeContent(doc, \"json\");\n const yamlResult = serializeContent(doc, \"yaml\");\n\n assert.strictEqual(jsonResult.includes('\"value\": null'), true);\n assert.strictEqual(yamlResult.includes(\"value:\"), true);\n });\n });\n\n describe(\"convertDocument\", () => {\n const testDocument = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n it(\"should convert from JSON to YAML\", () => {\n const jsonContent = JSON.stringify(testDocument);\n const result = convertDocument(jsonContent, \"json\", \"yaml\");\n\n assert.strictEqual(result.format, \"yaml\");\n assert.strictEqual(typeof result.content, \"string\");\n assert.strictEqual(result.content.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(result.content.includes(\"title: Test API\"), true);\n });\n\n it(\"should convert from YAML to JSON\", () => {\n const yamlContent = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n const result = convertDocument(yamlContent, \"yaml\", \"json\");\n\n assert.strictEqual(result.format, \"json\");\n assert.strictEqual(typeof result.content, \"string\");\n\n const parsed = JSON.parse(result.content);\n assert.strictEqual(parsed.openapi, \"3.1.0\");\n assert.strictEqual(parsed.info.title, \"Test API\");\n });\n\n it(\"should preserve data through JSON to YAML to JSON conversion\", () => {\n const originalJson = JSON.stringify(testDocument);\n\n // JSON -> YAML\n const yamlResult = convertDocument(originalJson, \"json\", \"yaml\");\n\n // YAML -> JSON\n const jsonResult = convertDocument(yamlResult.content, \"yaml\", \"json\");\n\n const finalDocument = JSON.parse(jsonResult.content);\n assert.deepStrictEqual(finalDocument, testDocument);\n });\n\n it(\"should preserve data through YAML to JSON to YAML conversion\", () => {\n const originalYaml = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n\n // Parse original to compare\n const originalDoc = parseContent(originalYaml, \"yaml\");\n\n // YAML -> JSON\n const jsonResult = convertDocument(originalYaml, \"yaml\", \"json\");\n\n // JSON -> YAML\n const yamlResult = convertDocument(jsonResult.content, \"json\", \"yaml\");\n\n const finalDocument = parseContent(yamlResult.content, \"yaml\");\n assert.deepStrictEqual(finalDocument, originalDoc);\n });\n\n it(\"should handle complex nested structures\", () => {\n const complexDoc = {\n openapi: \"3.1.0\",\n paths: {\n \"/users/{id}\": {\n get: {\n parameters: [\n { name: \"id\", in: \"path\", required: true },\n { name: \"fields\", in: \"query\", required: false },\n ],\n responses: {\n \"200\": {\n description: \"Success\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n name: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n const jsonContent = JSON.stringify(complexDoc);\n const yamlResult = convertDocument(jsonContent, \"json\", \"yaml\");\n const backToJson = convertDocument(yamlResult.content, \"yaml\", \"json\");\n\n const finalDoc = JSON.parse(backToJson.content);\n assert.deepStrictEqual(finalDoc, complexDoc);\n });\n\n it(\"should handle empty objects and arrays\", () => {\n const doc = {\n empty_object: {},\n empty_array: [],\n nested: {\n also_empty: {},\n },\n };\n\n const jsonContent = JSON.stringify(doc);\n const yamlResult = convertDocument(jsonContent, \"json\", \"yaml\");\n const backToJson = convertDocument(yamlResult.content, \"yaml\", \"json\");\n\n const finalDoc = JSON.parse(backToJson.content);\n assert.deepStrictEqual(finalDoc, doc);\n });\n });\n\n describe(\"generateOutputPath\", () => {\n it(\"should replace .json with .yaml\", () => {\n assert.strictEqual(generateOutputPath(\"api.json\", \"yaml\"), \"api.yaml\");\n });\n\n it(\"should replace .yaml with .json\", () => {\n assert.strictEqual(generateOutputPath(\"api.yaml\", \"json\"), \"api.json\");\n });\n\n it(\"should replace .yml with .json\", () => {\n assert.strictEqual(generateOutputPath(\"api.yml\", \"json\"), \"api.json\");\n });\n\n it(\"should handle paths with directories\", () => {\n assert.strictEqual(\n generateOutputPath(\"/path/to/api.json\", \"yaml\"),\n \"/path/to/api.yaml\"\n );\n assert.strictEqual(\n generateOutputPath(\"/path/to/api.yaml\", \"json\"),\n \"/path/to/api.json\"\n );\n });\n\n it(\"should handle relative paths\", () => {\n assert.strictEqual(\n generateOutputPath(\"./docs/api.json\", \"yaml\"),\n \"./docs/api.yaml\"\n );\n assert.strictEqual(\n generateOutputPath(\"../specs/api.yaml\", \"json\"),\n \"../specs/api.json\"\n );\n });\n\n it(\"should handle files with multiple dots in name\", () => {\n assert.strictEqual(\n generateOutputPath(\"api.v1.0.json\", \"yaml\"),\n \"api.v1.0.yaml\"\n );\n assert.strictEqual(\n generateOutputPath(\"my.api.spec.yaml\", \"json\"),\n \"my.api.spec.json\"\n );\n });\n\n it(\"should append extension if file has no extension\", () => {\n assert.strictEqual(generateOutputPath(\"api\", \"json\"), \"api.json\");\n assert.strictEqual(generateOutputPath(\"openapi\", \"yaml\"), \"openapi.yaml\");\n });\n\n it(\"should handle Windows-style paths\", () => {\n assert.strictEqual(\n generateOutputPath(\"C:\\\\Users\\\\docs\\\\api.json\", \"yaml\"),\n \"C:\\\\Users\\\\docs\\\\api.yaml\"\n );\n });\n\n it(\"should always use .yaml extension (not .yml) for yaml output\", () => {\n assert.strictEqual(generateOutputPath(\"api.yml\", \"yaml\"), \"api.yaml\");\n assert.strictEqual(generateOutputPath(\"api.json\", \"yaml\"), \"api.yaml\");\n });\n });\n});\n"]}
@@ -0,0 +1,9 @@
1
+ export interface Arguments {
2
+ input: string;
3
+ format?: "json" | "yaml";
4
+ json?: boolean;
5
+ yaml?: boolean;
6
+ output?: string;
7
+ }
8
+ export declare function convertOpenAPI(args: Arguments): Promise<void>;
9
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/open-api/convert/handler.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAwEnE"}
@@ -0,0 +1,54 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { printDiagnosticsToConsole } from "../../common/output.js";
4
+ import { logger } from "../../common/logger.js";
5
+ import { detectFormat, convertDocument, generateOutputPath, } from "./convert-engine.js";
6
+ export async function convertOpenAPI(args) {
7
+ const { input: inputPath, format, json, yaml, output: outputPath } = args;
8
+ let outputFormat;
9
+ if (format) {
10
+ outputFormat = format;
11
+ }
12
+ else if (json) {
13
+ outputFormat = "json";
14
+ }
15
+ else if (yaml) {
16
+ outputFormat = "yaml";
17
+ }
18
+ else {
19
+ throw new Error("Output format must be specified using --format, --json, or --yaml");
20
+ }
21
+ const inputFormat = detectFormat(inputPath);
22
+ if (!inputFormat) {
23
+ throw new Error(`Unable to determine input format from extension: ${path.extname(inputPath)}`);
24
+ }
25
+ if (inputFormat === outputFormat) {
26
+ console.log(`Input file is already in ${outputFormat.toUpperCase()} format. No conversion needed.`);
27
+ return;
28
+ }
29
+ console.log("OpenAPI Format Converter");
30
+ console.log("========================");
31
+ console.log(`Input file: ${inputPath}`);
32
+ console.log(`Input format: ${inputFormat.toUpperCase()}`);
33
+ console.log(`Output format: ${outputFormat.toUpperCase()}`);
34
+ if (outputPath) {
35
+ console.log(`Output file: ${outputPath}`);
36
+ }
37
+ try {
38
+ const inputContent = fs.readFileSync(inputPath, "utf-8");
39
+ const { content: outputContent } = convertDocument(inputContent, inputFormat, outputFormat);
40
+ const finalOutputPath = outputPath || generateOutputPath(inputPath, outputFormat);
41
+ const outputDir = path.dirname(finalOutputPath);
42
+ if (!fs.existsSync(outputDir)) {
43
+ fs.mkdirSync(outputDir, { recursive: true });
44
+ }
45
+ fs.writeFileSync(finalOutputPath, outputContent, "utf-8");
46
+ console.log(`\n✓ Converted file written to: ${finalOutputPath}`);
47
+ }
48
+ catch (error) {
49
+ logger.error(error, "Error converting OpenAPI file");
50
+ printDiagnosticsToConsole(`Error: ${error.message}`);
51
+ throw error;
52
+ }
53
+ }
54
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/open-api/convert/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAA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AW,EAAE,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,kBAAkB,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5D,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QAEH,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAGzD,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,eAAe,CAChD,YAAY,EACZ,WAAW,EACX,YAAY,CACb,CAAC;QAGF,MAAM,eAAe,GACnB,UAAU,IAAI,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAG5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAGD,EAAE,CAAC,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAE1D,OAAO,CAAC,GAAG,CAAC,kCAAkC,eAAe,EAAE,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC;QACrD,yBAAyB,CAAC,UAAW,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/** biome-ignore-all lint/suspicious/noConsole: CLI output file */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { printDiagnosticsToConsole } from \"../../common/output.js\";\nimport { logger } from \"../../common/logger.js\";\nimport {\n detectFormat,\n convertDocument,\n generateOutputPath,\n type FileFormat,\n} from \"./convert-engine.js\";\n\nexport interface Arguments {\n input: string;\n format?: \"json\" | \"yaml\";\n json?: boolean;\n yaml?: boolean;\n output?: string;\n}\n\n/**\n * Convert OpenAPI document between JSON and YAML formats\n */\nexport async function convertOpenAPI(args: Arguments): Promise<void> {\n const { input: inputPath, format, json, yaml, output: outputPath } = args;\n\n // Determine output format\n let outputFormat: FileFormat;\n if (format) {\n outputFormat = format;\n } else if (json) {\n outputFormat = \"json\";\n } else if (yaml) {\n outputFormat = \"yaml\";\n } else {\n throw new Error(\n \"Output format must be specified using --format, --json, or --yaml\"\n );\n }\n\n // Determine input format from extension\n const inputFormat = detectFormat(inputPath);\n if (!inputFormat) {\n throw new Error(\n `Unable to determine input format from extension: ${path.extname(inputPath)}`\n );\n }\n\n // Check if conversion is needed\n if (inputFormat === outputFormat) {\n console.log(\n `Input file is already in ${outputFormat.toUpperCase()} format. No conversion needed.`\n );\n return;\n }\n\n console.log(\"OpenAPI Format Converter\");\n console.log(\"========================\");\n console.log(`Input file: ${inputPath}`);\n console.log(`Input format: ${inputFormat.toUpperCase()}`);\n console.log(`Output format: ${outputFormat.toUpperCase()}`);\n if (outputPath) {\n console.log(`Output file: ${outputPath}`);\n }\n\n try {\n // Load input file\n const inputContent = fs.readFileSync(inputPath, \"utf-8\");\n\n // Convert document\n const { content: outputContent } = convertDocument(\n inputContent,\n inputFormat,\n outputFormat\n );\n\n // Determine output path (use provided path or generate one)\n const finalOutputPath =\n outputPath || generateOutputPath(inputPath, outputFormat);\n\n // Create output directory if it doesn't exist\n const outputDir = path.dirname(finalOutputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Write output file\n fs.writeFileSync(finalOutputPath, outputContent, \"utf-8\");\n\n console.log(`\\n✓ Converted file written to: ${finalOutputPath}`);\n } catch (error) {\n logger.error(error, \"Error converting OpenAPI file\");\n printDiagnosticsToConsole(`Error: ${(error as Error).message}`);\n throw error;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=handler.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.spec.d.ts","sourceRoot":"","sources":["../../../src/open-api/convert/handler.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,291 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { afterEach, beforeEach, describe, it } from "node:test";
4
+ import { fileURLToPath } from "node:url";
5
+ import assert from "node:assert";
6
+ import { convertOpenAPI } from "./handler.js";
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const testTmpPath = path.join(__dirname, "..", "..", "__tests__", "test-tmp", "convert-handler");
10
+ describe("Convert Handler", () => {
11
+ beforeEach(async () => {
12
+ await fs.mkdir(testTmpPath, { recursive: true });
13
+ });
14
+ afterEach(async () => {
15
+ try {
16
+ await fs.rm(testTmpPath, { recursive: true, force: true });
17
+ }
18
+ catch {
19
+ }
20
+ });
21
+ describe("convertOpenAPI", () => {
22
+ it("should convert JSON to YAML using --format yaml", async () => {
23
+ const inputPath = path.join(testTmpPath, "api.json");
24
+ const expectedOutputPath = path.join(testTmpPath, "api.yaml");
25
+ const inputDoc = {
26
+ openapi: "3.1.0",
27
+ info: {
28
+ title: "Test API",
29
+ version: "1.0.0",
30
+ },
31
+ paths: {},
32
+ };
33
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
34
+ await convertOpenAPI({
35
+ input: inputPath,
36
+ format: "yaml",
37
+ });
38
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
39
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
40
+ assert.strictEqual(outputContent.includes("title: Test API"), true);
41
+ });
42
+ it("should convert JSON to YAML using --yaml", async () => {
43
+ const inputPath = path.join(testTmpPath, "api.json");
44
+ const expectedOutputPath = path.join(testTmpPath, "api.yaml");
45
+ const inputDoc = {
46
+ openapi: "3.1.0",
47
+ info: {
48
+ title: "Test API",
49
+ version: "1.0.0",
50
+ },
51
+ paths: {},
52
+ };
53
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
54
+ await convertOpenAPI({
55
+ input: inputPath,
56
+ yaml: true,
57
+ });
58
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
59
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
60
+ });
61
+ it("should convert YAML to JSON using --format json", async () => {
62
+ const inputPath = path.join(testTmpPath, "api.yaml");
63
+ const expectedOutputPath = path.join(testTmpPath, "api.json");
64
+ const inputDoc = `openapi: 3.1.0
65
+ info:
66
+ title: Test API
67
+ version: 1.0.0
68
+ paths: {}`;
69
+ await fs.writeFile(inputPath, inputDoc);
70
+ await convertOpenAPI({
71
+ input: inputPath,
72
+ format: "json",
73
+ });
74
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
75
+ const parsed = JSON.parse(outputContent);
76
+ assert.strictEqual(parsed.openapi, "3.1.0");
77
+ assert.strictEqual(parsed.info.title, "Test API");
78
+ });
79
+ it("should convert YAML to JSON using --json", async () => {
80
+ const inputPath = path.join(testTmpPath, "api.yml");
81
+ const expectedOutputPath = path.join(testTmpPath, "api.json");
82
+ const inputDoc = `openapi: 3.1.0
83
+ info:
84
+ title: Test API
85
+ version: 1.0.0
86
+ paths: {}`;
87
+ await fs.writeFile(inputPath, inputDoc);
88
+ await convertOpenAPI({
89
+ input: inputPath,
90
+ json: true,
91
+ });
92
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
93
+ const parsed = JSON.parse(outputContent);
94
+ assert.strictEqual(parsed.openapi, "3.1.0");
95
+ });
96
+ it("should handle files with multiple dots in name", async () => {
97
+ const inputPath = path.join(testTmpPath, "api.v1.0.json");
98
+ const expectedOutputPath = path.join(testTmpPath, "api.v1.0.yaml");
99
+ const inputDoc = {
100
+ openapi: "3.1.0",
101
+ info: {
102
+ title: "Test API",
103
+ version: "1.0.0",
104
+ },
105
+ paths: {},
106
+ };
107
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
108
+ await convertOpenAPI({
109
+ input: inputPath,
110
+ format: "yaml",
111
+ });
112
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
113
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
114
+ });
115
+ it("should preserve complex nested structures", async () => {
116
+ const inputPath = path.join(testTmpPath, "complex.json");
117
+ const expectedOutputPath = path.join(testTmpPath, "complex.yaml");
118
+ const inputDoc = {
119
+ openapi: "3.1.0",
120
+ info: {
121
+ title: "Complex API",
122
+ version: "1.0.0",
123
+ },
124
+ paths: {
125
+ "/users/{id}": {
126
+ get: {
127
+ parameters: [
128
+ { name: "id", in: "path", required: true },
129
+ { name: "fields", in: "query", required: false },
130
+ ],
131
+ responses: {
132
+ "200": {
133
+ description: "Success",
134
+ content: {
135
+ "application/json": {
136
+ schema: {
137
+ type: "object",
138
+ properties: {
139
+ id: { type: "string" },
140
+ name: { type: "string" },
141
+ },
142
+ },
143
+ },
144
+ },
145
+ },
146
+ },
147
+ },
148
+ },
149
+ },
150
+ };
151
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
152
+ await convertOpenAPI({
153
+ input: inputPath,
154
+ format: "yaml",
155
+ });
156
+ await convertOpenAPI({
157
+ input: expectedOutputPath,
158
+ format: "json",
159
+ });
160
+ const finalContent = await fs.readFile(inputPath, "utf-8");
161
+ const finalDoc = JSON.parse(finalContent);
162
+ assert.deepStrictEqual(finalDoc, inputDoc);
163
+ });
164
+ it("should create output directory if it doesn't exist", async () => {
165
+ const inputPath = path.join(testTmpPath, "nested", "dir", "api.json");
166
+ const expectedOutputPath = path.join(testTmpPath, "nested", "dir", "api.yaml");
167
+ const inputDoc = {
168
+ openapi: "3.1.0",
169
+ info: {
170
+ title: "Test API",
171
+ version: "1.0.0",
172
+ },
173
+ paths: {},
174
+ };
175
+ await fs.mkdir(path.dirname(inputPath), { recursive: true });
176
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
177
+ await convertOpenAPI({
178
+ input: inputPath,
179
+ format: "yaml",
180
+ });
181
+ const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
182
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
183
+ });
184
+ it("should throw error when no format is specified", async () => {
185
+ const inputPath = path.join(testTmpPath, "api.json");
186
+ const inputDoc = {
187
+ openapi: "3.1.0",
188
+ info: {
189
+ title: "Test API",
190
+ version: "1.0.0",
191
+ },
192
+ paths: {},
193
+ };
194
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
195
+ await assert.rejects(() => convertOpenAPI({
196
+ input: inputPath,
197
+ }), /Output format must be specified/);
198
+ });
199
+ it("should throw error when input format cannot be determined", async () => {
200
+ const inputPath = path.join(testTmpPath, "api.txt");
201
+ await fs.writeFile(inputPath, "content");
202
+ await assert.rejects(() => convertOpenAPI({
203
+ input: inputPath,
204
+ format: "json",
205
+ }), /Unable to determine input format/);
206
+ });
207
+ it("should not convert if input and output formats are the same", async () => {
208
+ const inputPath = path.join(testTmpPath, "api.json");
209
+ const inputDoc = {
210
+ openapi: "3.1.0",
211
+ info: {
212
+ title: "Test API",
213
+ version: "1.0.0",
214
+ },
215
+ paths: {},
216
+ };
217
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
218
+ await convertOpenAPI({
219
+ input: inputPath,
220
+ format: "json",
221
+ });
222
+ const content = await fs.readFile(inputPath, "utf-8");
223
+ const parsed = JSON.parse(content);
224
+ assert.deepStrictEqual(parsed, inputDoc);
225
+ });
226
+ it("should use custom output path when specified", async () => {
227
+ const inputPath = path.join(testTmpPath, "api.json");
228
+ const customOutputPath = path.join(testTmpPath, "custom-name.yaml");
229
+ const inputDoc = {
230
+ openapi: "3.1.0",
231
+ info: {
232
+ title: "Test API",
233
+ version: "1.0.0",
234
+ },
235
+ paths: {},
236
+ };
237
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
238
+ await convertOpenAPI({
239
+ input: inputPath,
240
+ format: "yaml",
241
+ output: customOutputPath,
242
+ });
243
+ const outputContent = await fs.readFile(customOutputPath, "utf-8");
244
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
245
+ assert.strictEqual(outputContent.includes("title: Test API"), true);
246
+ });
247
+ it("should create output directory when using custom output path", async () => {
248
+ const inputPath = path.join(testTmpPath, "api.json");
249
+ const customOutputPath = path.join(testTmpPath, "custom", "output", "dir", "result.yaml");
250
+ const inputDoc = {
251
+ openapi: "3.1.0",
252
+ info: {
253
+ title: "Test API",
254
+ version: "1.0.0",
255
+ },
256
+ paths: {},
257
+ };
258
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
259
+ await convertOpenAPI({
260
+ input: inputPath,
261
+ format: "yaml",
262
+ output: customOutputPath,
263
+ });
264
+ const outputContent = await fs.readFile(customOutputPath, "utf-8");
265
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
266
+ });
267
+ it("should use custom output path with different location", async () => {
268
+ const inputPath = path.join(testTmpPath, "source", "api.json");
269
+ const customOutputPath = path.join(testTmpPath, "output", "api.yaml");
270
+ const inputDoc = {
271
+ openapi: "3.1.0",
272
+ info: {
273
+ title: "Test API",
274
+ version: "1.0.0",
275
+ },
276
+ paths: {},
277
+ };
278
+ await fs.mkdir(path.dirname(inputPath), { recursive: true });
279
+ await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
280
+ await convertOpenAPI({
281
+ input: inputPath,
282
+ format: "yaml",
283
+ output: customOutputPath,
284
+ });
285
+ const outputContent = await fs.readFile(customOutputPath, "utf-8");
286
+ assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
287
+ assert.strictEqual(outputContent.includes("title: Test API"), true);
288
+ });
289
+ });
290
+ });
291
+ //# sourceMappingURL=handler.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.spec.js","sourceRoot":"","sources":["../../../src/open-api/conv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,GAAG;gBACf,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE;oBACJ,KAAK,EAAE,UAAU;oBACjB,OAAO,EAAE,OAAO;iBACjB;gBACD,KAAK,EAAE,EAAE;aACV,CAAC;YAEF,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7D,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAEjE,MAAM,cAAc,CAAC;gBACnB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,gBAAgB;aACzB,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YACnE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,CAAC;YACnE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, describe, it } from \"node:test\";\nimport { fileURLToPath } from \"node:url\";\nimport assert from \"node:assert\";\nimport { convertOpenAPI } from \"./handler.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst testTmpPath = path.join(\n __dirname,\n \"..\",\n \"..\",\n \"__tests__\",\n \"test-tmp\",\n \"convert-handler\"\n);\n\ndescribe(\"Convert Handler\", () => {\n beforeEach(async () => {\n // Ensure test-tmp directory exists\n await fs.mkdir(testTmpPath, { recursive: true });\n });\n\n afterEach(async () => {\n // Clean up test files\n try {\n await fs.rm(testTmpPath, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n });\n\n describe(\"convertOpenAPI\", () => {\n it(\"should convert JSON to YAML using --format yaml\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n\n it(\"should convert JSON to YAML using --yaml\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n yaml: true,\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should convert YAML to JSON using --format json\", async () => {\n const inputPath = path.join(testTmpPath, \"api.yaml\");\n const expectedOutputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n\n await fs.writeFile(inputPath, inputDoc);\n\n await convertOpenAPI({\n input: inputPath,\n format: \"json\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n const parsed = JSON.parse(outputContent);\n assert.strictEqual(parsed.openapi, \"3.1.0\");\n assert.strictEqual(parsed.info.title, \"Test API\");\n });\n\n it(\"should convert YAML to JSON using --json\", async () => {\n const inputPath = path.join(testTmpPath, \"api.yml\");\n const expectedOutputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n\n await fs.writeFile(inputPath, inputDoc);\n\n await convertOpenAPI({\n input: inputPath,\n json: true,\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n const parsed = JSON.parse(outputContent);\n assert.strictEqual(parsed.openapi, \"3.1.0\");\n });\n\n it(\"should handle files with multiple dots in name\", async () => {\n const inputPath = path.join(testTmpPath, \"api.v1.0.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.v1.0.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should preserve complex nested structures\", async () => {\n const inputPath = path.join(testTmpPath, \"complex.json\");\n const expectedOutputPath = path.join(testTmpPath, \"complex.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Complex API\",\n version: \"1.0.0\",\n },\n paths: {\n \"/users/{id}\": {\n get: {\n parameters: [\n { name: \"id\", in: \"path\", required: true },\n { name: \"fields\", in: \"query\", required: false },\n ],\n responses: {\n \"200\": {\n description: \"Success\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n name: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n // Convert back to verify data preservation\n await convertOpenAPI({\n input: expectedOutputPath,\n format: \"json\",\n });\n\n const finalContent = await fs.readFile(inputPath, \"utf-8\");\n const finalDoc = JSON.parse(finalContent);\n assert.deepStrictEqual(finalDoc, inputDoc);\n });\n\n it(\"should create output directory if it doesn't exist\", async () => {\n const inputPath = path.join(testTmpPath, \"nested\", \"dir\", \"api.json\");\n const expectedOutputPath = path.join(\n testTmpPath,\n \"nested\",\n \"dir\",\n \"api.yaml\"\n );\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.mkdir(path.dirname(inputPath), { recursive: true });\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should throw error when no format is specified\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await assert.rejects(\n () =>\n convertOpenAPI({\n input: inputPath,\n }),\n /Output format must be specified/\n );\n });\n\n it(\"should throw error when input format cannot be determined\", async () => {\n const inputPath = path.join(testTmpPath, \"api.txt\");\n\n await fs.writeFile(inputPath, \"content\");\n\n await assert.rejects(\n () =>\n convertOpenAPI({\n input: inputPath,\n format: \"json\",\n }),\n /Unable to determine input format/\n );\n });\n\n it(\"should not convert if input and output formats are the same\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n // Should complete without error and not create output file\n await convertOpenAPI({\n input: inputPath,\n format: \"json\",\n });\n\n // Verify original file still exists\n const content = await fs.readFile(inputPath, \"utf-8\");\n const parsed = JSON.parse(content);\n assert.deepStrictEqual(parsed, inputDoc);\n });\n\n it(\"should use custom output path when specified\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const customOutputPath = path.join(testTmpPath, \"custom-name.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n\n it(\"should create output directory when using custom output path\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const customOutputPath = path.join(\n testTmpPath,\n \"custom\",\n \"output\",\n \"dir\",\n \"result.yaml\"\n );\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should use custom output path with different location\", async () => {\n const inputPath = path.join(testTmpPath, \"source\", \"api.json\");\n const customOutputPath = path.join(testTmpPath, \"output\", \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.mkdir(path.dirname(inputPath), { recursive: true });\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ajv.d.ts","sourceRoot":"","sources":["../../../src/open-api/merge/ajv.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW,CAC1B,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvB,CAAC,GAAG,OAAO;IAEX,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,UAAU,aAAa;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB;AACD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB;AACD,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,MAAM,EAAE,IAAI,CAAC;CACd;AACD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ajv.js","sourceRoot":"","sources":["../../../src/open-api/merge/ajv.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This file contains types copied from AJV to avoid a direct dependency on it.\n *\n */\n\n/** biome-ignore-all lint/suspicious/noExplicitAny: Third party api */\nexport interface ErrorObject<\n K extends string = string,\n P = Record<string, any>,\n S = unknown,\n> {\n keyword: K;\n instancePath: string;\n schemaPath: string;\n params: P;\n propertyName?: string;\n message?: string;\n schema?: S;\n parentSchema?: AnySchemaObject;\n data?: unknown;\n}\n\n// biome-ignore lint/style/useNamingConvention: Copy from AJV\ninterface _SchemaObject {\n id?: string;\n $id?: string;\n $schema?: string;\n [x: string]: any;\n}\nexport interface SchemaObject extends _SchemaObject {\n id?: string;\n $id?: string;\n $schema?: string;\n $async?: false;\n [x: string]: any;\n}\nexport interface AsyncSchema extends _SchemaObject {\n $async: true;\n}\nexport type AnySchemaObject = SchemaObject | AsyncSchema;\n"]}
@@ -0,0 +1,9 @@
1
+ import { type MergeMode } from "./merge-engine.js";
2
+ export interface Arguments {
3
+ prompt?: boolean;
4
+ source: string;
5
+ destination: string;
6
+ "merge-mode"?: MergeMode;
7
+ }
8
+ export declare function importOpenApi(argv: Arguments): Promise<void>;
9
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/open-api/merge/handler.ts"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA8JlE"}
@@ -1,41 +1,21 @@
1
1
  import { existsSync, writeFileSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
- import path, { basename, dirname, extname, join, relative } from "node:path";
4
+ import path from "node:path";
5
5
  import { confirm } from "@inquirer/prompts";
6
6
  import { mergeOpenApiDocuments } from "@zuplo/openapi-tools";
7
- import jsYaml from "js-yaml";
8
7
  import { format } from "prettier";
9
8
  import { logger } from "../../common/logger.js";
10
9
  import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../../common/output.js";
11
- import { addOperationIdsAsNecessary, parseOpenApiFile } from "./utils.js";
12
- export const BASE_TEMPLATE = `
13
- {
14
- "openapi": "3.1.0",
15
- "info": {
16
- "version": "1.0.0",
17
- "title": "My Zuplo API"
18
- },
19
- "paths": {}
20
- }
21
-
22
- `;
10
+ import { BASE_TEMPLATE, addOperationIdsAsNecessary, detectFormatFromContent, guessFileNameFromUrl, isUrl, parseOpenApiFile, } from "./merge-engine.js";
23
11
  export async function importOpenApi(argv) {
24
12
  let normalizedFilePath;
25
- let handleAsUrl = true;
26
- try {
27
- new URL(argv.source);
28
- }
29
- catch {
30
- handleAsUrl = false;
31
- }
32
- if (handleAsUrl) {
13
+ if (isUrl(argv.source)) {
33
14
  const parsedUrl = new URL(argv.source);
34
15
  const tempDir = tmpdir();
35
- const guessedFileName = basename(parsedUrl.pathname).replace(/\.[^/.]+$/, "") ||
36
- `imported-${Buffer.from(argv.source).toString("base64")}`;
37
- normalizedFilePath = join(tempDir, guessedFileName);
38
- await mkdir(dirname(normalizedFilePath), { recursive: true });
16
+ const guessedFileName = guessFileNameFromUrl(argv.source);
17
+ normalizedFilePath = path.join(tempDir, guessedFileName);
18
+ await mkdir(path.dirname(normalizedFilePath), { recursive: true });
39
19
  try {
40
20
  const response = await fetch(parsedUrl);
41
21
  if (!response.ok) {
@@ -43,42 +23,36 @@ export async function importOpenApi(argv) {
43
23
  }
44
24
  const text = await response.text();
45
25
  try {
46
- JSON.parse(text);
47
- normalizedFilePath = `${normalizedFilePath}.json`;
26
+ const format = detectFormatFromContent(text);
27
+ normalizedFilePath = `${normalizedFilePath}.${format === "json" ? "json" : "yaml"}`;
48
28
  await writeFile(normalizedFilePath, text, { flag: "w+" });
49
29
  }
50
- catch {
51
- try {
52
- jsYaml.load(text);
53
- normalizedFilePath = `${normalizedFilePath}.yaml`;
54
- await writeFile(normalizedFilePath, text, { flag: "w+" });
55
- }
56
- catch {
57
- await printCriticalFailureToConsoleAndExit(`Failed to parse the remote OpenAPI file as either JSON or YAML.`);
58
- }
30
+ catch (err) {
31
+ logger.error(err);
32
+ await printCriticalFailureToConsoleAndExit("Failed to parse the remote OpenAPI file as either JSON or YAML.");
59
33
  }
60
34
  }
61
35
  catch (err) {
62
36
  logger.error(err);
63
- await printCriticalFailureToConsoleAndExit(`Failed to download the remote OpenAPI file.`);
37
+ await printCriticalFailureToConsoleAndExit("Failed to download the remote OpenAPI file.");
64
38
  }
65
39
  }
66
40
  else {
67
41
  const filePath = argv.source;
68
- normalizedFilePath = join(relative(process.cwd(), filePath));
42
+ normalizedFilePath = path.join(path.relative(process.cwd(), filePath));
69
43
  if (!existsSync(normalizedFilePath)) {
70
44
  await printCriticalFailureToConsoleAndExit(`The file ${normalizedFilePath} to import does not exist.`);
71
45
  }
72
46
  }
73
47
  const rawOpenApiSpec = await readFile(normalizedFilePath);
74
- const extName = extname(normalizedFilePath);
48
+ const extName = path.extname(normalizedFilePath);
75
49
  const fileContent = rawOpenApiSpec.toString();
76
50
  const parsedOpenApiSpec = await parseOpenApiFile(extName, fileContent);
77
51
  const destination = argv.destination;
78
52
  if (!destination.endsWith(".oas.json")) {
79
- await printCriticalFailureToConsoleAndExit(`Destination file name must end with '.oas.json'`);
53
+ await printCriticalFailureToConsoleAndExit("Destination file name must end with '.oas.json'");
80
54
  }
81
- const destinationFilePath = join(relative(process.cwd(), destination));
55
+ const destinationFilePath = path.join(path.relative(process.cwd(), destination));
82
56
  let originalDocument;
83
57
  if (!existsSync(destinationFilePath)) {
84
58
  originalDocument = (await parseOpenApiFile(".json", BASE_TEMPLATE));