swaggie 1.3.0-test.2 → 1.3.0
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/dist/gen/genOperations.js +10 -6
- package/dist/gen/genTypes.js +6 -1
- package/dist/gen/refsHelper.js +1 -1
- package/dist/utils/utils.js +4 -0
- package/package.json +1 -1
- package/templates/axios/operation.ejs +2 -0
- package/templates/fetch/operation.ejs +2 -0
- package/templates/ng1/operation.ejs +2 -0
- package/templates/ng2/operation.ejs +4 -2
- package/templates/swr-axios/operation.ejs +2 -0
- package/templates/swr-axios/swrOperation.ejs +4 -2
- package/templates/tsq-xior/operation.ejs +2 -0
- package/templates/tsq-xior/queryOperation.ejs +3 -1
- package/templates/xior/operation.ejs +2 -0
|
@@ -121,8 +121,10 @@ function prepareClient(
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
const docs = getOperationDocs(op);
|
|
124
125
|
return {
|
|
125
|
-
docs
|
|
126
|
+
docs,
|
|
127
|
+
hasJSDocs: docs && docs.length > 0 && params.length > 0,
|
|
126
128
|
returnType,
|
|
127
129
|
responseContentType,
|
|
128
130
|
method: op.method.toUpperCase(),
|
|
@@ -143,11 +145,13 @@ function prepareClient(
|
|
|
143
145
|
*/
|
|
144
146
|
function getOperationDocs(op) {
|
|
145
147
|
const result = [];
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
const summary = _optionalChain([op, 'access', _3 => _3.summary, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
|
|
149
|
+
const description = _optionalChain([op, 'access', _6 => _6.description, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]);
|
|
150
|
+
if (summary) {
|
|
151
|
+
result.push(summary);
|
|
148
152
|
}
|
|
149
|
-
if (
|
|
150
|
-
result.push(
|
|
153
|
+
if (description && description !== summary) {
|
|
154
|
+
result.push(description);
|
|
151
155
|
}
|
|
152
156
|
if (op.deprecated) {
|
|
153
157
|
result.push('@deprecated');
|
|
@@ -256,7 +260,7 @@ function prepareUrl(path) {
|
|
|
256
260
|
original: p,
|
|
257
261
|
}));
|
|
258
262
|
|
|
259
|
-
if (_optionalChain([options, 'access',
|
|
263
|
+
if (_optionalChain([options, 'access', _9 => _9.modifiers, 'optionalAccess', _10 => _10.parameters])) {
|
|
260
264
|
for (const [name, modifier] of Object.entries(options.modifiers.parameters)) {
|
|
261
265
|
const paramIndex = result.findIndex(
|
|
262
266
|
(p) => p.original.in !== 'path' && (p.originalName === name || p.name === name)
|
package/dist/gen/genTypes.js
CHANGED
|
@@ -46,11 +46,16 @@ function renderSchema(
|
|
|
46
46
|
options
|
|
47
47
|
) {
|
|
48
48
|
const safeName = _swagger.getSafeIdentifier.call(void 0, name);
|
|
49
|
+
if (!safeName) {
|
|
50
|
+
console.warn(`Skipping schema ${name} because it is not a valid identifier`);
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
49
53
|
|
|
50
54
|
// This is an interesting case, because it is allowed but not likely to be used
|
|
51
55
|
// as it is just a reference to another schema object
|
|
52
56
|
if ('$ref' in schema) {
|
|
53
|
-
|
|
57
|
+
const refName = _swagger.getSafeIdentifier.call(void 0, schema.$ref.split('/').pop());
|
|
58
|
+
return `export type ${safeName} = ${refName || 'unknown'};`;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
const result = [];
|
package/dist/gen/refsHelper.js
CHANGED
|
@@ -55,7 +55,7 @@ function findDirectRefs(obj, options, refs) {
|
|
|
55
55
|
|
|
56
56
|
// If the object is deprecated and we want to skip deprecated objects,
|
|
57
57
|
// we won't process it and anything below it
|
|
58
|
-
if (options.skipDeprecated &&
|
|
58
|
+
if (options.skipDeprecated && obj.deprecated) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
package/dist/utils/utils.js
CHANGED
|
@@ -61,6 +61,10 @@ const reservedKeywords = new Set([
|
|
|
61
61
|
* Escaping is done by adding an underscore prefix.
|
|
62
62
|
*/
|
|
63
63
|
function escapeIdentifier(name) {
|
|
64
|
+
if (!name) {
|
|
65
|
+
return name;
|
|
66
|
+
}
|
|
67
|
+
|
|
64
68
|
if (reservedKeywords.has(name) || /^[0-9]/.test(name)) {
|
|
65
69
|
return `_${name}`;
|
|
66
70
|
}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
* @return Success
|
|
11
12
|
*/
|
|
13
|
+
<% } %>
|
|
12
14
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
13
15
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
14
16
|
<% }); %>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
2
|
+
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
|
-
|
|
4
|
+
* <%~ it.docs.join('\n * ') %>
|
|
4
5
|
<% } %>
|
|
5
6
|
|
|
6
7
|
<% it.parameters.forEach((parameter) => { %>
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
* @return Success
|
|
11
12
|
*/
|
|
13
|
+
<% } %>
|
|
12
14
|
<%= it.name %>(
|
|
13
15
|
<% it.parameters.forEach((parameter) => { %>
|
|
14
16
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
2
|
+
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
|
-
|
|
4
|
+
* <%~ it.docs.join('\n * ') %>
|
|
4
5
|
<% } %>
|
|
5
6
|
|
|
6
7
|
<% it.parameters.forEach((parameter) => { %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
export function <%= it.swrOpName %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
|
-
|
|
4
|
+
* <%~ it.docs.join('\n * ') %>
|
|
4
5
|
<% } %>
|
|
5
6
|
|
|
6
7
|
<% it.parameters.forEach((parameter) => { %>
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
* @param $config (optional) Additional configuration for TanStack Query
|
|
11
12
|
* @param $httpConfig (optional) Additional configuration for xior request (actually executes the request)
|
|
12
13
|
*/
|
|
14
|
+
<% } %>
|
|
13
15
|
export function <%= it.rqOpName %><TData = <%~ it.returnType %>, TError = Error>(<% it.parameters.forEach((parameter) => { %>
|
|
14
16
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
15
17
|
<% }); %>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% if(it.hasJSDocs) { %>
|
|
1
2
|
/**
|
|
2
3
|
<% if(it.docs && it.docs.length > 0) { %>
|
|
3
4
|
* <%~ it.docs.join('\n * ') %>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
<% }); -%>
|
|
10
11
|
*/
|
|
12
|
+
<% } %>
|
|
11
13
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
12
14
|
<%= parameter.name %><%= parameter.skippable ? '?' : '' %>: <%~ parameter.type %> <%= parameter.optional ? (parameter.skippable ? '| null' : '| null | undefined') : '' %>,
|
|
13
15
|
<% }); %>
|