swagger-typescript-api 10.0.1 → 10.0.3
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/LICENSE +21 -21
- package/README.md +288 -262
- package/index.d.ts +11 -1
- package/index.js +2 -0
- package/package.json +119 -114
- package/src/components.js +3 -5
- package/src/config.js +6 -0
- package/src/constants.js +7 -0
- package/src/files.js +6 -6
- package/src/formatFileContent.js +13 -6
- package/src/index.js +8 -7
- package/src/logger.js +9 -0
- package/src/modelNames.js +1 -5
- package/src/modelTypes.js +7 -6
- package/src/output.js +22 -23
- package/src/render/utils/index.js +9 -1
- package/src/routes.js +4 -1
- package/src/schema.js +87 -64
- package/src/swagger.js +4 -1
- package/src/templates.js +46 -23
- package/src/translators/JavaScript.js +3 -14
- package/src/typeFormatters.js +81 -35
- package/src/utils/resolveName.js +1 -4
- package/templates/README.md +17 -13
- package/templates/base/README.md +7 -7
- package/templates/base/data-contract-jsdoc.ejs +32 -0
- package/templates/base/data-contracts.ejs +28 -0
- package/templates/base/enum-data-contract.ejs +15 -0
- package/templates/base/{http-client.eta → http-client.ejs} +2 -2
- package/templates/base/http-clients/{axios-http-client.eta → axios-http-client.ejs} +133 -145
- package/templates/base/http-clients/{fetch-http-client.eta → fetch-http-client.ejs} +222 -222
- package/templates/base/interface-data-contract.ejs +10 -0
- package/templates/base/object-field-jsdoc.ejs +28 -0
- package/templates/base/{route-docs.eta → route-docs.ejs} +30 -31
- package/templates/base/{route-name.eta → route-name.ejs} +42 -42
- package/templates/base/{route-type.eta → route-type.ejs} +21 -21
- package/templates/base/type-data-contract.ejs +15 -0
- package/templates/default/README.md +6 -6
- package/templates/default/{api.eta → api.ejs} +65 -65
- package/templates/default/{procedure-call.eta → procedure-call.ejs} +99 -99
- package/templates/default/{route-types.eta → route-types.ejs} +28 -28
- package/templates/modular/README.md +6 -6
- package/templates/modular/{api.eta → api.ejs} +28 -28
- package/templates/modular/{procedure-call.eta → procedure-call.ejs} +99 -99
- package/templates/modular/{route-types.eta → route-types.ejs} +18 -18
- package/CHANGELOG.md +0 -872
- package/templates/base/data-contracts.eta +0 -45
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const { modelTypes, utils } = it;
|
|
3
|
-
const { formatDescription, require, _ } = utils;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const dataContractTemplates = {
|
|
7
|
-
enum: (contract) => {
|
|
8
|
-
return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
|
|
9
|
-
},
|
|
10
|
-
interface: (contract) => {
|
|
11
|
-
return `interface ${contract.name} {\r\n${contract.content}}`;
|
|
12
|
-
},
|
|
13
|
-
type: (contract) => {
|
|
14
|
-
return `type ${contract.name} = ${contract.content}`;
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const createDescription = (contract) => {
|
|
19
|
-
if (!contract.typeData) return _.compact([contract.description]);
|
|
20
|
-
|
|
21
|
-
return _.compact([
|
|
22
|
-
contract.description && formatDescription(contract.description),
|
|
23
|
-
contract.typeData.deprecated === true && '@deprecated',
|
|
24
|
-
!_.isUndefined(contract.typeData.format) && `@format ${contract.typeData.format}`,
|
|
25
|
-
!_.isUndefined(contract.typeData.minimum) && `@min ${contract.typeData.minimum}`,
|
|
26
|
-
!_.isUndefined(contract.typeData.maximum) && `@max ${contract.typeData.maximum}`,
|
|
27
|
-
!_.isUndefined(contract.typeData.pattern) && `@pattern ${contract.typeData.pattern}`,
|
|
28
|
-
!_.isUndefined(contract.typeData.example) && `@example ${
|
|
29
|
-
_.isObject(contract.typeData.example) ? JSON.stringify(contract.typeData.example) : contract.typeData.example
|
|
30
|
-
}`,
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
%>
|
|
34
|
-
<% modelTypes.forEach((contract) => { %>
|
|
35
|
-
<% const description = createDescription(contract); %>
|
|
36
|
-
<% if (description.length) { %>
|
|
37
|
-
/**
|
|
38
|
-
<%~ description.map(part => `* ${part}`).join("\n") %>
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
<% } %>
|
|
42
|
-
export <%~ (dataContractTemplates[contract.typeIdentifier] || dataContractTemplates.type)(contract) %>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<% }) %>
|