api-farmer 0.0.18 → 0.0.19

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.
package/README.md CHANGED
@@ -56,6 +56,16 @@ npx af
56
56
 
57
57
  Some simple usage examples can be found [here](fixtures)
58
58
 
59
+ ### Custom code generation templates
60
+
61
+ Create `api-farmer.ejs` in the project root, which will replace the `preset` template.
62
+ The template format can refer to the preset template listed below:
63
+
64
+ - [Axle](templates/axle.ejs)
65
+ - [Axios](templates/axios.ejs)
66
+
67
+ And see the bottom of the document for template variable definitions.
68
+
59
69
  ### Transformer API
60
70
 
61
71
  You can use the Transformer API to further define template variables, which will override the default transformation rules.
@@ -86,16 +96,6 @@ export default defineConfig({
86
96
  })
87
97
  ```
88
98
 
89
- ### Custom EJS Template
90
-
91
- Create `api-farmer.ejs` in the project root, which will replace the `preset` template.
92
- The template format can refer to the preset template listed below:
93
-
94
- - [Axle](templates/axle.ejs)
95
- - [Axios](templates/axios.ejs)
96
-
97
- See the bottom of the document for template variable definitions.
98
-
99
99
  ### Configuration Options
100
100
 
101
101
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-farmer",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "API module generation tool based on Openapi3/Swagger2.",
5
5
  "keywords": [
6
6
  "cli",
@@ -89,6 +89,7 @@
89
89
  "dev": "tsup src/index.ts src/cli.ts --format esm,cjs --watch --dts --shims",
90
90
  "format": "prettier --write .",
91
91
  "lint": "eslint . --fix",
92
- "release": "pnpm build && vr release"
92
+ "release": "pnpm build && vr release",
93
+ "gen": "pnpm --dir ./fixtures/axios gen & pnpm --dir ./fixtures/axle gen"
93
94
  }
94
95
  }
@@ -1,10 +1,10 @@
1
- <% if (ts && !typesOnly) { %> import { type AxiosRequestConfig } from 'axios' <% } %>
1
+ <% if (ts && !typesOnly) { %> import type { RequestConfig } from '@/request' <% } %>
2
2
  <% if (!typesOnly) { %> import { request } from '@/request' <% } %>
3
3
  <% if (ts) { %> import { type paths } from './<%- typesFilename %>' <% } %>
4
4
 
5
5
  <% if (!typesOnly) { %>
6
6
  <% apiModule.payloads.forEach(payload => { %> -%>
7
- export const <%- payload.fn %> = (config<% if (ts) { %>: AxiosRequestConfig<<%- payload.typeRequestBody %>> <% } %>)
7
+ export const <%- payload.fn %> = (config<% if (ts) { %>: RequestConfig<<%- payload.typeRequestBody %>> <% } %> = {})
8
8
  => request<% if (ts) { %><any, <%- payload.typeResponseBody %>><% } %>({
9
9
  url: '<%- payload.url %>',
10
10
  method: '<%- payload.method %>',