@apimatic/cli 1.1.0-alpha.21 → 1.1.0-alpha.22

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 (299) hide show
  1. package/README.md +112 -90
  2. package/lib/actions/action-result.d.ts +8 -3
  3. package/lib/actions/action-result.js +34 -15
  4. package/lib/actions/action-result.js.map +1 -1
  5. package/lib/actions/api/transform.d.ts +15 -0
  6. package/lib/actions/api/transform.js +48 -0
  7. package/lib/actions/api/transform.js.map +1 -0
  8. package/lib/actions/api/validate.d.ts +12 -0
  9. package/lib/actions/api/validate.js +41 -0
  10. package/lib/actions/api/validate.js.map +1 -0
  11. package/lib/actions/auth/login.d.ts +6 -5
  12. package/lib/actions/auth/login.js +25 -33
  13. package/lib/actions/auth/login.js.map +1 -1
  14. package/lib/actions/auth/logout.d.ts +8 -0
  15. package/lib/actions/auth/logout.js +15 -0
  16. package/lib/actions/auth/logout.js.map +1 -0
  17. package/lib/actions/auth/status.d.ts +11 -0
  18. package/lib/actions/auth/status.js +26 -0
  19. package/lib/actions/auth/status.js.map +1 -0
  20. package/lib/actions/portal/copilot.d.ts +5 -3
  21. package/lib/actions/portal/copilot.js +47 -37
  22. package/lib/actions/portal/copilot.js.map +1 -1
  23. package/lib/actions/portal/generate.d.ts +4 -5
  24. package/lib/actions/portal/generate.js +30 -37
  25. package/lib/actions/portal/generate.js.map +1 -1
  26. package/lib/actions/portal/quickstart.d.ts +16 -0
  27. package/lib/actions/portal/quickstart.js +145 -0
  28. package/lib/actions/portal/quickstart.js.map +1 -0
  29. package/lib/actions/portal/recipe/new-recipe.d.ts +11 -20
  30. package/lib/actions/portal/recipe/new-recipe.js +147 -221
  31. package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
  32. package/lib/actions/portal/serve.d.ts +12 -10
  33. package/lib/actions/portal/serve.js +112 -17
  34. package/lib/actions/portal/serve.js.map +1 -1
  35. package/lib/actions/portal/toc/new-toc.d.ts +16 -15
  36. package/lib/actions/portal/toc/new-toc.js +80 -116
  37. package/lib/actions/portal/toc/new-toc.js.map +1 -1
  38. package/lib/actions/sdk/generate.d.ts +5 -6
  39. package/lib/actions/sdk/generate.js +22 -47
  40. package/lib/actions/sdk/generate.js.map +1 -1
  41. package/lib/application/portal/recipe/portal-recipe.d.ts +2 -2
  42. package/lib/application/portal/recipe/portal-recipe.js +9 -9
  43. package/lib/application/portal/recipe/portal-recipe.js.map +1 -1
  44. package/lib/application/portal/recipe/recipe-generator.d.ts +7 -2
  45. package/lib/application/portal/recipe/recipe-generator.js +21 -22
  46. package/lib/application/portal/recipe/recipe-generator.js.map +1 -1
  47. package/lib/client-utils/auth-manager.d.ts +1 -1
  48. package/lib/client-utils/auth-manager.js +3 -4
  49. package/lib/client-utils/auth-manager.js.map +1 -1
  50. package/lib/commands/api/transform.d.ts +6 -3
  51. package/lib/commands/api/transform.js +43 -94
  52. package/lib/commands/api/transform.js.map +1 -1
  53. package/lib/commands/api/validate.d.ts +6 -3
  54. package/lib/commands/api/validate.js +27 -66
  55. package/lib/commands/api/validate.js.map +1 -1
  56. package/lib/commands/auth/login.d.ts +2 -1
  57. package/lib/commands/auth/login.js +15 -9
  58. package/lib/commands/auth/login.js.map +1 -1
  59. package/lib/commands/auth/logout.d.ts +3 -1
  60. package/lib/commands/auth/logout.js +12 -13
  61. package/lib/commands/auth/logout.js.map +1 -1
  62. package/lib/commands/auth/status.d.ts +1 -0
  63. package/lib/commands/auth/status.js +13 -11
  64. package/lib/commands/auth/status.js.map +1 -1
  65. package/lib/commands/portal/copilot.d.ts +2 -2
  66. package/lib/commands/portal/copilot.js +22 -20
  67. package/lib/commands/portal/copilot.js.map +1 -1
  68. package/lib/commands/portal/generate.d.ts +3 -4
  69. package/lib/commands/portal/generate.js +19 -14
  70. package/lib/commands/portal/generate.js.map +1 -1
  71. package/lib/commands/portal/quickstart.d.ts +3 -4
  72. package/lib/commands/portal/quickstart.js +24 -101
  73. package/lib/commands/portal/quickstart.js.map +1 -1
  74. package/lib/commands/portal/recipe/new.d.ts +3 -1
  75. package/lib/commands/portal/recipe/new.js +31 -23
  76. package/lib/commands/portal/recipe/new.js.map +1 -1
  77. package/lib/commands/portal/serve.d.ts +5 -5
  78. package/lib/commands/portal/serve.js +31 -57
  79. package/lib/commands/portal/serve.js.map +1 -1
  80. package/lib/commands/portal/toc/new.d.ts +2 -2
  81. package/lib/commands/portal/toc/new.js +35 -26
  82. package/lib/commands/portal/toc/new.js.map +1 -1
  83. package/lib/commands/sdk/generate.d.ts +5 -4
  84. package/lib/commands/sdk/generate.js +26 -17
  85. package/lib/commands/sdk/generate.js.map +1 -1
  86. package/lib/hooks/not-found.js +1 -1
  87. package/lib/hooks/not-found.js.map +1 -1
  88. package/lib/infrastructure/api-utils.js +3 -2
  89. package/lib/infrastructure/api-utils.js.map +1 -1
  90. package/lib/{application/portal/serve/watcher-handler.d.ts → infrastructure/debounce-service.d.ts} +3 -3
  91. package/lib/{application/portal/serve/watcher-handler.js → infrastructure/debounce-service.js} +5 -4
  92. package/lib/infrastructure/debounce-service.js.map +1 -0
  93. package/lib/infrastructure/env-info.d.ts +1 -1
  94. package/lib/infrastructure/env-info.js +2 -2
  95. package/lib/infrastructure/env-info.js.map +1 -1
  96. package/lib/infrastructure/file-service.d.ts +7 -2
  97. package/lib/infrastructure/file-service.js +46 -5
  98. package/lib/infrastructure/file-service.js.map +1 -1
  99. package/lib/infrastructure/launcher-service.d.ts +2 -0
  100. package/lib/infrastructure/launcher-service.js +4 -0
  101. package/lib/infrastructure/launcher-service.js.map +1 -1
  102. package/lib/infrastructure/network-service.d.ts +3 -0
  103. package/lib/infrastructure/network-service.js +7 -0
  104. package/lib/infrastructure/network-service.js.map +1 -0
  105. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  106. package/lib/infrastructure/services/api-client-factory.js +20 -0
  107. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  108. package/lib/infrastructure/services/api-service.d.ts +2 -2
  109. package/lib/infrastructure/services/api-service.js +6 -6
  110. package/lib/infrastructure/services/api-service.js.map +1 -1
  111. package/lib/infrastructure/services/auth-service.d.ts +1 -1
  112. package/lib/infrastructure/services/auth-service.js +7 -5
  113. package/lib/infrastructure/services/auth-service.js.map +1 -1
  114. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  115. package/lib/infrastructure/services/file-download-service.js +104 -0
  116. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  117. package/lib/infrastructure/services/portal-service.d.ts +11 -13
  118. package/lib/infrastructure/services/portal-service.js +73 -102
  119. package/lib/infrastructure/services/portal-service.js.map +1 -1
  120. package/lib/infrastructure/services/telemetry-service.d.ts +3 -2
  121. package/lib/infrastructure/services/telemetry-service.js +4 -6
  122. package/lib/infrastructure/services/telemetry-service.js.map +1 -1
  123. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  124. package/lib/infrastructure/services/transformation-service.js +56 -0
  125. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  126. package/lib/infrastructure/services/validation-service.d.ts +17 -0
  127. package/lib/infrastructure/services/validation-service.js +49 -0
  128. package/lib/infrastructure/services/validation-service.js.map +1 -0
  129. package/lib/prompts/api/transform.d.ts +11 -0
  130. package/lib/prompts/api/transform.js +30 -0
  131. package/lib/prompts/api/transform.js.map +1 -0
  132. package/lib/prompts/api/validate.d.ts +12 -0
  133. package/lib/prompts/api/validate.js +41 -0
  134. package/lib/prompts/api/validate.js.map +1 -0
  135. package/lib/prompts/auth/login.d.ts +6 -1
  136. package/lib/prompts/auth/login.js +12 -3
  137. package/lib/prompts/auth/login.js.map +1 -1
  138. package/lib/prompts/auth/logout.d.ts +3 -0
  139. package/lib/prompts/auth/logout.js +7 -0
  140. package/lib/prompts/auth/logout.js.map +1 -0
  141. package/lib/prompts/auth/status.d.ts +8 -0
  142. package/lib/prompts/auth/status.js +21 -0
  143. package/lib/prompts/auth/status.js.map +1 -0
  144. package/lib/prompts/format.d.ts +33 -0
  145. package/lib/prompts/format.js +99 -0
  146. package/lib/prompts/format.js.map +1 -0
  147. package/lib/prompts/portal/copilot.d.ts +8 -4
  148. package/lib/prompts/portal/copilot.js +35 -24
  149. package/lib/prompts/portal/copilot.js.map +1 -1
  150. package/lib/prompts/portal/generate.d.ts +9 -7
  151. package/lib/prompts/portal/generate.js +22 -23
  152. package/lib/prompts/portal/generate.js.map +1 -1
  153. package/lib/prompts/portal/quickstart.d.ts +30 -29
  154. package/lib/prompts/portal/quickstart.js +99 -193
  155. package/lib/prompts/portal/quickstart.js.map +1 -1
  156. package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -18
  157. package/lib/prompts/portal/recipe/new-recipe.js +70 -108
  158. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
  159. package/lib/prompts/portal/serve.d.ts +10 -3
  160. package/lib/prompts/portal/serve.js +30 -11
  161. package/lib/prompts/portal/serve.js.map +1 -1
  162. package/lib/prompts/portal/toc/new-toc.d.ts +12 -8
  163. package/lib/prompts/portal/toc/new-toc.js +20 -22
  164. package/lib/prompts/portal/toc/new-toc.js.map +1 -1
  165. package/lib/prompts/sdk/generate.d.ts +7 -7
  166. package/lib/prompts/sdk/generate.js +17 -23
  167. package/lib/prompts/sdk/generate.js.map +1 -1
  168. package/lib/types/api/account.d.ts +1 -1
  169. package/lib/types/api/transform.d.ts +14 -25
  170. package/lib/types/api/transform.js +16 -16
  171. package/lib/types/api/transform.js.map +1 -1
  172. package/lib/types/build/build.d.ts +9 -1
  173. package/lib/types/build/build.js +5 -2
  174. package/lib/types/build/build.js.map +1 -1
  175. package/lib/types/build-context.d.ts +5 -1
  176. package/lib/types/build-context.js +21 -4
  177. package/lib/types/build-context.js.map +1 -1
  178. package/lib/types/common/command-metadata.d.ts +4 -0
  179. package/lib/types/common/command-metadata.js +2 -0
  180. package/lib/types/common/command-metadata.js.map +1 -0
  181. package/lib/types/events/domain-event.d.ts +1 -1
  182. package/lib/types/events/domain-event.js.map +1 -1
  183. package/lib/types/events/quickstart-completed.js +1 -1
  184. package/lib/types/events/quickstart-initiated.js +1 -1
  185. package/lib/types/events/recipe-creation-failed.d.ts +1 -1
  186. package/lib/types/events/recipe-creation-failed.js +1 -1
  187. package/lib/types/events/recipe-creation-failed.js.map +1 -1
  188. package/lib/types/events/toc-creation-failed.d.ts +1 -1
  189. package/lib/types/events/toc-creation-failed.js +1 -1
  190. package/lib/types/events/toc-creation-failed.js.map +1 -1
  191. package/lib/types/file/directory.d.ts +17 -0
  192. package/lib/types/file/directory.js +86 -0
  193. package/lib/types/file/directory.js.map +1 -0
  194. package/lib/types/file/directoryPath.d.ts +3 -1
  195. package/lib/types/file/directoryPath.js +8 -2
  196. package/lib/types/file/directoryPath.js.map +1 -1
  197. package/lib/types/file/fileName.d.ts +2 -0
  198. package/lib/types/file/fileName.js +12 -0
  199. package/lib/types/file/fileName.js.map +1 -1
  200. package/lib/types/file/filePath.d.ts +2 -0
  201. package/lib/types/file/filePath.js +21 -0
  202. package/lib/types/file/filePath.js.map +1 -1
  203. package/lib/types/file/resource-input.d.ts +5 -0
  204. package/lib/types/file/resource-input.js +42 -0
  205. package/lib/types/file/resource-input.js.map +1 -0
  206. package/lib/types/file/urlPath.d.ts +6 -0
  207. package/lib/types/file/urlPath.js +22 -0
  208. package/lib/types/file/urlPath.js.map +1 -0
  209. package/lib/types/portal-context.d.ts +3 -1
  210. package/lib/types/portal-context.js +10 -0
  211. package/lib/types/portal-context.js.map +1 -1
  212. package/lib/types/recipe/recipe.d.ts +2 -17
  213. package/lib/types/recipe-context.d.ts +8 -0
  214. package/lib/types/recipe-context.js +21 -0
  215. package/lib/types/recipe-context.js.map +1 -0
  216. package/lib/types/resource-context.d.ts +12 -0
  217. package/lib/types/resource-context.js +30 -0
  218. package/lib/types/resource-context.js.map +1 -0
  219. package/lib/types/sdk/generate.d.ts +2 -15
  220. package/lib/types/sdk/generate.js +24 -10
  221. package/lib/types/sdk/generate.js.map +1 -1
  222. package/lib/types/sdk-context.d.ts +6 -5
  223. package/lib/types/sdk-context.js +12 -8
  224. package/lib/types/sdk-context.js.map +1 -1
  225. package/lib/types/sdl/sdl.d.ts +9 -0
  226. package/lib/types/sdl/sdl.js +46 -1
  227. package/lib/types/sdl/sdl.js.map +1 -1
  228. package/lib/types/spec-context.d.ts +3 -0
  229. package/lib/types/spec-context.js +7 -2
  230. package/lib/types/spec-context.js.map +1 -1
  231. package/lib/types/temp-context.d.ts +11 -0
  232. package/lib/types/temp-context.js +27 -0
  233. package/lib/types/temp-context.js.map +1 -0
  234. package/lib/types/toc-context.d.ts +12 -0
  235. package/lib/types/toc-context.js +26 -0
  236. package/lib/types/toc-context.js.map +1 -0
  237. package/lib/types/transform-context.d.ts +13 -0
  238. package/lib/types/transform-context.js +30 -0
  239. package/lib/types/transform-context.js.map +1 -0
  240. package/lib/types/utils.d.ts +0 -9
  241. package/lib/utils/string-utils.d.ts +1 -0
  242. package/lib/utils/string-utils.js +10 -0
  243. package/lib/utils/string-utils.js.map +1 -0
  244. package/lib/utils/utils.d.ts +2 -27
  245. package/lib/utils/utils.js +6 -145
  246. package/lib/utils/utils.js.map +1 -1
  247. package/package.json +4 -4
  248. package/lib/application/portal/serve/portal-watcher.d.ts +0 -11
  249. package/lib/application/portal/serve/portal-watcher.js +0 -64
  250. package/lib/application/portal/serve/portal-watcher.js.map +0 -1
  251. package/lib/application/portal/serve/serve-handler.d.ts +0 -16
  252. package/lib/application/portal/serve/serve-handler.js +0 -91
  253. package/lib/application/portal/serve/serve-handler.js.map +0 -1
  254. package/lib/application/portal/serve/watcher-handler.js.map +0 -1
  255. package/lib/application/portal/toc/sdl-parser.d.ts +0 -19
  256. package/lib/application/portal/toc/sdl-parser.js +0 -90
  257. package/lib/application/portal/toc/sdl-parser.js.map +0 -1
  258. package/lib/client-utils/sdk-client.d.ts +0 -18
  259. package/lib/client-utils/sdk-client.js +0 -41
  260. package/lib/client-utils/sdk-client.js.map +0 -1
  261. package/lib/config/env.d.ts +0 -26
  262. package/lib/config/env.js +0 -27
  263. package/lib/config/env.js.map +0 -1
  264. package/lib/controllers/api/transform.d.ts +0 -5
  265. package/lib/controllers/api/transform.js +0 -50
  266. package/lib/controllers/api/transform.js.map +0 -1
  267. package/lib/controllers/api/validate.d.ts +0 -3
  268. package/lib/controllers/api/validate.js +0 -29
  269. package/lib/controllers/api/validate.js.map +0 -1
  270. package/lib/controllers/portal/quickstart.d.ts +0 -13
  271. package/lib/controllers/portal/quickstart.js +0 -214
  272. package/lib/controllers/portal/quickstart.js.map +0 -1
  273. package/lib/infrastructure/api-client-utils.d.ts +0 -6
  274. package/lib/infrastructure/api-client-utils.js +0 -34
  275. package/lib/infrastructure/api-client-utils.js.map +0 -1
  276. package/lib/prompts/portal/common/base-prompts.d.ts +0 -7
  277. package/lib/prompts/portal/common/base-prompts.js +0 -19
  278. package/lib/prompts/portal/common/base-prompts.js.map +0 -1
  279. package/lib/types/api/validate.d.ts +0 -12
  280. package/lib/types/api/validate.js +0 -2
  281. package/lib/types/api/validate.js.map +0 -1
  282. package/lib/types/common/result.d.ts +0 -17
  283. package/lib/types/common/result.js +0 -32
  284. package/lib/types/common/result.js.map +0 -1
  285. package/lib/types/portal/generate.d.ts +0 -13
  286. package/lib/types/portal/generate.js +0 -3
  287. package/lib/types/portal/generate.js.map +0 -1
  288. package/lib/types/portal/quickstart.d.ts +0 -17
  289. package/lib/types/portal/quickstart.js +0 -2
  290. package/lib/types/portal/quickstart.js.map +0 -1
  291. package/lib/types/portal/serve.d.ts +0 -12
  292. package/lib/types/portal/serve.js +0 -2
  293. package/lib/types/portal/serve.js.map +0 -1
  294. package/lib/validators/common/directoryValidator.d.ts +0 -5
  295. package/lib/validators/common/directoryValidator.js +0 -22
  296. package/lib/validators/common/directoryValidator.js.map +0 -1
  297. package/lib/validators/portal/serve-validator.d.ts +0 -6
  298. package/lib/validators/portal/serve-validator.js +0 -15
  299. package/lib/validators/portal/serve-validator.js.map +0 -1
@@ -1,22 +1,32 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import treeify from "treeify";
4
- import { intro, spinner, select, text, cancel, isCancel, outro, log, autocomplete } from "@clack/prompts";
5
- import { getMessageInGreenColor } from "../../../utils/utils.js";
1
+ import { select, text, isCancel, log, autocomplete, confirm, note } from "@clack/prompts";
2
+ import { format as f, getTree, withSpinner } from "../../format.js";
3
+ import { getErrorMessage } from "../../../infrastructure/api-utils.js";
6
4
  export class PortalRecipePrompts {
7
- constructor() {
8
- this.spin = spinner();
9
- }
10
5
  displayWelcomeMessage() {
11
- intro(`Welcome to the API Recipe Generation Wizard. 🪄`);
12
- log.step(`This wizard will guide you through the process of creating an API Recipe.`);
13
- log.message(`An API Recipe is a collection of steps that allows you to define a single use case for your API Documentation portal.`);
14
- log.message(`ℹ️ Learn more: https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes`);
15
- log.message(`Let's get started! 🚀`);
6
+ log.step(`Welcome to the API Recipe Generation Wizard.`);
7
+ const message = `This wizard will guide you through the process of creating an API Recipe.
8
+
9
+ An API Recipe is a collection of steps that allows you to define a single use case for your API Documentation portal.
10
+ Learn more: ${f.link("https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes")}
11
+
12
+ Let's get started!`;
13
+ log.info(message);
14
+ }
15
+ recipeNameEmpty() {
16
+ const message = "No recipe name provided";
17
+ log.error(message);
18
+ }
19
+ contentFolderNotFound() {
20
+ const message = "Content folder not found.";
21
+ log.error(message);
22
+ }
23
+ specFileEmptyInvalid() {
24
+ const message = "Spec file is empty or invalid.";
25
+ log.error(message);
16
26
  }
17
27
  async recipeNamePrompt() {
18
28
  const recipeName = await text({
19
- message: `📘 Enter a name for your API Recipe:`,
29
+ message: `Enter a name for your API Recipe:`,
20
30
  placeholder: "This name will be displayed in your API Documentation portal sidebar.",
21
31
  validate: (name) => {
22
32
  if (!name) {
@@ -25,45 +35,10 @@ export class PortalRecipePrompts {
25
35
  }
26
36
  });
27
37
  if (isCancel(recipeName)) {
28
- cancel("Operation cancelled.");
29
- return process.exit(0);
38
+ return undefined;
30
39
  }
31
40
  return recipeName.trim();
32
41
  }
33
- //Todo: Find a better place for this function
34
- removeQuotes(str) {
35
- const quotes = ['"', "'"];
36
- for (const quote of quotes) {
37
- if (str.startsWith(quote) && str.endsWith(quote) && str.length > 1) {
38
- return this.removeQuotes(str.slice(1, -1)); // Recursive call
39
- }
40
- }
41
- return str;
42
- }
43
- async buildConfigFilePathPrompt(buildDirectoryPath) {
44
- const buildConfigFilePath = await text({
45
- message: `⚠️ APIMATIC-BUILD.json is required and was not found in "${buildDirectoryPath}".\nPlease enter the path to your build config file (relative to this directory):`,
46
- validate: (filePath) => {
47
- if (!filePath) {
48
- return "Build config file path cannot be empty. Please provide a valid file path.";
49
- }
50
- const cleanedPath = this.removeQuotes(filePath.trim());
51
- const resolvedPath = path.resolve(buildDirectoryPath, cleanedPath);
52
- if (!resolvedPath.endsWith(".json")) {
53
- return "The content file must be a JSON (.json) file. Please provide a valid file path.";
54
- }
55
- if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {
56
- return;
57
- }
58
- return "The specified path is either not a valid relative file path or it doesn't exist. Please provide a valid relative file path.";
59
- }
60
- });
61
- if (isCancel(buildConfigFilePath)) {
62
- cancel("Operation cancelled.");
63
- return process.exit(0);
64
- }
65
- return path.resolve(buildDirectoryPath, this.removeQuotes(buildConfigFilePath.trim()));
66
- }
67
42
  async stepNamePrompt(defaultStepName) {
68
43
  const stepName = await text({
69
44
  message: `Enter a name for the step:`,
@@ -71,36 +46,32 @@ export class PortalRecipePrompts {
71
46
  placeholder: `Press enter to use the default, i.e. ${defaultStepName}`
72
47
  });
73
48
  if (isCancel(stepName)) {
74
- cancel("Operation cancelled.");
75
- return process.exit(0);
49
+ return undefined;
76
50
  }
77
51
  return stepName.trim();
78
52
  }
79
53
  displayStepsInformation() {
80
- log.step(`🔧 Add Steps to your API Recipe:`);
81
- log.message(`You can add:`);
82
- log.message(`1. 📄 Content Step: Display custom content, such as instructions or information related to your API.`);
83
- log.message(`2. 🔗 Endpoint Step: Display an API endpoint, its playground and other relevant details.`);
84
- log.message(`💡 Steps appear in the order you add them.`);
85
- log.message(`📝 Let's proceed to adding steps to your API Recipe. `);
54
+ log.step(`Add Steps to your API Recipe:`);
55
+ const message = `You can add:
56
+ 1. Content Step: Display custom content, such as instructions or information related to your API.
57
+ 2. Endpoint Step: Display an API endpoint, its playground and other relevant details.
58
+ Steps appear in the order you add them.
59
+ Let's proceed to adding steps to your API Recipe.`;
60
+ log.message(message);
86
61
  }
87
62
  async stepTypeSelectionPrompt() {
88
63
  const stepType = await select({
89
- message: `➕ Select the type of step you want to add:`,
64
+ message: `Select the type of step you want to add:`,
90
65
  options: [
91
66
  { value: "content", label: "Content Step", hint: "For displaying custom content" },
92
67
  { value: "endpoint", label: "Endpoint Step", hint: "For displaying an API endpoint with its details" }
93
68
  ]
94
69
  });
95
70
  if (isCancel(stepType)) {
96
- cancel("Operation cancelled.");
97
- return process.exit(0);
71
+ return undefined;
98
72
  }
99
73
  return stepType;
100
74
  }
101
- displayContentStepInfo() {
102
- log.step("📝 Opening markdown editor for you to add content in...");
103
- }
104
75
  async endpointGroupNamePrompt(endpointGroups) {
105
76
  const groupNames = Array.from(endpointGroups.keys()).map((name) => ({
106
77
  value: name,
@@ -112,8 +83,7 @@ export class PortalRecipePrompts {
112
83
  options: groupNames
113
84
  });
114
85
  if (isCancel(endpointGroupName)) {
115
- cancel("Operation cancelled.");
116
- return process.exit(0);
86
+ return undefined;
117
87
  }
118
88
  return endpointGroupName.trim();
119
89
  }
@@ -128,76 +98,68 @@ export class PortalRecipePrompts {
128
98
  }))
129
99
  });
130
100
  if (isCancel(endpointName)) {
131
- cancel("Operation cancelled.");
132
- return process.exit(0);
101
+ return undefined;
133
102
  }
134
103
  return endpointName.trim();
135
104
  }
136
- async endpointDescriptionPrompt(endpointGroups, endpointGroupName, endpointName) {
137
- const defaultDescription = endpointGroups.get(endpointGroupName).find((e) => e.Name === endpointName).Description;
105
+ async endpointDescriptionPrompt(defaultDescription) {
138
106
  const endpointDescription = await text({
139
107
  message: `Enter a description for the endpoint:`,
140
108
  placeholder: `Optional. Leave this empty to use the endpoint description defined in the API Specification`,
141
109
  defaultValue: defaultDescription
142
110
  });
143
111
  if (isCancel(endpointDescription)) {
144
- cancel("Operation cancelled.");
145
- return process.exit(0);
112
+ return undefined;
146
113
  }
147
114
  return endpointDescription.trim();
148
115
  }
149
116
  async addAnotherStepSelectionPrompt() {
150
- const addAnotherStep = await select({
117
+ const addAnotherStep = await confirm({
151
118
  message: `Do you want to add another step?`,
152
- options: [
153
- { value: "yes", label: "Yes" },
154
- { value: "no", label: "No" }
155
- ],
156
- initialValue: "yes"
119
+ initialValue: true
157
120
  });
158
121
  if (isCancel(addAnotherStep)) {
159
- cancel("Operation cancelled.");
160
- return process.exit(0);
122
+ return false;
161
123
  }
162
- return addAnotherStep === "yes";
124
+ return addAnotherStep;
163
125
  }
164
- async overwriteApiRecipeInTocPrompt() {
165
- const overwriteApiRecipeInToc = await select({
166
- message: `⚠️ An API Recipe with this name already exists. Do you want to overwrite it?`,
167
- options: [
168
- { value: "yes", label: "Yes" },
169
- { value: "no", label: "No" }
170
- ]
126
+ async overwriteApiRecipeInTocPrompt(name) {
127
+ const overwrite = await confirm({
128
+ message: `An API Recipe with name ${f.var(name)} already exists. Do you want to overwrite it?`,
129
+ initialValue: false
171
130
  });
172
- if (isCancel(overwriteApiRecipeInToc)) {
173
- cancel("Operation cancelled.");
174
- return process.exit(0);
131
+ if (isCancel(overwrite)) {
132
+ return false;
175
133
  }
176
- return overwriteApiRecipeInToc === "yes";
134
+ return overwrite;
177
135
  }
178
136
  displayStepAddedSuccessfullyMessage() {
179
137
  log.step(`Step has been added successfully.`);
180
138
  }
181
- displayRecipeGenerationSuccessMessage(buildDirectoryPath) {
182
- log.message(`🎉 Your new API Recipe has been added to the source directory at: ${buildDirectoryPath}`);
183
- outro(`▶ Run the command 'apimatic portal:serve' to preview your documentation portal.`);
139
+ invalidBuildDirectory(directory) {
140
+ const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
141
+ log.error(message);
142
+ }
143
+ serviceError(serviceError) {
144
+ log.error(getErrorMessage(serviceError));
145
+ }
146
+ openRecipeMarkdownEditor() {
147
+ log.step("Opening markdown editor for you to enter recipe content...");
184
148
  }
185
- startProgressIndicatorWithMessage(message) {
186
- this.spin.start(message);
149
+ displayRecipeStructure(tocStructure) {
150
+ const heading = `You can edit the following files to customize your API Recipe:\n`;
151
+ const message = getTree(tocStructure);
152
+ log.info(heading + message);
187
153
  }
188
- stopProgressIndicatorWithMessage(message) {
189
- this.spin.stop(message);
154
+ nextSteps() {
155
+ const message = `Run the command '${f.cmdAlt(`apimatic`, 'portal', 'serve')}' to preview your documentation portal`;
156
+ note(message, "Next Steps");
190
157
  }
191
- displayBuildDirectoryStructureAsTree(buildDirectoryTreeObject) {
192
- const tree = treeify.asTree(buildDirectoryTreeObject, true, true);
193
- const coloredLogString = tree
194
- .split("\n")
195
- .map((line) => line.replace(/#.*/, (match) => getMessageInGreenColor(match)))
196
- .join("\n");
197
- log.step(`🛠️ You can edit the following files to customize your API Recipe :\n\n` + coloredLogString);
158
+ generateSdl(fn) {
159
+ return withSpinner("Extracting endpoints", "Endpoints extracted", "Endpoints extraction failed", fn);
198
160
  }
199
- logError(error) {
200
- outro(error);
161
+ recipeCreated() {
162
+ log.info(`A new API Recipe has been created successfully.`);
201
163
  }
202
164
  }
203
165
  //# sourceMappingURL=new-recipe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"new-recipe.js","sourceRoot":"","sources":["../../../../src/prompts/portal/recipe/new-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,Q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AAI,OAAO,CAAC,YAAY,CAAC,CAAC;QACvC,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEM,SAAS;QACd,MAAM,OAAO,GAAG,oBAAoB,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,wCAAwC,CAAC;QACpH,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAEM,WAAW,CAAC,EAAsC;QACvD,OAAO,WAAW,CAChB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,EAAE,CACH,CAAC;IACJ,CAAC;IAEM,aAAa;QAClB,GAAG,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -1,4 +1,11 @@
1
- import { BasePrompts } from "./common/base-prompts.js";
2
- export declare class PortalServePrompts extends BasePrompts {
3
- displayOutroMessage(buildDirectory: string, portalDirectory: string, port: number, hotReloadDisabled: boolean): void;
1
+ import { UrlPath } from "../../types/file/urlPath.js";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ export declare class PortalServePrompts {
4
+ usingFallbackPort(currentPort: number, availablePort: number): void;
5
+ portalServed(urlPath: UrlPath): void;
6
+ promptForExit(): void;
7
+ changesDetected(): void;
8
+ watcherError(): void;
9
+ blockExecution(): Promise<void>;
10
+ hotReloadEnabled(srcDirectory: DirectoryPath): void;
4
11
  }
@@ -1,14 +1,33 @@
1
- import { log, outro } from "@clack/prompts";
2
- import { BasePrompts } from "./common/base-prompts.js";
3
- export class PortalServePrompts extends BasePrompts {
4
- displayOutroMessage(buildDirectory, portalDirectory, port, hotReloadDisabled) {
5
- log.message(`The generated portal can be found at ${portalDirectory}`);
6
- log.message(`Server started at http://localhost:${port}`);
7
- if (!hotReloadDisabled) {
8
- log.message(`🔍 Hot reload enabled. Watching the following build folder for any changes:`);
9
- log.message(`${buildDirectory}`);
10
- }
11
- outro(`Press CTRL+C to stop the server.`);
1
+ import { log, note } from "@clack/prompts";
2
+ import { format as f } from "../format.js";
3
+ import { once } from "events";
4
+ export class PortalServePrompts {
5
+ usingFallbackPort(currentPort, availablePort) {
6
+ const message = `Port ${f.var(currentPort.toString())} is already in use. Available port ${f.var(availablePort.toString())} will be used.`;
7
+ log.step(message);
8
+ }
9
+ portalServed(urlPath) {
10
+ const message = `The portal is running at ${f.link(urlPath.toString())}`;
11
+ log.message(message);
12
+ }
13
+ promptForExit() {
14
+ const message = "Press CTRL+C to stop the server.";
15
+ log.message(message);
16
+ }
17
+ changesDetected() {
18
+ const message = "Changes detected...";
19
+ log.info(message);
20
+ }
21
+ watcherError() {
22
+ const message = `An unexpected error occurred while watching your build folder for changes. Please try again later. If the issue persists, contact our team at ${f.var('support@apimatic.io')}`;
23
+ log.error(message);
24
+ }
25
+ async blockExecution() {
26
+ await Promise.race([once(process, "SIGINT"), once(process, "SIGTERM")]);
27
+ }
28
+ hotReloadEnabled(srcDirectory) {
29
+ note(`Hot reload is enabled.
30
+ Watching the directory ${f.path(srcDirectory)} for any changes`, `Note`);
12
31
  }
13
32
  }
14
33
  //# sourceMappingURL=serve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAC1C,mBAAmB,CACxB,cAAsB,EACtB,eAAuB,EACvB,IAAY,EACZ,iBAA0B;QAE1B,GAAG,CAAC,OAAO,CAAC,wCAAwC,eAAe,EAAE,CAAC,CAAC;QACvE,GAAG,CAAC,OAAO,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,GAAG,CAAC,OAAO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C,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEM,gBAAgB,CAAC,YAA2B;QACjD,IAAI,CAAC;yBACgB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;CACF"}
@@ -1,11 +1,15 @@
1
1
  import { FilePath } from "../../../types/file/filePath.js";
2
+ import { Result } from "neverthrow";
3
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
4
+ import { ServiceError } from "../../../infrastructure/api-utils.js";
5
+ import { Sdl } from "../../../types/sdl/sdl.js";
2
6
  export declare class PortalNewTocPrompts {
3
- private readonly spin;
4
- overwriteExistingTocPrompt(tocPath: FilePath): Promise<boolean>;
5
- startProgressIndicatorWithMessage(message: string): void;
6
- stopProgressIndicatorWithMessage(message: string): void;
7
- displayOutroMessage(tocPath: FilePath): void;
8
- logError(error: string): void;
9
- displayWarning(message: string): void;
10
- displayInfo(message: string): void;
7
+ overwriteToc(tocPath: FilePath): Promise<boolean>;
8
+ fallingBackToDefault(): void;
9
+ tocFileAlreadyExists(): void;
10
+ logError(message: string): void;
11
+ contentDirectoryNotFound(contentFolderPath: DirectoryPath): void;
12
+ invalidBuildDirectory(directory: DirectoryPath): void;
13
+ extractEndpointGroupsAndModels(fn: Promise<Result<Sdl, ServiceError>>): Promise<Result<Sdl, ServiceError>>;
14
+ tocCreated(tocPath: FilePath): void;
11
15
  }
@@ -1,39 +1,37 @@
1
- import { cancel, outro, confirm, spinner, isCancel, log } from "@clack/prompts";
1
+ import { confirm, isCancel, log } from "@clack/prompts";
2
+ import { format as f, withSpinner } from "../../format.js";
2
3
  export class PortalNewTocPrompts {
3
- constructor() {
4
- this.spin = spinner();
5
- }
6
- async overwriteExistingTocPrompt(tocPath) {
4
+ async overwriteToc(tocPath) {
7
5
  const overwrite = await confirm({
8
- message: `⚠️ The destination file '${tocPath}' already exists, do you want to overwrite it?`,
6
+ message: `The destination file ${f.path(tocPath)} already exists, do you want to overwrite it?`,
9
7
  initialValue: false
10
8
  });
11
9
  if (isCancel(overwrite)) {
12
- cancel("Operation cancelled.");
13
10
  return false;
14
11
  }
15
- if (!overwrite) {
16
- log.error("Please enter a different destination path or delete the existing toc.yml file and try again.");
17
- }
18
12
  return overwrite;
19
13
  }
20
- startProgressIndicatorWithMessage(message) {
21
- this.spin.start(message);
14
+ fallingBackToDefault() {
15
+ log.warn(`Falling back to the default TOC structure.`);
16
+ }
17
+ tocFileAlreadyExists() {
18
+ log.error(`Please enter a different destination path or delete the existing toc.yml file and try again.`);
22
19
  }
23
- stopProgressIndicatorWithMessage(message) {
24
- this.spin.stop(message);
20
+ logError(message) {
21
+ log.error(message);
25
22
  }
26
- displayOutroMessage(tocPath) {
27
- outro(`toc.yml file successfully created at: ${tocPath}`);
23
+ contentDirectoryNotFound(contentFolderPath) {
24
+ log.error(`Content folder not found at: ${contentFolderPath}`);
28
25
  }
29
- logError(error) {
30
- outro(error);
26
+ invalidBuildDirectory(directory) {
27
+ const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
28
+ log.error(message);
31
29
  }
32
- displayWarning(message) {
33
- log.warning(message);
30
+ extractEndpointGroupsAndModels(fn) {
31
+ return withSpinner("Extracting endpoint groups and models", "Endpoint groups and models extracted", "Endpoint groups and models extraction failed", fn);
34
32
  }
35
- displayInfo(message) {
36
- log.step(message);
33
+ tocCreated(tocPath) {
34
+ log.info(`The TOC file successfully created at: ${f.path(tocPath)}`);
37
35
  }
38
36
  }
39
37
  //# sourceMappingURL=new-toc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/prompts/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,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CAAC,yCAAyC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;CACF"}
@@ -1,11 +1,11 @@
1
1
  import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { Result } from "neverthrow";
2
3
  export declare class SdkGeneratePrompts {
3
- private readonly spin;
4
4
  overwriteSdk(directory: DirectoryPath): Promise<boolean>;
5
- displaySdkGenerationMessage(): void;
6
- displaySdkGenerationSuccessMessage(): void;
7
- displaySdkGenerationErrorMessage(): void;
8
- displayOutroMessage(generatedSdkPath: DirectoryPath): void;
9
- logError(error: string): void;
10
- private cleanUpStandardInput;
5
+ sameSpecAndSdkDir(directory: DirectoryPath): void;
6
+ invalidSpecDirectory(directory: DirectoryPath): void;
7
+ destinationDirNotEmpty(): void;
8
+ generateSDK(fn: Promise<Result<NodeJS.ReadableStream, string>>): Promise<Result<NodeJS.ReadableStream, string>>;
9
+ logGenerationError(error: string): void;
10
+ sdkGenerated(sdk: DirectoryPath): void;
11
11
  }
@@ -1,12 +1,9 @@
1
- import { outro, spinner, isCancel, confirm, log } from "@clack/prompts";
2
- import { getMessageInRedColor, getMessageInMagentaColor, getMessageInCyanColor } from "../../utils/utils.js";
1
+ import { isCancel, confirm, log } from "@clack/prompts";
2
+ import { format as f, withSpinner } from "../format.js";
3
3
  export class SdkGeneratePrompts {
4
- constructor() {
5
- this.spin = spinner();
6
- }
7
4
  async overwriteSdk(directory) {
8
5
  const overwrite = await confirm({
9
- message: `The destination '${directory}' is not empty, do you want to overwrite?`,
6
+ message: `The destination ${f.path(directory)} is not empty, do you want to overwrite?`,
10
7
  initialValue: false
11
8
  });
12
9
  if (isCancel(overwrite)) {
@@ -14,29 +11,26 @@ export class SdkGeneratePrompts {
14
11
  }
15
12
  return overwrite;
16
13
  }
17
- displaySdkGenerationMessage() {
18
- this.spin.start(getMessageInMagentaColor("Generating SDK"));
14
+ sameSpecAndSdkDir(directory) {
15
+ const message = `The ${f.var("src")} and ${f.var("portal")} directories must be different. Current value: ${f.path(directory)}`;
16
+ this.logGenerationError(message);
19
17
  }
20
- displaySdkGenerationSuccessMessage() {
21
- this.spin.stop(getMessageInCyanColor("SDK generated successfully."));
22
- this.cleanUpStandardInput();
18
+ invalidSpecDirectory(directory) {
19
+ const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
20
+ this.logGenerationError(message);
23
21
  }
24
- displaySdkGenerationErrorMessage() {
25
- this.spin.stop(getMessageInRedColor(`SDK Generation failed.`), 1);
26
- this.cleanUpStandardInput();
22
+ destinationDirNotEmpty() {
23
+ const message = `Please enter a different destination folder or remove the existing files and try again.`;
24
+ this.logGenerationError(message);
27
25
  }
28
- displayOutroMessage(generatedSdkPath) {
29
- outro(`The generated SDK can be found at ${generatedSdkPath}`);
26
+ generateSDK(fn) {
27
+ return withSpinner("Generating SDK", "SDK generated successfully.", "SDK Generation failed.", fn);
30
28
  }
31
- logError(error) {
29
+ logGenerationError(error) {
32
30
  log.error(error);
33
31
  }
34
- //This clears the standard input to allow interrupts like CTRL+C to work properly.
35
- cleanUpStandardInput() {
36
- if (process.stdin.isTTY) {
37
- process.stdin.setRawMode(false);
38
- process.stdin.pause();
39
- }
32
+ sdkGenerated(sdk) {
33
+ log.info(`Generated SDK can be found at ${f.path(sdk)}.`);
40
34
  }
41
35
  }
42
36
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7G,MAAM,OAAO,kBAAkB;IAA/B;QACmB,SAAI,GAAG,OAAO,EAAE,CAAC;IA4CpC,CAAC;IA1CQ,KAAK,CAAC,Y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AAkB;QACpC,GAAG,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF"}
@@ -4,7 +4,7 @@ export interface SubscriptionInfo {
4
4
  FullName: string;
5
5
  SecurityStamp: string;
6
6
  tenantId: string;
7
- allowedLanguages: string;
7
+ allowedLanguages: number;
8
8
  isPackagePublishingAllowed: boolean;
9
9
  ApiCopilotKeys: string[];
10
10
  }
@@ -1,14 +1,3 @@
1
- import { TransformationController } from "@apimatic/sdk";
2
- export type TransformationIdParams = {
3
- file: string;
4
- url: string;
5
- format: string;
6
- };
7
- export type DownloadTransformationParams = {
8
- id: string;
9
- destinationFilePath: string;
10
- transformationController: TransformationController;
11
- };
12
1
  export type TransformationData = {
13
2
  result: NodeJS.ReadableStream | Blob;
14
3
  };
@@ -28,18 +17,18 @@ export declare const DestinationFormats: {
28
17
  GraphQlSchema: string;
29
18
  };
30
19
  export declare enum TransformationFormats {
31
- APIMATIC = "Apimatic",
32
- WADL2009 = "Wadl2009",
33
- WSDL = "Wsdl",
34
- SWAGGER10 = "Swagger10",
35
- SWAGGER20 = "Swagger20",
36
- SWAGGERYAML = "Swaggeryaml",
37
- OAS3 = "Oas3",
38
- OPENAPI3YAML = "Openapi3Yaml",
39
- APIBLUEPRINT = "Apiblueprint",
40
- RAML = "Raml",
41
- RAML10 = "Raml10",
42
- POSTMAN10 = "Postman10",
43
- POSTMAN20 = "Postman20",
44
- GRAPHQLSCHEMA = "Graphqlschema"
20
+ apimatic = "Apimatic",
21
+ wadl2009 = "Wadl2009",
22
+ wsdl = "Wsdl",
23
+ swagger10 = "Swagger10",
24
+ swagger20 = "Swagger20",
25
+ swaggeryaml = "Swaggeryaml",
26
+ oas3 = "Oas3",
27
+ openapi3yaml = "Openapi3Yaml",
28
+ apiblueprint = "Apiblueprint",
29
+ raml = "Raml",
30
+ raml10 = "Raml10",
31
+ postman10 = "Postman10",
32
+ postman20 = "Postman20",
33
+ graphqlschema = "Graphqlschema"
45
34
  }