alova.config.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* eslint-disable no-irregular-whitespace */
  2. import type { Config } from '@alova/wormhole'
  3. // For more config detailed visit:
  4. // https://alova.js.org/tutorial/getting-started/extension-integration
  5. export default <Config>{
  6. generator: [
  7. {
  8. /**
  9. * file input. support:
  10. * 1. openapi json file url
  11. * 2. local file
  12. */
  13. input: 'https://petstore3.swagger.io/api/v3/openapi.json',
  14. /**
  15. * input file platform. Currently only swagger is supported.
  16. * When this parameter is specified, the input field only needs to specify the document address without specifying the openapi file
  17. */
  18. platform: 'swagger',
  19. /**
  20. * output path of interface file and type file.
  21. * Multiple generators cannot have the same address, otherwise the generated code will overwrite each other.
  22. */
  23. output: 'src/api',
  24. /**
  25. * the mediaType of the generated response data. default is `application/json`
  26. */
  27. responseMediaType: 'application/json',
  28. /**
  29. * the bodyMediaType of the generated request body data. default is `application/json`
  30. */
  31. bodyMediaType: 'application/json',
  32. /**
  33. * the generated api version. options are `2` or `3`, default is `auto`.
  34. */
  35. version: 3,
  36. /**
  37. * type of generated code. The options ​​are `auto/ts/typescript/module/commonjs`.
  38. */
  39. type: 'typescript',
  40. /**
  41. * exported global api name, you can access the generated api globally through this name, default is `Apis`.
  42. * it is required when multiple generators are configured, and it cannot be repeated
  43. */
  44. global: 'Apis',
  45. /**
  46. * filter or convert the generated api information, return an apiDescriptor, if this function is not specified, the apiDescripor object is not converted
  47. */
  48. handleApi: (apiDescriptor) => {
  49. // Skip logging to console
  50. // console.log(apiDescriptor)
  51. // Filter out any deprecated APIs if needed
  52. if (apiDescriptor.deprecated) {
  53. return undefined // Skip this API
  54. }
  55. // You can transform the API descriptor here if needed
  56. // For example, add custom headers, modify parameters, etc.
  57. return apiDescriptor
  58. },
  59. },
  60. ],
  61. /**
  62. * extension only
  63. * whether to automatically update the interface, enabled by default, check every 5 minutes, closed when set to `false`
  64. */
  65. autoUpdate: {
  66. // Update when editor is launched
  67. launchEditor: true,
  68. // Check for updates every 5 minutes
  69. interval: 5 * 60 * 1000,
  70. },
  71. }