anl 1.4.10 → 1.4.11

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.
@@ -0,0 +1,21 @@
1
+ type TDatalevel = 'data' | 'serve' | 'axios';
2
+ type RServe<T> = Promise<ResponseModel<T>>;
3
+
4
+ type RAxios<T> = Promise<import('axios').AxiosResponse<ResponseModel<T>>>;
5
+
6
+ type ResponseModel<T> = {
7
+ code: number;
8
+ msg: string;
9
+ data: T;
10
+ };
11
+
12
+ interface IRequestFnRestParams<P = any> {
13
+ config?: import('axios').AxiosRequestConfig<P>;
14
+ datalevel?: TDatalevel;
15
+ [key: string]: any;
16
+ }
17
+
18
+ interface IRequestFnParams<P = any> extends IRequestFnRestParams<P> {
19
+ query?: any;
20
+ body?: any;
21
+ }
@@ -1,101 +1,142 @@
1
- import type { AxiosRequestConfig, AxiosResponse } from 'axios';
1
+ import type { AxiosResponse } from 'axios';
2
2
 
3
3
  import { dio as axios } from './config';
4
-
5
- // 将这里替换为自己的错误提示
6
4
  import { messageTip } from './error-message';
7
5
 
8
- type TDatalevel = 'data' | 'serve' | 'axios';
9
- export type RServe<T> = Promise<BaseResponse<T>>;
10
- export type RAxios<T> = Promise<AxiosResponse<BaseResponse<T>>>;
11
- export type BaseResponse<T> = {
12
- code: number;
13
- msg: string;
14
- data: T;
6
+ type RequestParamsWithDataLevel<P, D extends TDatalevel = 'serve'> = Omit<IRequestFnParams<P>, 'datalevel'> & {
7
+ datalevel?: D;
15
8
  };
16
9
 
17
- function POST<R = unknown, P = unknown>(url: string, data?: P, datalevel?: 'serve', config?: AxiosRequestConfig<P>): RServe<R>;
18
- function POST<R = unknown, P = unknown>(url: string, data?: P, datalevel?: 'data', config?: AxiosRequestConfig<P>): Promise<R>;
19
- function POST<R = unknown, P = unknown>(url: string, data?: P, datalevel?: 'axios', config?: AxiosRequestConfig<P>): RAxios<R>;
20
- function POST<R = unknown, P = unknown>(url: string, data?: P, datalevel: TDatalevel = 'serve', config?: AxiosRequestConfig<P>) {
21
- return axios.post<P, AxiosResponse<BaseResponse<R>>>(url, data, config).then((res) => {
22
- messageTip(res);
23
- switch (datalevel) {
24
- case 'data':
25
- return res.data.data;
26
- case 'serve':
27
- return res.data;
28
- case 'axios':
29
- return res;
30
- }
10
+ function GET<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'serve'>): RServe<R>;
11
+ function GET<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'data'>): Promise<R>;
12
+ function GET<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'axios'>): RAxios<R>;
13
+ function GET<R = unknown, P = unknown>(
14
+ url: string,
15
+ { query = {}, config = {}, datalevel = 'serve' }: IRequestFnParams<P> = {},
16
+ ): Promise<R> | RServe<R> | RAxios<R> {
17
+ return axios.request<P, AxiosResponse<ResponseModel<R>>>({
18
+ ...config,
19
+ url,
20
+ params: query,
21
+ method: 'get',
22
+ transformResponse(res) {
23
+ messageTip(res);
24
+ switch (datalevel) {
25
+ case 'data':
26
+ return res.data.data;
27
+ case 'serve':
28
+ return res.data;
29
+ case 'axios':
30
+ return res;
31
+ }
32
+ },
31
33
  });
32
34
  }
33
35
 
34
- function GET<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'serve', config?: AxiosRequestConfig<P>): RServe<R>;
35
- function GET<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'data', config?: AxiosRequestConfig<P>): Promise<R>;
36
- function GET<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'axios', config?: AxiosRequestConfig<P>): RAxios<R>;
37
- function GET<R = unknown, P = unknown>(url: string, params?: P, datalevel: TDatalevel = 'serve', config?: AxiosRequestConfig<P>) {
38
- return axios.get<P, AxiosResponse<BaseResponse<R>>>(url, { params, ...config }).then((res) => {
39
- messageTip(res);
40
- switch (datalevel) {
41
- case 'data':
42
- return res.data.data;
43
- case 'serve':
44
- return res.data;
45
- case 'axios':
46
- return res;
47
- }
36
+ function DELETE<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'serve'>): RServe<R>;
37
+ function DELETE<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'data'>): Promise<R>;
38
+ function DELETE<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'axios'>): RAxios<R>;
39
+ function DELETE<R = unknown, P = unknown>(
40
+ url: string,
41
+ { query = {}, config = {}, datalevel = 'serve' }: IRequestFnParams<P> = {},
42
+ ): Promise<R> | RServe<R> | RAxios<R> {
43
+ return axios.request<P, AxiosResponse<ResponseModel<R>>>({
44
+ ...config,
45
+ url,
46
+ params: query,
47
+ method: 'delete',
48
+ transformResponse(res) {
49
+ messageTip(res);
50
+ switch (datalevel) {
51
+ case 'data':
52
+ return res.data.data;
53
+ case 'serve':
54
+ return res.data;
55
+ case 'axios':
56
+ return res;
57
+ }
58
+ },
48
59
  });
49
60
  }
50
61
 
51
- function DELETE<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'serve', config?: AxiosRequestConfig<P>): RServe<R>;
52
- function DELETE<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'data', config?: AxiosRequestConfig<P>): Promise<R>;
53
- function DELETE<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'axios', config?: AxiosRequestConfig<P>): RAxios<R>;
54
- function DELETE<R = unknown, P = unknown>(url: string, params?: P, datalevel: TDatalevel = 'serve', config?: AxiosRequestConfig<P>) {
55
- return axios.delete<P, AxiosResponse<BaseResponse<R>>>(url, { params, ...config }).then((res) => {
56
- messageTip(res);
57
- switch (datalevel) {
58
- case 'data':
59
- return res.data.data;
60
- case 'serve':
61
- return res.data;
62
- case 'axios':
63
- return res;
64
- }
62
+ function PUT<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'serve'>): RServe<R>;
63
+ function PUT<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'data'>): Promise<R>;
64
+ function PUT<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'axios'>): RAxios<R>;
65
+ function PUT<R = unknown, P = unknown>(
66
+ url: string,
67
+ { query = {}, body = {}, config = {}, datalevel = 'serve' }: IRequestFnParams<P> = {},
68
+ ): Promise<R> | RServe<R> | RAxios<R> {
69
+ return axios.request<P, AxiosResponse<ResponseModel<R>>>({
70
+ ...config,
71
+ url,
72
+ params: query,
73
+ data: body,
74
+ method: 'put',
75
+ transformResponse(res) {
76
+ messageTip(res);
77
+ switch (datalevel) {
78
+ case 'data':
79
+ return res.data.data;
80
+ case 'serve':
81
+ return res.data;
82
+ case 'axios':
83
+ return res;
84
+ }
85
+ },
65
86
  });
66
87
  }
67
88
 
68
- function PATCH<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'serve', config?: AxiosRequestConfig<P>): RServe<R>;
69
- function PATCH<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'data', config?: AxiosRequestConfig<P>): Promise<R>;
70
- function PATCH<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'axios', config?: AxiosRequestConfig<P>): RAxios<R>;
71
- function PATCH<R = unknown, P = unknown>(url: string, params?: P, datalevel: TDatalevel = 'serve', config?: AxiosRequestConfig<P>) {
72
- return axios.patch<P, AxiosResponse<BaseResponse<R>>>(url, params, config).then((res) => {
73
- messageTip(res);
74
- switch (datalevel) {
75
- case 'data':
76
- return res.data.data;
77
- case 'serve':
78
- return res.data;
79
- case 'axios':
80
- return res;
81
- }
89
+ function POST<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'serve'>): RServe<R>;
90
+ function POST<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'data'>): Promise<R>;
91
+ function POST<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'axios'>): RAxios<R>;
92
+ function POST<R = unknown, P = unknown>(
93
+ url: string,
94
+ { query = {}, body = {}, config = {}, datalevel = 'serve' }: IRequestFnParams<P> = {},
95
+ ): Promise<R> | RServe<R> | RAxios<R> {
96
+ return axios.request<P, AxiosResponse<ResponseModel<R>>>({
97
+ ...config,
98
+ url,
99
+ params: query,
100
+ data: body,
101
+ method: 'post',
102
+ transformResponse(res) {
103
+ messageTip(res);
104
+ switch (datalevel) {
105
+ case 'data':
106
+ return res.data.data;
107
+ case 'serve':
108
+ return res.data;
109
+ case 'axios':
110
+ return res;
111
+ }
112
+ },
82
113
  });
83
114
  }
84
115
 
85
- function PUT<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'serve', config?: AxiosRequestConfig<P>): RServe<R>;
86
- function PUT<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'data', config?: AxiosRequestConfig<P>): Promise<R>;
87
- function PUT<R = unknown, P = unknown>(url: string, params?: P, datalevel?: 'axios', config?: AxiosRequestConfig<P>): RAxios<R>;
88
- function PUT<R = unknown, P = unknown>(url: string, params?: P, datalevel: TDatalevel = 'serve', config?: AxiosRequestConfig<P>) {
89
- return axios.put<P, AxiosResponse<BaseResponse<R>>>(url, params, config).then((res) => {
90
- messageTip(res);
91
- switch (datalevel) {
92
- case 'data':
93
- return res.data.data;
94
- case 'serve':
95
- return res.data;
96
- case 'axios':
97
- return res;
98
- }
116
+ function PATCH<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'serve'>): RServe<R>;
117
+ function PATCH<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'data'>): Promise<R>;
118
+ function PATCH<R = unknown, P = unknown>(url: string, params?: RequestParamsWithDataLevel<P, 'axios'>): RAxios<R>;
119
+ function PATCH<R = unknown, P = unknown>(
120
+ url: string,
121
+ { query = {}, body = {}, config = {}, datalevel = 'serve' }: IRequestFnParams<P> = {},
122
+ ): Promise<R> | RServe<R> | RAxios<R> {
123
+ return axios.request<P, AxiosResponse<ResponseModel<R>>>({
124
+ ...config,
125
+ url,
126
+ params: query,
127
+ data: body,
128
+ method: 'patch',
129
+ transformResponse(res) {
130
+ messageTip(res);
131
+ switch (datalevel) {
132
+ case 'data':
133
+ return res.data.data;
134
+ case 'serve':
135
+ return res.data;
136
+ case 'axios':
137
+ return res;
138
+ }
139
+ },
99
140
  });
100
141
  }
101
142
 
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="3.0.3",t={title:"Swagger Petstore - OpenAPI 3.0",description:"This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about\nSwagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!\nYou can now help us improve the API whether it's by making changes to the definition itself or to the code.\nThat way, with time, we can improve the API in general, and expose some of the new features in OAS3.\n\n_If you're looking for the Swagger 2.0/OAS 2.0 version of Petstore, then click [here](https://editor.swagger.io/?url=https://petstore.swagger.io/v2/swagger.yaml). Alternatively, you can load via the `Edit > Load Petstore OAS 2.0` menu option!_\n\nSome useful links:\n- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)\n- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)",termsOfService:"http://swagger.io/terms/",contact:{email:"apiteam@swagger.io"},license:{name:"Apache 2.0",url:"http://www.apache.org/licenses/LICENSE-2.0.html"},version:"1.0.11"},s={description:"Find out more about Swagger",url:"http://swagger.io"},r=[{url:"https://petstore3.swagger.io/api/v3"}],a=[{name:"pet",description:"Everything about your Pets",externalDocs:{description:"Find out more",url:"http://swagger.io"}},{name:"store",description:"Access to Petstore orders",externalDocs:{description:"Find out more about our store",url:"http://swagger.io"}},{name:"user",description:"Operations about user"}],o={"/pet":{put:{tags:["pet"],summary:"Update an existing pet",description:"Update an existing pet by Id",operationId:"updatePet",requestBody:{description:"Update an existent pet in the store",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}},"application/x-www-form-urlencoded":{schema:{$ref:"#/components/schemas/Pet"}}},required:!0},responses:{200:{description:"Successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}}}},400:{description:"Invalid ID supplied"},404:{description:"Pet not found"},422:{description:"Validation exception"}},security:[{petstore_auth:["write:pets","read:pets"]}]},post:{tags:["pet"],summary:"Add a new pet to the store",description:"Add a new pet to the store",operationId:"addPet",requestBody:{description:"Create a new pet in the store",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}},"application/x-www-form-urlencoded":{schema:{$ref:"#/components/schemas/Pet"}}},required:!0},responses:{200:{description:"Successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}}}},400:{description:"Invalid input"},422:{description:"Validation exception"}},security:[{petstore_auth:["write:pets","read:pets"]}]}},"/pet/findByStatus":{get:{tags:["pet"],summary:"Finds Pets by status",description:"Multiple status values can be provided with comma separated strings",operationId:"findPetsByStatus",parameters:[{name:"status",in:"query",description:"Status values that need to be considered for filter",required:!1,explode:!0,schema:{type:"string",default:"available",enum:["available","pending","sold"]}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{$ref:"#/components/schemas/Pet"}}},"application/xml":{schema:{type:"array",items:{$ref:"#/components/schemas/Pet"}}}}},400:{description:"Invalid status value"}},security:[{petstore_auth:["write:pets","read:pets"]}]}},"/pet/findByTags":{get:{tags:["pet"],summary:"Finds Pets by tags",description:"Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",operationId:"findPetsByTags",parameters:[{name:"tags",in:"query",description:"Tags to filter by",required:!1,explode:!0,schema:{type:"array",items:{type:"string"}}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{$ref:"#/components/schemas/Pet"}}},"application/xml":{schema:{type:"array",items:{$ref:"#/components/schemas/Pet"}}}}},400:{description:"Invalid tag value"}},security:[{petstore_auth:["write:pets","read:pets"]}]}},"/pet/{petId}":{get:{tags:["pet"],summary:"Find pet by ID",description:"Returns a single pet",operationId:"getPetById",parameters:[{name:"petId",in:"path",description:"ID of pet to return",required:!0,schema:{type:"integer",format:"int64"}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}}}},400:{description:"Invalid ID supplied"},404:{description:"Pet not found"}},security:[{api_key:[]},{petstore_auth:["write:pets","read:pets"]}]},post:{tags:["pet"],summary:"Updates a pet in the store with form data",description:"",operationId:"updatePetWithForm",parameters:[{name:"petId",in:"path",description:"ID of pet that needs to be updated",required:!0,schema:{type:"integer",format:"int64"}},{name:"name",in:"query",description:"Name of pet that needs to be updated",schema:{type:"string"}},{name:"status",in:"query",description:"Status of pet that needs to be updated",schema:{type:"string"}}],responses:{400:{description:"Invalid input"}},security:[{petstore_auth:["write:pets","read:pets"]}]},delete:{tags:["pet"],summary:"Deletes a pet",description:"delete a pet",operationId:"deletePet",parameters:[{name:"api_key",in:"header",description:"",required:!1,schema:{type:"string"}},{name:"petId",in:"path",description:"Pet id to delete",required:!0,schema:{type:"integer",format:"int64"}}],responses:{400:{description:"Invalid pet value"}},security:[{petstore_auth:["write:pets","read:pets"]}]}},"/pet/{petId}/uploadImage":{post:{tags:["pet"],summary:"uploads an image",description:"",operationId:"uploadFile",parameters:[{name:"petId",in:"path",description:"ID of pet to update",required:!0,schema:{type:"integer",format:"int64"}},{name:"additionalMetadata",in:"query",description:"Additional Metadata",required:!1,schema:{type:"string"}}],requestBody:{content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}},responses:{200:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/ApiResponse"}}}}},security:[{petstore_auth:["write:pets","read:pets"]}]}},"/store/inventory":{get:{tags:["store"],summary:"Returns pet inventories by status",description:"Returns a map of status codes to quantities",operationId:"getInventory",responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"object",additionalProperties:{type:"integer",format:"int32"}}}}}},security:[{api_key:[]}]}},"/store/order":{post:{tags:["store"],summary:"Place an order for a pet",description:"Place a new order in the store",operationId:"placeOrder",requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/Order"}},"application/xml":{schema:{$ref:"#/components/schemas/Order"}},"application/x-www-form-urlencoded":{schema:{$ref:"#/components/schemas/Order"}}}},responses:{200:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/Order"}}}},400:{description:"Invalid input"},422:{description:"Validation exception"}}}},"/store/order/{orderId}":{get:{tags:["store"],summary:"Find purchase order by ID",description:"For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.",operationId:"getOrderById",parameters:[{name:"orderId",in:"path",description:"ID of order that needs to be fetched",required:!0,schema:{type:"integer",format:"int64"}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/Order"}},"application/xml":{schema:{$ref:"#/components/schemas/Order"}}}},400:{description:"Invalid ID supplied"},404:{description:"Order not found"}}},delete:{tags:["store"],summary:"Delete purchase order by ID",description:"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",operationId:"deleteOrder",parameters:[{name:"orderId",in:"path",description:"ID of the order that needs to be deleted",required:!0,schema:{type:"integer",format:"int64"}}],responses:{400:{description:"Invalid ID supplied"},404:{description:"Order not found"}}}},"/user":{post:{tags:["user"],summary:"Create user",description:"This can only be done by the logged in user.",operationId:"createUser",requestBody:{description:"Created user object",content:{"application/json":{schema:{$ref:"#/components/schemas/User"}},"application/xml":{schema:{$ref:"#/components/schemas/User"}},"application/x-www-form-urlencoded":{schema:{$ref:"#/components/schemas/User"}}}},responses:{default:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/User"}},"application/xml":{schema:{$ref:"#/components/schemas/User"}}}}}}},"/user/createWithList":{post:{tags:["user"],summary:"Creates list of users with given input array",description:"Creates list of users with given input array",operationId:"createUsersWithListInput",requestBody:{content:{"application/json":{schema:{type:"array",items:{$ref:"#/components/schemas/User"}}}}},responses:{200:{description:"Successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/User"}},"application/xml":{schema:{$ref:"#/components/schemas/User"}}}},default:{description:"successful operation"}}}},"/user/login":{get:{tags:["user"],summary:"Logs user into the system",description:"",operationId:"loginUser",parameters:[{name:"username",in:"query",description:"The user name for login",required:!1,schema:{type:"string"}},{name:"password",in:"query",description:"The password for login in clear text",required:!1,schema:{type:"string"}}],responses:{200:{description:"successful operation",headers:{"X-Rate-Limit":{description:"calls per hour allowed by the user",schema:{type:"integer",format:"int32"}},"X-Expires-After":{description:"date in UTC when token expires",schema:{type:"string",format:"date-time"}}},content:{"application/xml":{schema:{type:"string"}},"application/json":{schema:{type:"string"}}}},400:{description:"Invalid username/password supplied"}}}},"/user/logout":{get:{tags:["user"],summary:"Logs out current logged in user session",description:"",operationId:"logoutUser",parameters:[],responses:{default:{description:"successful operation"}}}},"/user/{username}":{get:{tags:["user"],summary:"Get user by user name",description:"",operationId:"getUserByName",parameters:[{name:"username",in:"path",description:"The name that needs to be fetched. Use user1 for testing. ",required:!0,schema:{type:"string"}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{$ref:"#/components/schemas/User"}},"application/xml":{schema:{$ref:"#/components/schemas/User"}}}},400:{description:"Invalid username supplied"},404:{description:"User not found"}}},put:{tags:["user"],summary:"Update user",description:"This can only be done by the logged in user.",operationId:"updateUser",parameters:[{name:"username",in:"path",description:"name that need to be deleted",required:!0,schema:{type:"string"}}],requestBody:{description:"Update an existent user in the store",content:{"application/json":{schema:{$ref:"#/components/schemas/User"}},"application/xml":{schema:{$ref:"#/components/schemas/User"}},"application/x-www-form-urlencoded":{schema:{$ref:"#/components/schemas/User"}}}},responses:{default:{description:"successful operation"}}},delete:{tags:["user"],summary:"Delete user",description:"This can only be done by the logged in user.",operationId:"deleteUser",parameters:[{name:"username",in:"path",description:"The name that needs to be deleted",required:!0,schema:{type:"string"}}],responses:{400:{description:"Invalid username supplied"},404:{description:"User not found"}}}}},n={schemas:{Order:{type:"object",properties:{id:{type:"integer",format:"int64",example:10},petId:{type:"integer",format:"int64",example:198772},quantity:{type:"integer",format:"int32",example:7},shipDate:{type:"string",format:"date-time"},status:{type:"string",description:"Order Status",example:"approved",enum:["placed","approved","delivered"]},complete:{type:"boolean"}},xml:{name:"order"}},Customer:{type:"object",properties:{id:{type:"integer",format:"int64",example:1e5},username:{type:"string",example:"fehguy"},address:{type:"array",xml:{name:"addresses",wrapped:!0},items:{$ref:"#/components/schemas/Address"}}},xml:{name:"customer"}},Address:{type:"object",properties:{street:{type:"string",example:"437 Lytton"},city:{type:"string",example:"Palo Alto"},state:{type:"string",example:"CA"},zip:{type:"string",example:"94301"}},xml:{name:"address"}},Category:{type:"object",properties:{id:{type:"integer",format:"int64",example:1},name:{type:"string",example:"Dogs"}},xml:{name:"category"}},User:{type:"object",properties:{id:{type:"integer",format:"int64",example:10},username:{type:"string",example:"theUser"},firstName:{type:"string",example:"John"},lastName:{type:"string",example:"James"},email:{type:"string",example:"john@email.com"},password:{type:"string",example:"12345"},phone:{type:"string",example:"12345"},userStatus:{type:"integer",description:"User Status",format:"int32",example:1}},xml:{name:"user"}},Tag:{type:"object",properties:{id:{type:"integer",format:"int64"},name:{type:"string"}},xml:{name:"tag"}},Pet:{required:["name","photoUrls"],type:"object",properties:{id:{type:"integer",format:"int64",example:10},name:{type:"string",example:"doggie"},category:{$ref:"#/components/schemas/Category"},photoUrls:{type:"array",xml:{wrapped:!0},items:{type:"string",xml:{name:"photoUrl"}}},tags:{type:"array",xml:{wrapped:!0},items:{$ref:"#/components/schemas/Tag"}},status:{type:"string",description:"pet status in the store",enum:["available","pending","sold"]}},xml:{name:"pet"}},ApiResponse:{type:"object",properties:{code:{type:"integer",format:"int32"},type:{type:"string"},message:{type:"string"}},xml:{name:"##default"}}},requestBodies:{Pet:{description:"Pet object that needs to be added to the store",content:{"application/json":{schema:{$ref:"#/components/schemas/Pet"}},"application/xml":{schema:{$ref:"#/components/schemas/Pet"}}}},UserArray:{description:"List of user object",content:{"application/json":{schema:{type:"array",items:{$ref:"#/components/schemas/User"}}}}}},securitySchemes:{petstore_auth:{type:"oauth2",flows:{implicit:{authorizationUrl:"https://petstore3.swagger.io/oauth/authorize",scopes:{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}},api_key:{type:"apiKey",name:"api_key",in:"header"}}},i={openapi:e,info:t,externalDocs:s,servers:r,tags:a,paths:o,components:n};exports.components=n,exports.default=i,exports.externalDocs=s,exports.info=t,exports.openapi=e,exports.paths=o,exports.servers=r,exports.tags=a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="1.4.10",i="FE command line tool",s="bin/an-cli.js",l={dev:"rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript -w",build:"rimraf lib && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",pub:"bash publish.sh",ts:"tsc ./src/int.ts --noEmit --watch",blink:"npm run build && npm link"},p={anl:"bin/an-cli.js"},t="Gleason <bianliuzhu@gmail.com>",r={"@commitlint/cli":"^17.4.3","@commitlint/config-conventional":"^17.4.3","@rollup/plugin-commonjs":"^21.0.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.3","@rollup/plugin-typescript":"^8.3.0","@types/inquirer":"^9.0.3","@types/shelljs":"^0.8.11","@typescript-eslint/eslint-plugin":"^5.52.0","@typescript-eslint/parser":"^5.52.0","cross-env":"^7.0.3",eslint:"^8.7.0",husky:"^8.0.3","openapi-types":"^12.1.3",prettier:"^3.3.2",rimraf:"^5.0.7",rollup:"^2.64.0","rollup-plugin-cleandir":"^2.0.0","rollup-plugin-copy":"^3.5.0","rollup-plugin-terser":"^7.0.2",typescript:"^4.5.4"},o={"app-root-path":"^3.1.0",cac:"^6.7.12",chalk:"4.*","clear-console":"^1.1.0",commander:"^10.0.0",figures:"^6.1.0",inquirer:"^10.1.8","log-symbols":"^5.1.0",ora:"5.*","progress-estimator":"^0.3.0",shelljs:"^0.8.5"},n=["typescript","cli","typescript 脚手架","ts 脚手架","ts-cli","脚手架"],c=["package.json","README.md","lib","template"],u={type:"git",url:"https://github.com/bianliuzhu/an-cli.git"},a="commonjs",m={name:"anl",version:e,description:i,main:s,scripts:l,bin:p,author:t,license:"ISC",devDependencies:r,dependencies:o,keywords:n,files:c,repository:u,type:a};exports.author=t,exports.bin=p,exports.default=m,exports.dependencies=o,exports.description=i,exports.devDependencies=r,exports.files=c,exports.keywords=n,exports.license="ISC",exports.main=s,exports.name="anl",exports.repository=u,exports.scripts=l,exports.type=a,exports.version=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="1.4.11",i="FE command line tool",s="bin/an-cli.js",l={dev:"rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript -w",build:"rimraf lib && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",pub:"bash publish.sh",ts:"tsc ./src/int.ts --noEmit --watch",blink:"npm run build && npm link"},p={anl:"bin/an-cli.js"},t="Gleason <bianliuzhu@gmail.com>",r={"@commitlint/cli":"^17.4.3","@commitlint/config-conventional":"^17.4.3","@rollup/plugin-commonjs":"^21.0.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.3","@rollup/plugin-typescript":"^8.3.0","@types/inquirer":"^9.0.3","@types/shelljs":"^0.8.11","@typescript-eslint/eslint-plugin":"^5.52.0","@typescript-eslint/parser":"^5.52.0","cross-env":"^7.0.3",eslint:"^8.7.0",husky:"^8.0.3","openapi-types":"^12.1.3",prettier:"^3.3.2",rimraf:"^5.0.7",rollup:"^2.64.0","rollup-plugin-cleandir":"^2.0.0","rollup-plugin-copy":"^3.5.0","rollup-plugin-terser":"^7.0.2",typescript:"^4.5.4"},o={"app-root-path":"^3.1.0",cac:"^6.7.12",chalk:"4.*","clear-console":"^1.1.0",commander:"^10.0.0",figures:"^6.1.0",inquirer:"^10.1.8","log-symbols":"^5.1.0",ora:"5.*","progress-estimator":"^0.3.0",shelljs:"^0.8.5"},n=["typescript","cli","typescript 脚手架","ts 脚手架","ts-cli","脚手架"],c=["package.json","README.md","lib","template"],u={type:"git",url:"https://github.com/bianliuzhu/an-cli.git"},a="commonjs",m={name:"anl",version:e,description:i,main:s,scripts:l,bin:p,author:t,license:"ISC",devDependencies:r,dependencies:o,keywords:n,files:c,repository:u,type:a};exports.author=t,exports.bin=p,exports.default=m,exports.dependencies=o,exports.description=i,exports.devDependencies=r,exports.files=c,exports.keywords=n,exports.license="ISC",exports.main=s,exports.name="anl",exports.repository=u,exports.scripts=l,exports.type=a,exports.version=e;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/index.js");const t="\t";var r;!function(e){e.GET="get",e.PUT="put",e.POST="post",e.DELETE="delete",e.OPTIONS="options",e.HEAD="head",e.PATCH="patch",e.TRACE="trace"}(r||(r={}));const n={typeMapping:new Map([["integer","number"],["string","string"],["boolean","boolean"],["binary","File"]]),errorHandling:{throwOnError:!1,logErrors:!0}},s="#/components/schemas/",a="#/components/parameters/",i="#/definitions/";class o{pathsObject={};nonArrayType=["boolean","object","number","string","integer"];pathKey="";contentBody={payload:{path:[],query:[],body:[]},response:"",_response:"",fileName:"",method:"",requestPath:"",summary:"",apiName:"",typeName:"",deprecated:!1};Map=new Map;config;errors=[];referenceCache=new Map;parameters={};templates={exportConst:e=>`export const ${e}`,typeDefinition:(e,t)=>`type ${e} = ${t}`,interfaceDefinition:e=>`interface ${e}`};constructor(e,t,r){this.pathsObject=e,this.parameters=t??{},this.config={...n,...r,typeMapping:new Map([...n.typeMapping||[],...r.typeMapping||[]])}}handleError(t){if(this.errors.push(t),this.config.errorHandling?.logErrors&&e.log.error(`${t.type}: ${t.message}${t.path?` at ${t.path}`:""}`),this.config.errorHandling?.throwOnError)throw new Error(`${t.type}: ${t.message}`)}getIndentation(){return this.config.formatting?.indentation||t}typeNameToFileName(e){return e=(e=(e=e.replace(/_/g,"-")).replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()).replace(/-+/g,"-")}handleComplexType(e){try{return e.oneOf?e.oneOf.map((e=>this.schemaParse(e))).join(" | "):e.allOf?e.allOf.map((e=>this.schemaParse(e))).join(" & "):e.anyOf?e.anyOf.map((e=>this.schemaParse(e))).join(" | "):e.enum?"number"===e.type||"integer"===e.type?e.enum.join(" | "):e.enum.map((e=>`'${e}'`)).join(" | "):"unknown"}catch(e){return this.handleError({type:"SCHEMA",message:"Failed to handle complex type",details:e}),"unknown"}}propertiesParse(e){if(!e)return[];const r=[];for(const n in e){const s=e[n],a=this.schemaParse(s);let i="";i=Array.isArray(a)?`${t}${t}${n}: {${a.join("\n")}};`:`${t}${t}${n}: ${a};`,r.push(i)}return r}nonArraySchemaObjectParse(e){if(!e)return"unknown";if("binary"===e.format||"string"===e.type&&"binary"===e.format)return"File";switch(e.type){case"boolean":return"boolean";case"integer":case"number":return"number";case"object":return this.propertiesParse(e.properties);case"string":return"binary"===e.format?"File":"string";default:return"unknown"}}arraySchemaObjectParse(e){if("array"!==e.type)return"";const{items:t}=e,r="$ref"in t?t:null,n=t;if(r){return`Array<${this.referenceObjectParse(r)}>`}if(n){const e=this.schemaParse(t);return Array.isArray(e)?`Array<{${e.join("\n")}}>`:`Array<${e}>`}return""}referenceObjectParse(e){try{const t=e.$ref,r=this.referenceCache.get(t);if(r)return r;let n=t;t.startsWith(s)&&(n=t.replace(s,"")),t.startsWith(a)&&(n=t.replace(a,"")),t.startsWith(i)&&(n=t.replace(i,""));const o=this.typeNameToFileName(n),p=/enum/gi.test(n)?`import('${this.config.importEnumPath}/${o}').${n}`:`import('../models/${o}').${n}`;return this.referenceCache.set(t,p),p}catch(e){return this.handleError({type:"REFERENCE",message:"Failed to parse reference object",details:e}),"unknown"}}schemaParse(e){try{if(!e)return"unknown";if("oneOf"in e||"allOf"in e||"anyOf"in e||"enum"in e)return this.handleComplexType(e);if("$ref"in e)return this.referenceObjectParse(e);const t=e,r=t.type,n=!0===t.nullable?" | null":"";if(e.format&&this.config.typeMapping?.has(e.format))return this.config.typeMapping.get(e.format)+n;if(r&&this.config.typeMapping?.has(r))return this.config.typeMapping.get(r)+n;if("array"===r&&t.items){const e=this.schemaParse(t.items);if(Array.isArray(e)){const t=this.config.formatting?.lineEnding,r=this.config.formatting?.indentation;return`Array<{${t}${e.join("\n")}${t}${r}${r}}>`}return`Array<${e}>`}if("object"===r){if(t.properties){const e=this.propertiesParse(t.properties);return e.length?e:["unknown"]}if(!0===t.additionalProperties)return"Record<string, unknown>"+n;if("object"==typeof t.additionalProperties){return`Record<string, ${this.schemaParse(t.additionalProperties)}>`+n}}return"unknown"}catch(e){return this.handleError({type:"SCHEMA",message:"Failed to parse schema",details:e}),"unknown"}}responseObjectParse(e){try{const t=e.content;if(!t)return"";const r=["application/json","text/json","text/plain","application/octet-stream","*/*"];let n;for(const e of r)if(t[e]?.schema){n=t[e].schema;break}return n?this.schemaParse(n):""}catch(e){return this.handleError({type:"RESPONSE",message:"Failed to parse response object",details:e}),""}}responseHandle(e){const t=e[200];if(!t)return;const r="content"in t?t:null,n="$ref"in t?t:null;if(null===r&&null===n&&(this.contentBody.response="type Response = unknown",this.contentBody._response="unknown"),n){const e=this.referenceObjectParse(n);this.contentBody.response=`type Response = ${e}`,this.contentBody._response=e}if(r){const e=this.responseObjectParse(r);if(Array.isArray(e)){if(1===e.length&&"unknown"===e[0])this.contentBody.response=`type Response = ${e.join("\n")};`;else{const t=this.config.formatting?.lineEnding,r=this.config.formatting?.indentation;this.contentBody.response=`interface Response {${t}${e.join("\n")}${t}${r}};`}this.contentBody._response=`${e.join("\n")}`}else this.contentBody.response=`type Response = ${e}`,this.contentBody._response=`${e}`}}requestBodyObjectParse(e){const r=Object.values(e.content),{schema:n}=r[0]||{schema:null};if(n){const e=n?.type,r="$ref"in n?n:null,s="array"===e?n:null,a=e&&this.nonArrayType.includes(e)?n:null;if(r){const e=this.referenceObjectParse(r);return`${t}type Body = ${e}`}if(s){const e=this.arraySchemaObjectParse(s);return`${t}type Body = ${e}`}if(a){const e=this.nonArraySchemaObjectParse(a);return Array.isArray(e)?0===e.length?[`${t}type Body = ${a.type};`]:[`${t}interface Body {`,...e.map((e=>e.replace(/: string;/,": File;"))),"}"]:[`${t}type Body = ${e}`]}}}requestBodyParse(e){if(!e)return"{}";const r="$ref"in e?e:null,n="content"in e?e:null;if(r){const e=this.referenceObjectParse(r);return`${t}type Body = ${e}`}return n&&"[object Object]"===String(e)&&0!==Reflect.ownKeys(e).length?this.requestBodyObjectParse(n):"{}"}parametersItemHandle(e,r,n){const s="$ref"in e?e:null,i="name"in e?e:null;if(s&&s.$ref&&s.$ref.startsWith(a)&&this.parameters){const e=s.$ref.replace(a,""),t=this.parameters[e];this.parametersItemHandle(t,r,n)}if(i){if("path"===i.in){const e=this.schemaParse(i.schema);r.push(`${t}${t}type ${i.name} = ${e};`),this.contentBody.payload._path?"string"==typeof e?this.contentBody.payload._path[i.name]=e:console.log("Unexpected v2value type:",e):"string"==typeof e?this.contentBody.payload._path={[i.name]:e}:console.log("Unexpected v2value type:",e)}if("query"===i.in){const e=this.schemaParse(i.schema);n.push(`${t}${t}${i.name}: ${e};`),this.contentBody.payload._query?"string"==typeof e?this.contentBody.payload._query[i.name]=e:console.log("Unexpected v2value type:",e):"string"==typeof e?this.contentBody.payload._query={[i.name]:e}:console.log("Unexpected v2value type:",e)}}}requestParametersParse(e){const r=[],n=[];e?.map((e=>this.parametersItemHandle(e,r,n))),0!==r.length&&(r.unshift(`${t}namespace Path {`),r.push(`${t}}`)),0!==n.length&&(n.unshift(`${t}interface Query {`),n.push(`${t}}`)),this.contentBody.payload.path=r,this.contentBody.payload.query=n}requestHandle(e){if(e.parameters&&this.requestParametersParse(e.parameters),e.requestBody){const t=this.requestBodyParse(e.requestBody);if(Array.isArray(t))this.contentBody.payload.body=t;else if(t){const e=t?.split("\n")||[];this.contentBody.payload.body=e}}}apiRequestItemHandle(e){const{payload:t,requestPath:r,_response:n,method:s,typeName:a,apiName:i}=e,{_path:o,_query:p,body:c}=t,h=c.some((e=>e.includes("File:")||e.includes(": File"))),l=e=>{const t=[];for(const r in e)t.push(`${r}: ${a}.Path.${r}`);return t.length>1?t.join(","):t.join("")},y=o?l(o):"",d=p?`params: ${a}.Query`:"",m=c.length>0?`params: ${a}.Body`:"",u={};y&&(u.apiParamsPath=y),d&&(u.apiParamsQuery=d),m&&(u.apiParamsBody=m);const f=Object.keys(u).length>=2,$=h?`,${this.config.dataLevel}`:"",g=h?", { headers: { 'Content-Type': 'multipart/form-data' } }":"";return[`export const ${i} = `,"(",o?l(o):"",""+(f?",":""),p?`params: ${a}.Query`:"",c.length>0?`params: ${a}.Body`:"",")"," => ",`${s}${n?`<${a}.Response>`:""}`,"(`"+r+"`"+(d||m?", params":"")+$+g+");"].join("")}parsePathItemObject(e,t){if(e)for(const r in e){const n=e[r];if(n){const e=r.toUpperCase(),s=t+"|"+e,{apiName:a,typeName:i,fileName:o,path:p}=this.convertEndpointString(s);this.contentBody={payload:{path:[],query:[],body:[]},response:"",_response:"",fileName:o,method:e,typeName:i,requestPath:p,apiName:a,summary:n.summary,deprecated:n.deprecated??!1},this.requestHandle(n),this.responseHandle(n.responses),this.Map.has(s)||this.Map.set(s,JSON.parse(JSON.stringify(this.contentBody)))}}}convertEndpointString(e){let t=e;e.startsWith("/")||(t="/"+e);const[r,n]=t.split("|"),s=`${r.replace("/api/","").split("/").map((e=>e.includes("{")?`$${e.slice(1,-1)}`:e.charAt(0).toUpperCase()+e.slice(1))).join("")}_${n}`;return{apiName:s.charAt(0).toLowerCase()+s.slice(1),fileName:(r.slice(1).replace(/\//g,"-").replace("api-","")+"-"+n).toLowerCase(),typeName:s.charAt(0).toUpperCase()+s.slice(1),path:r.replace(/(\/api)|(api)/g,"").replace(/\{\w+\}/g,(e=>`$${e}`))}}parseData(){return new Promise(((e,t)=>{try{for(const e in this.pathsObject){const t=this.pathsObject[e];t&&this.parsePathItemObject(t,e)}e(this.Map)}catch(e){this.handleError({type:"SCHEMA",message:"Failed to parse schema",details:e}),t(e)}}))}async writeFile(){const r=[],n=[],s=this.config.saveTypeFolderPath,a=[],i=(r,i)=>new Promise(((o,p)=>{try{const{payload:c,response:h,fileName:l,summary:y,typeName:d,deprecated:m}=i,[,u]=r.split("|");!a.includes(u)&&a.push(u);const f=[`declare namespace ${d} {`,...c.path,...c.query,...c.body,`${t}${h}`,"}"];y&&n.push(["/**","\n",m?` * @deprecated ${y}`:` * ${y}`,"\n"," */"].join(""));const $=this.apiRequestItemHandle(i);n.push($,"\n"),e.writeFileRecursive(`${s}/connectors/${l}.d.ts`,f.join("\n")).then((()=>o(1))).catch((e=>{this.handleError({type:"FILE_WRITE",message:"Failed to write type definition file",path:l,details:e}),p(e)}))}catch(e){this.handleError({type:"PATH",message:"Failed to process path item",path:r,details:e}),p(e)}}));for(const[e,t]of this.Map)r.push(i(e,t));try{await Promise.all(r),n.unshift(`import { ${a.join(", ")} } from '${this.config.requestMethodsImportPath||"./api"}';`,"\n"),await e.clearDir(this.config.saveApiListFolderPath+"/index.ts"),await e.writeFileRecursive(this.config.saveApiListFolderPath+"/index.ts",n.join("\n")),this.Map=new Map,this.errors.length>0&&e.log.warning(`Completed with ${this.errors.length} errors`)}catch(e){throw this.handleError({type:"FILE_WRITE",message:"Failed to write API list file",details:e}),e}}async handle(){try{await this.parseData(),await this.writeFile(),e.log.success("Path parse & write done!")}catch(e){if(this.handleError({type:"SCHEMA",message:"Failed to handle schema",details:e}),this.config.errorHandling?.throwOnError)throw e}}}exports.PathParse=o,exports.default=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/index.js");const t="\t";var r;!function(e){e.GET="get",e.PUT="put",e.POST="post",e.DELETE="delete",e.OPTIONS="options",e.HEAD="head",e.PATCH="patch",e.TRACE="trace"}(r||(r={}));const n={typeMapping:new Map([["integer","number"],["string","string"],["boolean","boolean"],["binary","File"]]),errorHandling:{throwOnError:!1,logErrors:!0}},s="#/components/schemas/",a="#/components/parameters/",o="#/definitions/",i=["application/json","text/json","text/plain","application/x-www-form-urlencoded","application/xml","text/xml","*/*","application/octet-stream","multipart/form-data"],p=["application/octet-stream","multipart/form-data"];class c{pathsObject={};nonArrayType=["boolean","object","number","string","integer"];pathKey="";contentBody={payload:{path:[],query:[],body:[]},response:"",_response:"",fileName:"",method:"",requestPath:"",summary:"",apiName:"",typeName:"",deprecated:!1,contentType:"application/json"};Map=new Map;config;errors=[];referenceCache=new Map;parameters={};templates={exportConst:e=>`export const ${e}`,typeDefinition:(e,t)=>`type ${e} = ${t}`,interfaceDefinition:e=>`interface ${e}`};constructor(e,t,r){this.pathsObject=e,this.parameters=t??{},this.config={...n,...r,typeMapping:new Map([...n.typeMapping||[],...r.typeMapping||[]])}}handleError(t){if(this.errors.push(t),this.config.errorHandling?.logErrors&&e.log.error(`${t.type}: ${t.message}${t.path?` at ${t.path}`:""}`),this.config.errorHandling?.throwOnError)throw new Error(`${t.type}: ${t.message}`)}getIndentation(){return this.config.formatting?.indentation||t}typeNameToFileName(e){return e=(e=(e=e.replace(/_/g,"-")).replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()).replace(/-+/g,"-")}handleComplexType(e){try{return e.oneOf?e.oneOf.map((e=>this.schemaParse(e))).join(" | "):e.allOf?e.allOf.map((e=>this.schemaParse(e))).join(" & "):e.anyOf?e.anyOf.map((e=>this.schemaParse(e))).join(" | "):e.enum?"number"===e.type||"integer"===e.type?e.enum.join(" | "):e.enum.map((e=>`'${e}'`)).join(" | "):"unknown"}catch(e){return this.handleError({type:"SCHEMA",message:"Failed to handle complex type",details:e}),"unknown"}}propertiesParse(e){if(!e)return[];const r=[];for(const n in e){const s=e[n],a=this.schemaParse(s);let o="";o=Array.isArray(a)?`${t}${t}${n}: {${a.join("\n")}};`:`${t}${t}${n}: ${a};`,r.push(o)}return r}nonArraySchemaObjectParse(e){if(!e)return"unknown";if("binary"===e.format||"string"===e.type&&"binary"===e.format)return"File";switch(e.type){case"boolean":return"boolean";case"integer":case"number":return"number";case"object":return this.propertiesParse(e.properties);case"string":return"binary"===e.format?"File":"string";default:return"unknown"}}arraySchemaObjectParse(e){if("array"!==e.type)return"";const{items:t}=e,r="$ref"in t?t:null,n=t;if(r){return`Array<${this.referenceObjectParse(r)}>`}if(n){const e=this.schemaParse(t);return Array.isArray(e)?`Array<{${e.join("\n")}}>`:`Array<${e}>`}return""}referenceObjectParse(e){try{const t=e.$ref,r=this.referenceCache.get(t);if(r)return r;let n=t;t.startsWith(s)&&(n=t.replace(s,"")),t.startsWith(a)&&(n=t.replace(a,"")),t.startsWith(o)&&(n=t.replace(o,""));const i=this.typeNameToFileName(n),p=/enum/gi.test(n)?`import('${this.config.importEnumPath}/${i}').${n}`:`import('../models/${i}').${n}`;return this.referenceCache.set(t,p),p}catch(e){return this.handleError({type:"REFERENCE",message:"Failed to parse reference object",details:e}),"unknown"}}schemaParse(e){try{if(!e)return"unknown";if("oneOf"in e||"allOf"in e||"anyOf"in e||"enum"in e)return this.handleComplexType(e);if("$ref"in e)return this.referenceObjectParse(e);const t=e,r=t.type,n=!0===t.nullable?" | null":"";if(e.format&&this.config.typeMapping?.has(e.format))return this.config.typeMapping.get(e.format)+n;if(r&&this.config.typeMapping?.has(r))return this.config.typeMapping.get(r)+n;if("array"===r&&t.items){const e=this.schemaParse(t.items);if(Array.isArray(e)){const t=this.config.formatting?.lineEnding,r=this.config.formatting?.indentation;return`Array<{${t}${e.join("\n")}${t}${r}${r}}>`}return`Array<${e}>`}if("object"===r){if(t.properties){const e=this.propertiesParse(t.properties);return e.length?e:["unknown"]}if(!0===t.additionalProperties)return"Record<string, unknown>"+n;if("object"==typeof t.additionalProperties){return`Record<string, ${this.schemaParse(t.additionalProperties)}>`+n}}return"unknown"}catch(e){return this.handleError({type:"SCHEMA",message:"Failed to parse schema",details:e}),"unknown"}}responseObjectParse(e){try{const t=e.content;if(!t)return"";let r;for(const e of i)if(t[e]?.schema){r=t[e].schema;break}return r?this.schemaParse(r):""}catch(e){return this.handleError({type:"RESPONSE",message:"Failed to parse response object",details:e}),""}}responseHandle(e){const t=e[200];if(!t)return;const r="content"in t?t:null,n="$ref"in t?t:null;if(null===r&&null===n&&(this.contentBody.response="type Response = unknown",this.contentBody._response="unknown"),n){const e=this.referenceObjectParse(n);this.contentBody.response=`type Response = ${e}`,this.contentBody._response=e}if(r){const e=this.responseObjectParse(r);if(Array.isArray(e)){if(1===e.length&&"unknown"===e[0])this.contentBody.response=`type Response = ${e.join("\n")};`;else{const t=this.config.formatting?.lineEnding,r=this.config.formatting?.indentation;this.contentBody.response=`interface Response {${t}${e.join("\n")}${t}${r}};`}this.contentBody._response=`${e.join("\n")}`}else this.contentBody.response=`type Response = ${e}`,this.contentBody._response=`${e}`}}requestBodyObjectParse(e){const r=Object.values(e.content),{schema:n}=r[0]||{schema:null};if(n){const e=n?.type,r="$ref"in n?n:null,s="array"===e?n:null,a=e&&this.nonArrayType.includes(e)?n:null;if(r){const e=this.referenceObjectParse(r);return`${t}type Body = ${e}`}if(s){const e=this.arraySchemaObjectParse(s);return`${t}type Body = ${e}`}if(a){const e=this.nonArraySchemaObjectParse(a);return Array.isArray(e)?0===e.length?[`${t}type Body = ${a.type};`]:[`${t}interface Body {`,...e.map((e=>e.replace(/: string;/,": File;"))),"}"]:[`${t}type Body = ${e}`]}}}requestBodyParse(e){if(!e)return"{}";const r="$ref"in e?e:null,n="content"in e?e:null;if(r){const e=this.referenceObjectParse(r);return`${t}type Body = ${e}`}return n&&"[object Object]"===String(e)&&0!==Reflect.ownKeys(e).length?this.requestBodyObjectParse(n):"{}"}parametersItemHandle(e,r,n){const s="$ref"in e?e:null,o="name"in e?e:null;if(s&&s.$ref&&s.$ref.startsWith(a)&&this.parameters){const e=s.$ref.replace(a,""),t=this.parameters[e];this.parametersItemHandle(t,r,n)}if(o){if("path"===o.in){const e=this.schemaParse(o.schema);r.push(`${t}${t}type ${o.name} = ${e};`),this.contentBody.payload._path?"string"==typeof e?this.contentBody.payload._path[o.name]=e:console.log("Unexpected v2value type:",e):"string"==typeof e?this.contentBody.payload._path={[o.name]:e}:console.log("Unexpected v2value type:",e)}if("query"===o.in){const e=this.schemaParse(o.schema);n.push(`${t}${t}${o.name}: ${e};`),this.contentBody.payload._query?"string"==typeof e?this.contentBody.payload._query[o.name]=e:console.log("Unexpected v2value type:",e):"string"==typeof e?this.contentBody.payload._query={[o.name]:e}:console.log("Unexpected v2value type:",e)}}}requestParametersParse(e){const r=[],n=[];e?.map((e=>this.parametersItemHandle(e,r,n))),0!==r.length&&(r.unshift(`${t}namespace Path {`),r.push(`${t}}`)),0!==n.length&&(n.unshift(`${t}interface Query {`),n.push(`${t}}`)),this.contentBody.payload.path=r,this.contentBody.payload.query=n}requestHandle(e){if(e.parameters&&this.requestParametersParse(e.parameters),e.requestBody){const t=this.requestBodyParse(e.requestBody);if(Array.isArray(t))this.contentBody.payload.body=t;else if(t){const e=t?.split("\n")||[];this.contentBody.payload.body=e}}}apiRequestItemHandle(e){const{payload:t,requestPath:r,_response:n,method:s,typeName:a,apiName:o,contentType:i}=e,{_path:c,_query:h,body:l}=t,y=(()=>{const e=[];for(const t in c)e.push(`${t}: ${a}.Path.${t}`);const t=e.join(e.length>1?",":"");return""===t?t:t+","})(),d=(()=>{const e=h?`query: ${a}.Query,`:"";return""===e?"":`${e}`})(),u=(()=>{const e=l.length>0?`body: ${a}.Body,`:"";return""===e?"":`${e}`})(),m=(y+d+u).replace(/,$/,"");return[`export const ${o} = `,"(",m,""===m?"...rest: IRequestFnParams":", ...rest: IRequestFnParams",")"," => ",s,""+(n?`<${a}.Response>`:""),"(","`"+r+"`,",(()=>{const e=p.includes(i)?`{ headers: { 'Content-Type': '${i}' } }`:void 0;return["{",""===d?"":"query,",""===u?"":"body,",e?`config: ${e},`:"",`datalevel: '${this.config.dataLevel}'`,",...rest","}"].join("")})(),");"].join("")}parsePathItemObject(e,t){if(e)for(const r in e){const n=e[r];if(n){const e=r.toUpperCase(),s=t+"|"+e,{apiName:a,typeName:o,fileName:p,path:c}=this.convertEndpointString(s),h=n.requestBody&&"content"in n.requestBody&&n.requestBody.content,l="object"==typeof h?Object.keys(h)[0]:"application/json";this.contentBody={payload:{path:[],query:[],body:[]},response:"",_response:"",fileName:p,method:e,typeName:o,requestPath:c,apiName:a,summary:n.summary,deprecated:n.deprecated??!1,contentType:i.includes(l)?l:"application/json"},this.requestHandle(n),this.responseHandle(n.responses),this.Map.has(s)||this.Map.set(s,JSON.parse(JSON.stringify(this.contentBody)))}}}convertEndpointString(e){let t=e;e.startsWith("/")||(t="/"+e);const[r,n]=t.split("|"),s=`${r.replace("/api/","").split("/").map((e=>e.includes("{")?`$${e.slice(1,-1)}`:e.charAt(0).toUpperCase()+e.slice(1))).join("")}_${n}`;return{apiName:s.charAt(0).toLowerCase()+s.slice(1),fileName:(r.slice(1).replace(/\//g,"-").replace("api-","")+"-"+n).toLowerCase(),typeName:s.charAt(0).toUpperCase()+s.slice(1),path:r.replace(/(\/api)|(api)/g,"").replace(/\{\w+\}/g,(e=>`$${e}`))}}parseData(){return new Promise(((e,t)=>{try{for(const e in this.pathsObject){const t=this.pathsObject[e];t&&this.parsePathItemObject(t,e)}e(this.Map)}catch(e){this.handleError({type:"SCHEMA",message:"Failed to parse schema",details:e}),t(e)}}))}async writeFile(){const r=[],n=[],s=this.config.saveTypeFolderPath,a=[],o=(r,o)=>new Promise(((i,p)=>{try{const{payload:c,response:h,fileName:l,summary:y,typeName:d,deprecated:u}=o,[,m]=r.split("|");!a.includes(m)&&a.push(m);const f=[`declare namespace ${d} {`,...c.path,...c.query,...c.body,`${t}${h}`,"}"];y&&n.push(["/**","\n",u?` * @deprecated ${y}`:` * ${y}`,"\n"," */"].join(""));const $=this.apiRequestItemHandle(o);n.push($,"\n"),e.writeFileRecursive(`${s}/connectors/${l}.d.ts`,f.join("\n")).then((()=>i(1))).catch((e=>{this.handleError({type:"FILE_WRITE",message:"Failed to write type definition file",path:l,details:e}),p(e)}))}catch(e){this.handleError({type:"PATH",message:"Failed to process path item",path:r,details:e}),p(e)}}));for(const[e,t]of this.Map)r.push(o(e,t));try{await Promise.all(r),n.unshift(`import { ${a.join(", ")} } from '${this.config.requestMethodsImportPath||"./api"}';`,"\n"),await e.clearDir(this.config.saveApiListFolderPath+"/index.ts"),await e.writeFileRecursive(this.config.saveApiListFolderPath+"/index.ts",n.join("\n")),this.Map=new Map,this.errors.length>0&&e.log.warning(`Completed with ${this.errors.length} errors`)}catch(e){throw this.handleError({type:"FILE_WRITE",message:"Failed to write API list file",details:e}),e}}async handle(){try{await this.parseData(),await this.writeFile(),e.log.success("Path parse & write done!")}catch(e){if(this.handleError({type:"SCHEMA",message:"Failed to handle schema",details:e}),this.config.errorHandling?.throwOnError)throw e}}}exports.PathParse=c,exports.default=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("../utils/index.js"),s=require("./core/components.js"),a=require("./core/get-data.js"),r=require("./core/path.js"),o=require("shelljs"),i=require("chalk"),n=require("path");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=c(e),p=c(i),u=c(n);let h;const d="development"===process.env.NODE_ENV,f={saveTypeFolderPath:d?"apps/types":"src/api/types",saveApiListFolderPath:d?"apps/types":"src/api",saveEnumFolderPath:d?"apps/types/enums":"src/enums",importEnumPath:"../../../enums",requestMethodsImportPath:"./fetch",dataLevel:"serve",swaggerJsonUrl:"www.example.swagger.json.url",headers:{},formatting:{indentation:"\t",lineEnding:"\n"}};class w{schemas={};paths={};async handle(e){try{let t;if(t="development"===process.env.NODE_ENV?(await Promise.resolve().then((function(){return require("../../data/open-api.json.js")}))).default:await a.getSwaggerJson(e),!t)throw new Error("无法获取 Swagger 数据");this.schemas=t.components?.schemas||{},this.paths=t.paths||{};const o=new s.default(this.schemas,e),i=new r.PathParse(this.paths,t.components?.parameters,e);return await Promise.all([o.handle(),i.handle()]),!0}catch(e){if(e instanceof Error)throw new Error(`处理 Swagger 数据失败: ${e.message}`);throw new Error("处理 Swagger 数据失败: 未知错误")}}async formatGeneratedFiles(e){const s=`npx prettier --write "${e.saveTypeFolderPath}/**/*.{ts,d.ts}"`;try{await l.default.promises.access(e.saveTypeFolderPath);const{stderr:a}=await new Promise(((e,t)=>{o.exec(s,((s,a,r)=>{s?t(s):e({stdout:a,stderr:r})}))}));if(a)throw new Error(a);t.log.success("文件格式化成功")}catch(e){console.log(""),t.log.error("格式化失败,请手动执行以下命令:"),console.log("$",p.default.yellow(s)),console.log("")}}async copyAjaxConfigFiles(e){try{const s=["config.ts","error-message.ts","fetch.ts"],a=u.default.join(__dirname,"..","..","ajax-config"),r=e;for(const e of s){const s=u.default.join(a,e),o=u.default.join(r,e);try{await l.default.promises.access(s);try{await l.default.promises.access(o),t.log.info(`${e} 已存在,跳过生成.`)}catch{await l.default.promises.copyFile(s,o),t.log.success(`${e} create done.`)}}catch(e){t.log.error(`源文件 ${s} 不存在`);continue}}}catch(e){return e}}async initialize(){const e=process.cwd()+"/an.config.json";try{const s=await this.getConfig(e);if(!h)return;await l.default.promises.mkdir(s.saveApiListFolderPath,{recursive:!0}),await this.copyAjaxConfigFiles(s.saveApiListFolderPath),await t.clearDir(s.saveTypeFolderPath),await t.clearDir(s.saveEnumFolderPath),await this.handle(s),await this.formatGeneratedFiles(s)}catch(e){const s=e instanceof Error?e.message:"未知错误";t.log.error(`初始化失败: ${s}`)}}async getConfig(e){try{const t=await l.default.promises.readFile(e,"utf8");return h=!0,JSON.parse(t)}catch(s){return h=!1,t.log.warning("配置文件不存在,将自动创建配置文件。"),await t.writeFileRecursive(e,JSON.stringify(f,null,2)),t.log.success("请查看项目根目录下的 an.config.json 文件"),f}}}if("development"===process.env.NODE_ENV){(new w).initialize()}exports.Main=w;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("../utils/index.js"),s=require("./core/components.js"),a=require("./core/get-data.js"),r=require("./core/path.js"),o=require("shelljs"),i=require("chalk"),n=require("path");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=c(e),p=c(i),u=c(n);let d;const h="development"===process.env.NODE_ENV,f={saveTypeFolderPath:h?"apps/types":"src/api/types",saveApiListFolderPath:h?"apps/types":"src/api",saveEnumFolderPath:h?"apps/types/enums":"src/enums",importEnumPath:"../../../enums",requestMethodsImportPath:"./fetch",dataLevel:"serve",swaggerJsonUrl:"www.example.swagger.json.url",headers:{},formatting:{indentation:"\t",lineEnding:"\n"}};class w{schemas={};paths={};async handle(e){try{let t;if(t="development"===process.env.NODE_ENV?(await Promise.resolve().then((function(){return require("../../data/openapi.json.js")}))).default:await a.getSwaggerJson(e),!t)throw new Error("无法获取 Swagger 数据");this.schemas=t.components?.schemas||{},this.paths=t.paths||{};const o=new s.default(this.schemas,e),i=new r.PathParse(this.paths,t.components?.parameters,e);return await Promise.all([o.handle(),i.handle()]),!0}catch(e){if(e instanceof Error)throw new Error(`处理 Swagger 数据失败: ${e.message}`);throw new Error("处理 Swagger 数据失败: 未知错误")}}async formatGeneratedFiles(e){const s=`npx prettier --write "${e.saveTypeFolderPath}/**/*.{ts,d.ts}"`;try{await l.default.promises.access(e.saveTypeFolderPath);const{stderr:a}=await new Promise(((e,t)=>{o.exec(s,((s,a,r)=>{s?t(s):e({stdout:a,stderr:r})}))}));if(a)throw new Error(a);t.log.success("文件格式化成功")}catch(e){console.log(""),t.log.error("格式化失败,请手动执行以下命令:"),console.log("$",p.default.yellow(s)),console.log("")}}async copyAjaxConfigFiles(e){try{const s=["config.ts","error-message.ts","fetch.ts","api-type.d.ts"],a=u.default.join(__dirname,"..","..","ajax-config"),r=e;for(const e of s){const s=u.default.join(a,e),o=u.default.join(r,e);try{await l.default.promises.access(s);try{await l.default.promises.access(o),t.log.info(`${e} 已存在,跳过生成.`)}catch{await l.default.promises.copyFile(s,o),t.log.success(`${e} create done.`)}}catch(e){t.log.error(`源文件 ${s} 不存在`);continue}}}catch(e){return e}}async initialize(){const e=process.cwd()+"/an.config.json";try{const s=await this.getConfig(e);if(!d)return;await l.default.promises.mkdir(s.saveApiListFolderPath,{recursive:!0}),await this.copyAjaxConfigFiles(s.saveApiListFolderPath),await t.clearDir(s.saveTypeFolderPath),await t.clearDir(s.saveEnumFolderPath),await this.handle(s),await this.formatGeneratedFiles(s)}catch(e){const s=e instanceof Error?e.message:"未知错误";t.log.error(`初始化失败: ${s}`)}}async getConfig(e){try{const t=await l.default.promises.readFile(e,"utf8");return d=!0,JSON.parse(t)}catch(s){return d=!1,t.log.warning("配置文件不存在,将自动创建配置文件。"),await t.writeFileRecursive(e,JSON.stringify(f,null,2)),t.log.success("请查看项目根目录下的 an.config.json 文件"),f}}}if("development"===process.env.NODE_ENV){(new w).initialize()}exports.Main=w;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anl",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "FE command line tool",
5
5
  "main": "bin/an-cli.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="3.0.1",t={title:"Swagger Generator",description:"This is an online swagger codegen server. You can find out more at https://github.com/swagger-api/swagger-codegen or on [irc.freenode.net, #swagger](http://swagger.io/irc/).",license:{name:"Apache 2.0",url:"http://www.apache.org/licenses/LICENSE-2.0.html"},version:"3.0.68"},r=[{url:"/api"}],n=[{name:"clients"},{name:"servers"},{name:"documentation"},{name:"config"}],o={"/generate":{get:{tags:["clients","servers","documentation","config"],summary:"Generates and download code. GenerationRequest input provided as JSON available at URL specified in parameter codegenOptionsURL.",operationId:"generateFromURL",parameters:[{name:"codegenOptionsURL",in:"query",required:!0,schema:{type:"string"}}],responses:{200:{description:"successful operation",content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"},post:{tags:["clients","servers","documentation","config"],summary:"Generates and download code. GenerationRequest input provided as request body.",operationId:"generate",requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/GenerationRequest"}}}},responses:{200:{description:"successful operation",content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/clients":{get:{tags:["clients","documentation"],summary:"Deprecated, use '/{type}/{version}' instead. List generator languages of type 'client' or 'documentation' for given codegen version (defaults to V3)",operationId:"clientLanguages",parameters:[{$ref:"#/components/parameters/version"},{name:"clientOnly",in:"query",description:"flag to only return languages of type `client`",schema:{type:"boolean",default:!1}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{type:"string"}}}}}},deprecated:!0,"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/servers":{get:{tags:["servers"],summary:"Deprecated, use '/{type}/{version}' instead. List generator languages of type 'server' for given codegen version (defaults to V3)",operationId:"serverLanguages",parameters:[{$ref:"#/components/parameters/version"}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{type:"string"}}}}}},deprecated:!0,"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/documentation":{get:{tags:["documentation"],summary:"Deprecated, use '/{type}/{version}' instead. List generator languages of type 'documentation' for given codegen version (defaults to V3)",operationId:"documentationLanguages",parameters:[{$ref:"#/components/parameters/version"}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{type:"string"}}}}}},deprecated:!0,"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/{type}/{version}":{get:{tags:["clients","servers","documentation","config"],summary:"List generator languages of the given type and version",operationId:"languages",parameters:[{$ref:"#/components/parameters/type"},{name:"version",in:"path",description:"generator version used by codegen engine",required:!0,schema:{type:"string",enum:["V2","V3"]}}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{type:"string"}}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/types":{get:{tags:["clients","servers","documentation","config"],summary:"List generator languages of version defined in 'version parameter (defaults to V3) and type included in 'types' parameter; all languages",operationId:"languagesMulti",parameters:[{$ref:"#/components/parameters/types"},{$ref:"#/components/parameters/version"}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"array",items:{type:"string"}}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/options":{get:{tags:["clients","servers","documentation","config"],summary:"Returns options for a given language and version (defaults to V3)",operationId:"listOptions",parameters:[{name:"language",in:"query",description:"language",schema:{type:"string"}},{$ref:"#/components/parameters/version"}],responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"object",additionalProperties:{$ref:"#/components/schemas/CliOption"}}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/model":{post:{tags:["clients","servers","documentation","config"],summary:'Generates the intermediate model ("bundle") and returns it as a JSON. body.',operationId:"generateBundle",requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/GenerationRequest"}}}},responses:{200:{description:"successful operation",content:{"application/json":{schema:{type:"object"}}}}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}},"/render":{post:{tags:["documentation"],summary:"render a template using the provided data",operationId:"renderTemplate",requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/RenderRequest"}}}},responses:{200:{description:"successful operation"}},"x-swagger-router-controller":"io.swagger.v3.generator.online.GeneratorController"}}},i={schemas:{GenerationRequest:{required:["lang"],type:"object",properties:{lang:{title:"language",type:"string",description:"language to generate (required)",example:"java"},spec:{type:"object",description:"spec in json format. . Alternative to `specURL`"},specURL:{type:"string",description:"URL of the spec in json format. Alternative to `spec`"},type:{type:"string",description:"type of the spec",enum:["CLIENT","SERVER","DOCUMENTATION","CONFIG"]},codegenVersion:{type:"string",description:"codegen version to use",enum:["V2","V3"]},options:{$ref:"#/components/schemas/Options"}},"x-swagger-router-model":"io.swagger.codegen.v3.service.GenerationRequest"},AuthorizationValue:{title:"authorization",type:"object",properties:{value:{type:"string",description:"Authorization value"},keyName:{type:"string",description:"Authorization key"},type:{type:"string",description:"Authorization type",enum:["query","header"]}},description:"adds authorization headers when fetching the open api definitions remotely. Pass in an authorizationValue object","x-swagger-router-model":"io.swagger.v3.parser.core.models.AuthorizationValue"},Options:{type:"object",properties:{auth:{title:"authorization",type:"string",description:"adds authorization headers when fetching the open api definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values"},authorizationValue:{$ref:"#/components/schemas/AuthorizationValue"},apiPackage:{title:"api package",type:"string",description:"package for generated api classes"},templateVersion:{title:"Template Version",type:"string",description:"template version for generation"},modelPackage:{title:"model package",type:"string",description:"package for generated models"},modelNamePrefix:{title:"model name prefix",type:"string",description:"Prefix that will be prepended to all model names. Default is the empty string."},modelNameSuffix:{title:"model name suffix",type:"string",description:"PrefixSuffix that will be appended to all model names. Default is the empty string."},systemProperties:{title:"System Properties",type:"object",additionalProperties:{type:"string"},description:"sets specified system properties in key/value format"},instantiationTypes:{title:"instantiation types",type:"object",additionalProperties:{type:"string"},description:"sets instantiation type mappings in key/value format. For example (in Java): array=ArrayList,map=HashMap. In other words array types will get instantiated as ArrayList in generated code."},typeMappings:{title:"type mappings",type:"object",additionalProperties:{type:"string"},description:"sets mappings between swagger spec types and generated code types in key/value format. For example: array=List,map=Map,string=String."},additionalProperties:{title:"additional properties",type:"object",additionalProperties:{type:"object"},description:"sets additional properties that can be referenced by the mustache templates in key/value format."},languageSpecificPrimitives:{title:"language specific primitives",type:"array",description:"specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double. You can also have multiple occurrences of this option.",items:{type:"string"}},importMappings:{title:"import mappings",type:"object",additionalProperties:{type:"string"},description:"specifies mappings between a given class and the import that should be used for that class in key/value format."},invokerPackage:{title:"invoker package",type:"string",description:"root package for generated code"},groupId:{title:"group id",type:"string",description:"groupId in generated pom.xml"},artifactId:{title:"artifact id",type:"string",description:"artifactId in generated pom.xml"},artifactVersion:{title:"artifact version",type:"string",description:"artifact version generated in pom.xml"},library:{title:"library",type:"string",description:"library template (sub-template)"},gitUserId:{title:"git user id",type:"string",description:"Git user ID, e.g. swagger-api."},gitRepoId:{title:"git repo id",type:"string",description:"Git repo ID, e.g. swagger-codegen."},releaseNote:{title:"release note",type:"string",description:"Release note, default to 'Minor update'."},httpUserAgent:{title:"http user agent",type:"string",description:"HTTP user agent, e.g. codegen_csharp_api_client, default to 'Swagger-Codegen/{packageVersion}}/{language}'"},reservedWordsMappings:{title:"reserved words mappings",type:"object",additionalProperties:{type:"string"},description:"pecifies how a reserved name should be escaped to. Otherwise, the default _<name> is used. For example id=identifier."},ignoreFileOverride:{title:"ignore file override location",type:"string",description:"Specifies an override location for the .swagger-codegen-ignore file. Most useful on initial generation."},removeOperationIdPrefix:{title:"remove prefix of the operationId",type:"boolean",description:"Remove prefix of operationId, e.g. config_getId => getId"},skipOverride:{type:"boolean"}},"x-swagger-router-model":"io.swagger.codegen.v3.service.Options"},CliOption:{type:"object",properties:{optionName:{type:"string"},description:{type:"string"},type:{type:"string",description:"Data type is based on the types supported by the JSON-Schema"},enum:{type:"object",additionalProperties:{type:"string"}},default:{type:"string"}}},RenderRequest:{required:["context","template"],type:"object",properties:{template:{title:"template",type:"string",description:"template as string",example:"{{!mustache}}"},context:{title:"context",type:"string",description:"context as string",example:"{}"}},"x-swagger-router-model":"io.swagger.codegen.v3.service.RenderRequest"},RenderResponse:{required:["value"],type:"object",properties:{value:{type:"string"}},"x-swagger-router-model":"io.swagger.codegen.v3.service.RenderResponse"}},parameters:{version:{name:"version",in:"query",description:"generator version used by codegen engine",schema:{type:"string",enum:["V2","V3"]}},type:{name:"type",in:"path",description:"generator type",required:!0,schema:{type:"string",enum:["client","server","documentation","config"]}},types:{name:"types",in:"query",description:"comma-separated list of generator types",required:!0,style:"form",explode:!1,schema:{type:"array",items:{type:"string",enum:["client","server","documentation","config"]}}}}},s={openapi:e,info:t,servers:r,tags:n,paths:o,components:i};exports.components=i,exports.default=s,exports.info=t,exports.openapi=e,exports.paths=o,exports.servers=r,exports.tags=n;