@cparra/apexdocs 2.13.0-alpha.3 → 2.13.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/README.md +22 -2
- package/docs/Misc-Group/nspc.Reference7.md +7 -0
- package/docs/Misc-Group/nspc.SampleRestResource.md +6 -0
- package/docs/README.md +3 -0
- package/docs/restapi.json +22 -3
- package/examples/force-app/main/default/classes/AnotherInterface.cls +1 -1
- package/examples/force-app/main/default/restapi/SampleRestResource.cls +5 -1
- package/examples/force-app/main/default/restapi/SampleRestResourceToSkip.cls +35 -0
- package/examples/force-app/main/default/restapi/references/Reference7.cls +3 -0
- package/lib/cli/generate.js +7 -1
- package/lib/cli/generate.js.map +1 -1
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +7 -0
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +12 -0
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js.map +1 -0
- package/lib/model/manifest.d.ts +4 -4
- package/lib/model/manifest.js +7 -2
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-home-file.js +1 -1
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/openapi/open-api-types.d.ts +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js +5 -1
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.js +7 -1
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +48 -13
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/util/string-utils.d.ts +1 -1
- package/lib/util/string-utils.js +3 -3
- package/lib/util/string-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/cli/generate.ts +6 -1
- package/src/model/apex-type-wrappers/MethodMirrorWrapper.ts +11 -0
- package/src/model/manifest.ts +18 -4
- package/src/model/markdown-home-file.ts +2 -2
- package/src/model/openapi/open-api-types.ts +1 -0
- package/src/transpiler/openapi/__tests__/open-api-docs-processor.spec.ts +2 -2
- package/src/transpiler/openapi/open-api-docs-processor.ts +5 -1
- package/src/transpiler/openapi/parsers/MethodParser.ts +6 -0
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +76 -19
- package/src/transpiler/openapi/parsers/__tests__/MethodParser.spec.ts +2 -2
- package/src/transpiler/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +45 -1
- package/src/util/string-utils.ts +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ the [Java based ApexDoc tool](https://github.com/SalesforceFoundation/ApexDoc) o
|
|
|
13
13
|
later maintained by Salesforce.org, as that tool is no longer being maintained.
|
|
14
14
|
|
|
15
15
|
ApexDocs is a Node.js library built on Typescript and hosted on [npm](https://www.npmjs.com/package/@cparra/apexdocs).
|
|
16
|
-
It offers CLI capabilities to automatically
|
|
16
|
+
It offers CLI capabilities to automatically document your source code, based on the ApexDoc style of documentation.
|
|
17
17
|
Additionally, it can be imported and consumed directly by your JavaScript code.
|
|
18
18
|
|
|
19
19
|
There are some key differences between ApexDocs and the Java based ApexDoc tool:
|
|
@@ -71,7 +71,10 @@ public class MyClass {
|
|
|
71
71
|
* Apex docs blocks can now all be in a single line
|
|
72
72
|
* Support for grouping blocks of related code within a class
|
|
73
73
|
* Support for HTML tags
|
|
74
|
-
*
|
|
74
|
+
* OpenApi REST specification generation
|
|
75
|
+
* Support for ignoring files and members from being documented
|
|
76
|
+
* Namespace support
|
|
77
|
+
* And much, much more!
|
|
75
78
|
|
|
76
79
|
### Demo
|
|
77
80
|
|
|
@@ -329,6 +332,23 @@ To fix this issue, when not sanitizing HTML, you should wrap any code that conta
|
|
|
329
332
|
treated as HTML within '\`'
|
|
330
333
|
or within `<code>` tags.
|
|
331
334
|
|
|
335
|
+
|
|
336
|
+
### Ignoring files and members
|
|
337
|
+
|
|
338
|
+
You can ignore files and members by using the `@ignore` tag on any ApexDoc block. If used at the class level, the entire
|
|
339
|
+
file will be ignored. If used at the member level, only that member will be ignored.
|
|
340
|
+
|
|
341
|
+
Example
|
|
342
|
+
|
|
343
|
+
```apex
|
|
344
|
+
/**
|
|
345
|
+
* @ignore
|
|
346
|
+
*/
|
|
347
|
+
public class MyClass {
|
|
348
|
+
public static void myMethod() {}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
332
352
|
## Generating OpenApi REST Definitions
|
|
333
353
|
|
|
334
354
|
ApexDocs supports generating OpenApi 3.1.0 REST definitions based on any `@RestResource` classes in your source code.
|
|
@@ -29,6 +29,9 @@ Sample HTTP Delete method with references to other types.
|
|
|
29
29
|
|
|
30
30
|
**Http Response** statusCode: 306 schema: List<Reference1>
|
|
31
31
|
|
|
32
|
+
|
|
33
|
+
**Http Response** statusCode: 307 schema: Reference7[untypedObject:Reference2]
|
|
34
|
+
|
|
32
35
|
### `static doGet()`
|
|
33
36
|
|
|
34
37
|
`HTTPGET`
|
|
@@ -83,6 +86,9 @@ String
|
|
|
83
86
|
A String SObject.
|
|
84
87
|
|
|
85
88
|
|
|
89
|
+
**Summary** Posts an Account 2
|
|
90
|
+
|
|
91
|
+
|
|
86
92
|
**Http Parameter** name: limit in: query required: true description: Limits the number of items on a page schema: type: integer
|
|
87
93
|
|
|
88
94
|
|
package/docs/README.md
CHANGED
package/docs/restapi.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"paths": {
|
|
13
|
-
"
|
|
13
|
+
"AccountService/": {
|
|
14
14
|
"description": "Account related operations",
|
|
15
15
|
"get": {
|
|
16
16
|
"tags": [
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"Account Service"
|
|
143
143
|
],
|
|
144
144
|
"description": "This is a sample HTTP Post method",
|
|
145
|
+
"summary": "Posts an Account 2",
|
|
145
146
|
"requestBody": {
|
|
146
147
|
"description": "This is an example of a request body",
|
|
147
148
|
"content": {
|
|
@@ -314,6 +315,16 @@
|
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
},
|
|
318
|
+
"307": {
|
|
319
|
+
"description": "Status code 307",
|
|
320
|
+
"content": {
|
|
321
|
+
"application/json": {
|
|
322
|
+
"schema": {
|
|
323
|
+
"$ref": "#/components/schemas/Reference7_Reference7[untypedObject:Reference2]"
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
},
|
|
317
328
|
"500": {
|
|
318
329
|
"description": "Status code 500",
|
|
319
330
|
"content": {
|
|
@@ -327,7 +338,7 @@
|
|
|
327
338
|
}
|
|
328
339
|
}
|
|
329
340
|
},
|
|
330
|
-
"
|
|
341
|
+
"Contact/": {
|
|
331
342
|
"description": "Contact related operations",
|
|
332
343
|
"get": {
|
|
333
344
|
"tags": [
|
|
@@ -348,7 +359,7 @@
|
|
|
348
359
|
}
|
|
349
360
|
}
|
|
350
361
|
},
|
|
351
|
-
"
|
|
362
|
+
"Order/": {
|
|
352
363
|
"description": "Order related operations",
|
|
353
364
|
"get": {
|
|
354
365
|
"tags": [
|
|
@@ -557,6 +568,14 @@
|
|
|
557
568
|
"$ref": "#/components/schemas/Reference1"
|
|
558
569
|
}
|
|
559
570
|
},
|
|
571
|
+
"Reference7_Reference7[untypedObject:Reference2]": {
|
|
572
|
+
"type": "object",
|
|
573
|
+
"properties": {
|
|
574
|
+
"untypedObject": {
|
|
575
|
+
"$ref": "#/components/schemas/Reference2"
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
},
|
|
560
579
|
"SampleRestResourceWithInnerClass.InnerClass": {
|
|
561
580
|
"type": "object",
|
|
562
581
|
"properties": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
public interface AnotherInterface{}
|
|
1
|
+
public interface AnotherInterface{}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description Account related operations
|
|
3
3
|
*/
|
|
4
|
-
@RestResource(
|
|
4
|
+
@RestResource(UrlMapping='/AccountService/*')
|
|
5
5
|
global with sharing class SampleRestResource {
|
|
6
6
|
/**
|
|
7
7
|
* @description Sample HTTP Delete method with references to other types.
|
|
@@ -26,6 +26,9 @@ global with sharing class SampleRestResource {
|
|
|
26
26
|
* @http-response
|
|
27
27
|
* statusCode: 306
|
|
28
28
|
* schema: List<Reference1>
|
|
29
|
+
* @http-response
|
|
30
|
+
* statusCode: 307
|
|
31
|
+
* schema: Reference7[untypedObject:Reference2]
|
|
29
32
|
*/
|
|
30
33
|
@HttpDelete
|
|
31
34
|
global static void doDelete() {
|
|
@@ -114,6 +117,7 @@ global with sharing class SampleRestResource {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
/**
|
|
120
|
+
* @summary Posts an Account 2
|
|
117
121
|
* @description This is a sample HTTP Post method
|
|
118
122
|
* @return A String SObject.
|
|
119
123
|
* @http-parameter
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This rest resource should be skipped
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
@RestResource(UrlMapping='/ResourceToSkip/*')
|
|
6
|
+
global with sharing class SampleRestResourceToSkip {
|
|
7
|
+
@HttpDelete
|
|
8
|
+
global static void doDelete() {
|
|
9
|
+
RestRequest req = RestContext.request;
|
|
10
|
+
RestResponse res = RestContext.response;
|
|
11
|
+
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1);
|
|
12
|
+
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
|
|
13
|
+
delete account;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@HttpGet
|
|
17
|
+
global static Account doGet() {
|
|
18
|
+
RestRequest req = RestContext.request;
|
|
19
|
+
RestResponse res = RestContext.response;
|
|
20
|
+
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1);
|
|
21
|
+
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@HttpPost
|
|
26
|
+
global static String doPost(String name,
|
|
27
|
+
String phone, String website) {
|
|
28
|
+
Account account = new Account();
|
|
29
|
+
account.Name = name;
|
|
30
|
+
account.phone = phone;
|
|
31
|
+
account.website = website;
|
|
32
|
+
insert account;
|
|
33
|
+
return account.Id;
|
|
34
|
+
}
|
|
35
|
+
}
|
package/lib/cli/generate.js
CHANGED
|
@@ -86,5 +86,11 @@ settings_1.Settings.build({
|
|
|
86
86
|
namespace: argv.namespace,
|
|
87
87
|
openApiFileName: argv.openApiFileName,
|
|
88
88
|
});
|
|
89
|
-
|
|
89
|
+
try {
|
|
90
|
+
Apexdocs_1.Apexdocs.generate();
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error(error);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
90
96
|
//# sourceMappingURL=generate.js.map
|
package/lib/cli/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/cli/generate.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B,0CAAuC;AACvC,sDAAmD;AAGnD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;IACzB,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,+DAA+D;KAC1E;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,kEAAkE;KAC7E;IACD,SAAS,EAAE;QACT,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,kFAAkF;KAC7F;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,CAAC,QAAQ,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'@cparra/apex-reflection';
|
|
2
|
+
export declare class MethodMirrorWrapper {
|
|
3
|
+
methodMirror: MethodMirror;
|
|
4
|
+
constructor(methodMirror: MethodMirror);
|
|
5
|
+
hasDocCommentAnnotation: (annotationName: string) => boolean | undefined;
|
|
6
|
+
getDocCommentAnnotation: (annotationName: string) => DocCommentAnnotation | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodMirrorWrapper = void 0;
|
|
4
|
+
class MethodMirrorWrapper {
|
|
5
|
+
constructor(methodMirror) {
|
|
6
|
+
this.methodMirror = methodMirror;
|
|
7
|
+
this.hasDocCommentAnnotation = (annotationName) => { var _a; return (_a = this.methodMirror.docComment) === null || _a === void 0 ? void 0 : _a.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName); };
|
|
8
|
+
this.getDocCommentAnnotation = (annotationName) => { var _a; return (_a = this.methodMirror.docComment) === null || _a === void 0 ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === annotationName); };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.MethodMirrorWrapper = MethodMirrorWrapper;
|
|
12
|
+
//# sourceMappingURL=MethodMirrorWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodMirrorWrapper.js","sourceRoot":"","sources":["../../../src/model/apex-type-wrappers/MethodMirrorWrapper.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAmB;IAC9B,YAAmB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;QAEtC,4BAAuB,GAAG,CAAC,cAAsB,EAAE,EAAE,WAC1D,OAAA,MAAA,IAAI,CAAC,YAAY,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,cAAc,CAAC,CAAA,EAAA,CAAC;QAE5G,4BAAuB,GAAG,CAAC,cAAsB,EAAoC,EAAE,WAC5F,OAAA,MAAA,IAAI,CAAC,YAAY,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,cAAc,CAAC,CAAA,EAAA,CAAC;IANnE,CAAC;CAOlD;AARD,kDAQC"}
|
package/lib/model/manifest.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Type, Annotation } from '@cparra/apex-reflection';
|
|
2
|
-
type
|
|
1
|
+
import { Type, Annotation, DocComment } from '@cparra/apex-reflection';
|
|
2
|
+
type AccessAndDocAware = {
|
|
3
3
|
access_modifier: string;
|
|
4
|
-
} & {
|
|
5
4
|
annotations: Annotation[];
|
|
5
|
+
docComment?: DocComment;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Represents the full library of Apex top-level types (classes, enums, and interface) for a Salesforce project.
|
|
@@ -17,6 +17,6 @@ export default class Manifest {
|
|
|
17
17
|
*/
|
|
18
18
|
constructor(types: Type[], isForInnerTypes?: boolean);
|
|
19
19
|
filteredByAccessModifierAndAnnotations(modifiers: string[]): Type[];
|
|
20
|
-
filterAccessibleModifier(
|
|
20
|
+
filterAccessibleModifier(accessAndDocAwares: AccessAndDocAware[], modifiers: string[]): AccessAndDocAware[];
|
|
21
21
|
}
|
|
22
22
|
export {};
|
package/lib/model/manifest.js
CHANGED
|
@@ -31,8 +31,13 @@ class Manifest {
|
|
|
31
31
|
}
|
|
32
32
|
return typesToReturn;
|
|
33
33
|
}
|
|
34
|
-
filterAccessibleModifier(
|
|
35
|
-
return
|
|
34
|
+
filterAccessibleModifier(accessAndDocAwares, modifiers) {
|
|
35
|
+
return accessAndDocAwares.filter((currentType) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const hasIgnoreDocAnnotation = (_a = currentType.docComment) === null || _a === void 0 ? void 0 : _a.annotations.some((annotation) => annotation.name === 'ignore');
|
|
38
|
+
if (hasIgnoreDocAnnotation) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
36
41
|
return (modifiers.includes(currentType.access_modifier) ||
|
|
37
42
|
currentType.annotations.some((annotation) => modifiers.includes(annotation.type.toLowerCase())));
|
|
38
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/model/manifest.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/model/manifest.ts"],"names":[],"mappings":";;AAYA;;GAEG;AACH,MAAqB,QAAQ;IAC3B;;;;OAIG;IACH,YAAmB,KAAa,EAAS,kBAA2B,KAAK;QAAtD,UAAK,GAAL,KAAK,CAAQ;QAAS,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAE7E,sCAAsC,CAAC,SAAmB;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3E,MAAM,aAAa,GAAW,EAAE,CAAC;QACjC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;YACxC,MAAM,WAAW,GAAG,YAAoB,CAAC;YACzC,IAAI,WAAW,CAAC,SAAS,KAAK,OAAO,EAAE;gBACrC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAChC,SAAS;aACV;YAED,MAAM,YAAY,GAAG,WAA0B,CAAC;YAChD,IAAI,aAAa,mCACZ,WAAW,KACd,OAAO,EAAE,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EACvE,UAAU,EAAE,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,EAC7E,MAAM,EAAE,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,E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|
if ((_a = typeMirror.docComment) === null || _a === void 0 ? void 0 : _a.descriptionLines) {
|
|
34
34
|
const description = typeMirror.docComment.descriptionLines.reduce((previous, current) => previous + current + '\n', '');
|
|
35
|
-
this.addText((0, string_utils_1.
|
|
35
|
+
this.addText((0, string_utils_1.truncate)(description, 300));
|
|
36
36
|
this.addBlankLine();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-home-file.js","sourceRoot":"","sources":["../../src/model/markdown-home-file.ts"],"names":[],"mappings":";;;AACA,kGAAyF;AACzF,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"markdown-home-file.js","sourceRoot":"","sources":["../../src/model/markdown-home-file.ts"],"names":[],"mappings":";;;AACA,kGAAyF;AACzF,mDAA+C;AAC/C,uDAAgD;AAChD,0CAAuC;AAEvC,MAAa,gBAAiB,SAAQ,4BAAY;IAChD,YAAmB,QAAgB,EAAS,KAAa,EAAE,aAAsB;QAC/E,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QADH,aAAQ,GAAR,QAAQ,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QAEvD,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAC7B;QACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,MAAM,cAAc,GAAwB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9D,cAAc,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;YACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACtB,KAAK,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC3B,IAAI,CAAC,YAAY,CAAC,U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AI,KAAK,OAAO,CAAC,0CAAE,IAAI,mCAC1F,mBAAQ,CAAC,WAAW,EAAE,CAAC,mBAAmB,EAAE,CAC7C,CAAC;IACJ,CAAC;CACF;AAnDD,4CAmDC"}
|
|
@@ -64,7 +64,11 @@ class OpenApiDocsProcessor extends processor_type_transpiler_1.default {
|
|
|
64
64
|
logger_1.Logger.error(`Type does not contain urlMapping annotation ${type.name}`);
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
let endpointPath = urlMapping.value.replaceAll('"', '').replaceAll("'", '').replaceAll('/*', '/');
|
|
68
|
+
if (endpointPath.startsWith('/')) {
|
|
69
|
+
endpointPath = endpointPath.substring(1);
|
|
70
|
+
}
|
|
71
|
+
return endpointPath;
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
exports.OpenApiDocsProcessor = OpenApiDocsProcessor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-docs-processor.js","sourceRoot":"","sources":["../../../src/transpiler/openapi/open-api-docs-processor.ts"],"names":[],"mappings":";;;AAAA,4EAAmE;AACnE,sDAAkD;AAElD,6EAAwE;AACxE,8CAA2C;AAC3C,2DAAuD;AACvD,6CAA0C;AAC1C,yDAAsD;AACtD,0DAAsD;AAEtD,MAAa,oBAAqB,SAAQ,mCAAuB;IAI/D;QACE,KAAK,EAAE,CAAC;QAsDV,mBAAc,GAA0C,GAAG,EAAE;YAC3D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,mCAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC;QAvDA,IAAI,CAAC,cAAc,GAAG,IAAI,8BAAa,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC,eAAe,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,KAAK,CAAC,gCAAgC,CAAC,CAAC;SAC/C;QACD,IAA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Y,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEhE,OAAO;QACP,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,MAAM;QACN,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAE9D,SAAS;QACT,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAMO,eAAe,CAAC,IAAU;;QAChC,MAAM,sBAAsB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,cAAc,CAAC,CAAC;QACjH,MAAM,UAAU,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,aAAa,0CAAE,IAAI,CAC5D,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,YAAY,CACxD,CAAC;QACF,IAAI,CAAC,UAAU,EAAE;YACf,eAAM,CAAC,KAAK,CAAC,+CAA+C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACzE,OAAO,IAAI,CAAC;SACb;QAED,
|
|
1
|
+
{"version":3,"file":"open-api-docs-processor.js","sourceRoot":"","sources":["../../../src/transpiler/openapi/open-api-docs-processor.ts"],"names":[],"mappings":";;;AAAA,4EAAmE;AACnE,sDAAkD;AAElD,6EAAwE;AACxE,8CAA2C;AAC3C,2DAAuD;AACvD,6CAA0C;AAC1C,yDAAsD;AACtD,0DAAsD;AAEtD,MAAa,oBAAqB,SAAQ,mCAAuB;IAI/D;QACE,KAAK,EAAE,CAAC;QAsDV,mBAAc,GAA0C,GAAG,EAAE;YAC3D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,mCAAe,CA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AE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClG,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAChC,YAAY,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC1C;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA/ED,oDA+EC"}
|
|
@@ -7,6 +7,7 @@ const ReferenceBuilder_1 = require("./ReferenceBuilder");
|
|
|
7
7
|
const ParameterObjectBuilder_1 = require("./ParameterObjectBuilder");
|
|
8
8
|
const ResponsesBuilder_1 = require("./ResponsesBuilder");
|
|
9
9
|
const RequestBodyBuilder_1 = require("./RequestBodyBuilder");
|
|
10
|
+
const MethodMirrorWrapper_1 = require("../../../model/apex-type-wrappers/MethodMirrorWrapper");
|
|
10
11
|
/**
|
|
11
12
|
* Parses ApexDocs with HTTP REST annotations and turns them into an OpenApi specification.
|
|
12
13
|
*/
|
|
@@ -15,7 +16,7 @@ class MethodParser {
|
|
|
15
16
|
this.openApiModel = openApiModel;
|
|
16
17
|
}
|
|
17
18
|
parseMethod(classMirror, httpUrlEndpoint, httpMethodKey, tag) {
|
|
18
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
19
20
|
const classMirrorWrapper = new ClassMirrorWrapper_1.ClassMirrorWrapper(classMirror);
|
|
20
21
|
// Apex supports HttpGet, HttpPut, HttpPost, HttpDelete, and HttpPatch, so we search for a method
|
|
21
22
|
// that has one of those annotations.
|
|
@@ -30,6 +31,11 @@ class MethodParser {
|
|
|
30
31
|
if ((_a = httpMethod.docComment) === null || _a === void 0 ? void 0 : _a.description) {
|
|
31
32
|
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].description = httpMethod.docComment.description;
|
|
32
33
|
}
|
|
34
|
+
const methodMirrorWrapper = new MethodMirrorWrapper_1.MethodMirrorWrapper(httpMethod);
|
|
35
|
+
if (methodMirrorWrapper.hasDocCommentAnnotation('summary')) {
|
|
36
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey].summary =
|
|
37
|
+
(_b = methodMirrorWrapper.getDocCommentAnnotation('summary')) === null || _b === void 0 ? void 0 : _b.body;
|
|
38
|
+
}
|
|
33
39
|
this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, httpMethodKey, 'http-request-body', this.addRequestBodyToOpenApi.bind(this), this.fallbackHttpRequestBodyParser(httpUrlEndpoint, httpMethodKey));
|
|
34
40
|
this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, httpMethodKey, 'http-parameter', this.addParametersToOpenApi.bind(this));
|
|
35
41
|
this.parseHttpAnnotation(httpMethod, httpUrlEndpoint, httpMethodKey, 'http-response', this.addHttpResponsesToOpenApi.bind(this), this.getFallbackHttpResponseParser(httpUrlEndpoint, httpMethodKey));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MethodParser.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/MethodParser.ts"],"names":[],"mappings":";;;AAEA,gCAAgC;AAChC,6FAA0F;AAC1F,yDAAiE;AACjE,qEAAkE;AAClE,yDAAsD;AAMtD,6DAA0D;
|
|
1
|
+
{"version":3,"file":"MethodParser.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/MethodParser.ts"],"names":[],"mappings":";;;AAEA,gCAAgC;AAChC,6FAA0F;AAC1F,yDAAiE;AACjE,qEAAkE;AAClE,yDAAsD;AAMtD,6DAA0D;AAG1D,+FAA4F;AAO5F;;GAEG;AACH,MAAa,YAAY;IACvB,YAAmB,YAAqB;QAArB,iBAAY,GAAZ,YAAY,CAAS;IAAG,CAAC;IAErC,WAAW,CAAC,WAAwB,EAAE,eAAuB,EAAE,aAA6B,EAAE,GAAW;;QAC9G,MAAM,kBAAkB,GAAG,IAAI,uCAAkB,CAAC,WAAW,CAAC,CAAC;QAC/D,iGAAiG;QACjG,qCAAqC;QACrC,MAAM,WAAW,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,OA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,MAAM,EAAE;gBACzD,OAAO;aACR;YAED,iEAAiE;YACjE,eAAe,CAAC,SAAS,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChE,uEAAuE;gBACvE,IAAI,CAAC,YAAY,CAAC,UAAW,CAAC,OAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;YACnF,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AA/ND,oCA+NC"}
|
|
@@ -10,15 +10,24 @@ class ReferenceBuilder {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
build(referencedTypeName) {
|
|
13
|
+
const originalTypeName = referencedTypeName;
|
|
14
|
+
// Checking for inline overrides of the type: [memberName:ClassOverrideName]
|
|
15
|
+
const regexForSchemaOverrides = /\[(.*?)]/g;
|
|
16
|
+
const schemaOverrides = referencedTypeName.match(regexForSchemaOverrides);
|
|
17
|
+
let referenceOverrides = [];
|
|
18
|
+
if (schemaOverrides && schemaOverrides.length > 0) {
|
|
19
|
+
referenceOverrides = ReferenceOverrides.build(schemaOverrides[0]);
|
|
20
|
+
referencedTypeName = referencedTypeName.replace(regexForSchemaOverrides, '');
|
|
21
|
+
}
|
|
13
22
|
const [parsedReferencedType, isCollection] = this.handlePossibleCollectionReference(referencedTypeName);
|
|
14
23
|
const referencedTypeBundle = types_repository_1.TypesRepository.getInstance().getFromAllByName(parsedReferencedType);
|
|
15
24
|
if (!referencedTypeBundle) {
|
|
16
|
-
throw new Error(`The referenced type
|
|
25
|
+
throw new Error(`The referenced type ${referencedTypeName} was not found.`);
|
|
17
26
|
}
|
|
18
27
|
if (referencedTypeBundle.type.type_name !== 'class') {
|
|
19
28
|
throw new Error(`Expected the referenced type to be a class, but found a ${referencedTypeBundle.type.type_name}.`);
|
|
20
29
|
}
|
|
21
|
-
const typeBundleWithIsCollection = Object.assign(Object.assign({}, referencedTypeBundle), { isCollection: isCollection });
|
|
30
|
+
const typeBundleWithIsCollection = Object.assign(Object.assign({}, referencedTypeBundle), { originalTypeName: originalTypeName, isCollection: isCollection, referenceOverrides: referenceOverrides });
|
|
22
31
|
return this.buildReferenceFromType(typeBundleWithIsCollection);
|
|
23
32
|
}
|
|
24
33
|
/**
|
|
@@ -56,16 +65,27 @@ class ReferenceBuilder {
|
|
|
56
65
|
let referencedComponents = [];
|
|
57
66
|
propertiesAndFields.forEach((current) => {
|
|
58
67
|
var _a, _b;
|
|
59
|
-
// Check for
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
// Check if there are reference overrides for the current property, this takes priority over anything else.
|
|
69
|
+
const referenceOverride = typeBundle.referenceOverrides.find((currentOverride) => {
|
|
70
|
+
return currentOverride.propertyName.toLowerCase() === current.name.toLowerCase();
|
|
71
|
+
});
|
|
72
|
+
if (referenceOverride) {
|
|
73
|
+
const reference = this.build(referenceOverride.referenceName);
|
|
74
|
+
properties[current.name] = reference.entrypointReferenceObject;
|
|
75
|
+
reference.referenceComponents.forEach((current) => referencedComponents.push(current));
|
|
64
76
|
}
|
|
65
77
|
else {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
// Check for "@http-schema" annotations within properties themselves. If these are specified they
|
|
79
|
+
// take precedence over the property type itself.
|
|
80
|
+
const manuallyDefinedHttpSchema = (_a = current.docComment) === null || _a === void 0 ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === 'http-schema');
|
|
81
|
+
if (manuallyDefinedHttpSchema) {
|
|
82
|
+
this.handleOverriddenSchema(manuallyDefinedHttpSchema, properties, current, referencedComponents);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const pair = this.getReferenceType(current.typeReference);
|
|
86
|
+
properties[current.name] = pair.schema;
|
|
87
|
+
referencedComponents.push(...pair.referenceComponents);
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
90
|
properties[current.name].description = (_b = current.docComment) === null || _b === void 0 ? void 0 : _b.description;
|
|
71
91
|
});
|
|
@@ -83,8 +103,8 @@ class ReferenceBuilder {
|
|
|
83
103
|
// This can be of type ApexDocSchemaObject
|
|
84
104
|
const inYaml = manuallyDefinedHttpSchema === null || manuallyDefinedHttpSchema === void 0 ? void 0 : manuallyDefinedHttpSchema.bodyLines.reduce((prev, current, _) => prev + '\n' + current);
|
|
85
105
|
const asJson = yaml.load(inYaml);
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
106
|
+
const isReferenceString = this.isReferenceString(asJson);
|
|
107
|
+
if (isReferenceString) {
|
|
88
108
|
const reference = this.build(asJson);
|
|
89
109
|
properties[current.name] = reference.entrypointReferenceObject;
|
|
90
110
|
reference.referenceComponents.forEach((current) => referencedComponents.push(current));
|
|
@@ -104,6 +124,9 @@ class ReferenceBuilder {
|
|
|
104
124
|
if (typeBundle.isCollection) {
|
|
105
125
|
referenceName = `${referenceName}_array`;
|
|
106
126
|
}
|
|
127
|
+
if (typeBundle.referenceOverrides.length) {
|
|
128
|
+
referenceName = `${referenceName}_${typeBundle.originalTypeName}`;
|
|
129
|
+
}
|
|
107
130
|
return referenceName;
|
|
108
131
|
}
|
|
109
132
|
buildMainReferenceComponent(typeBundle, properties) {
|
|
@@ -166,13 +189,15 @@ class ReferenceBuilder {
|
|
|
166
189
|
// For Maps, we treat them as objects but do not try to define their shape, because their keys can vary
|
|
167
190
|
// at runtime.
|
|
168
191
|
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
192
|
+
case 'object':
|
|
193
|
+
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
169
194
|
default:
|
|
170
195
|
// If we got here we are dealing with a non-primitive (most likely a custom class or an SObject).
|
|
171
196
|
const referencedType = types_repository_1.TypesRepository.getInstance().getFromAllByName(typeName);
|
|
172
197
|
if (!referencedType) {
|
|
173
198
|
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
174
199
|
}
|
|
175
|
-
const reference = this.buildReferenceFromType(Object.assign(Object.assign({}, referencedType), { isCollection: false }));
|
|
200
|
+
const reference = this.buildReferenceFromType(Object.assign(Object.assign({}, referencedType), { isCollection: false, referenceOverrides: [], originalTypeName: typeName }));
|
|
176
201
|
return {
|
|
177
202
|
schema: reference.entrypointReferenceObject,
|
|
178
203
|
referenceComponents: [...reference.referenceComponents],
|
|
@@ -188,4 +213,14 @@ class ReferenceBuilder {
|
|
|
188
213
|
}
|
|
189
214
|
}
|
|
190
215
|
exports.ReferenceBuilder = ReferenceBuilder;
|
|
216
|
+
class ReferenceOverrides {
|
|
217
|
+
static build(referenceAsString) {
|
|
218
|
+
const cleanedUpReference = referenceAsString.replace(/[\[\]]/g, '');
|
|
219
|
+
const referenceStrings = cleanedUpReference.split(',').map((item) => item.replace(/\s/g, ''));
|
|
220
|
+
return referenceStrings.map((item) => {
|
|
221
|
+
const [propertyName, referenceName] = item.split(':');
|
|
222
|
+
return { propertyName, referenceName };
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
191
226
|
//# sourceMappingURL=ReferenceBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceBuilder.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/ReferenceBuilder.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AAQhC,sEAA8E;
|
|
1
|
+
{"version":3,"file":"ReferenceBuilder.js","sourceRoot":"","sources":["../../../../src/transpiler/openapi/parsers/ReferenceBuilder.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AAQhC,sEAA8E;AAW9E,MAAa,gBAAgB;IAA7B;QA6OU,sBAAiB,GAAG,CAAC,YAAqB,EAA0B,EAAE;YAC5E,OAAO,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,YAAY,MAAM,CAAC;QAC5E,CAAC,CAAC;IACJ,CAAC;IA/OC,KAAK,CAAC,kBAA0B;QAC9B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;QAE5C,4EAA4E;QAC5E,MAAM,uBAAuB,GAAG,WAAW,C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AAM,kBAAkB;IACtB,MAAM,CAAC,KAAK,CAAC,iBAAyB;QACpC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACpE,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9F,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACnC,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function truncate(str: string, n: number): string;
|
|
2
2
|
export declare const camel2title: (camelCase: string) => string;
|
package/lib/util/string-utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.camel2title = exports.
|
|
4
|
-
function
|
|
3
|
+
exports.camel2title = exports.truncate = void 0;
|
|
4
|
+
function truncate(str, n) {
|
|
5
5
|
return str.length > n ? str.substr(0, n - 1) + '…' : str;
|
|
6
6
|
}
|
|
7
|
-
exports.
|
|
7
|
+
exports.truncate = truncate;
|
|
8
8
|
const camel2title = (camelCase) => camelCase
|
|
9
9
|
.replace(/([A-Z])/g, (match) => ` ${match}`)
|
|
10
10
|
.replace(/^./, (match) => match.toUpperCase())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../src/util/string-utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,
|
|
1
|
+
{"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../src/util/string-utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,GAAW,EAAE,CAAS;IAC7C,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;AAClE,CAAC;AAFD,4BAEC;AAEM,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CAC/C,SAAS;KACN,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;KAC3C,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;KAC7C,IAAI,EAAE,CAAC;AAJC,QAAA,WAAW,eAIZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "2.13.0
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@cparra/apex-reflection": "2.
|
|
69
|
+
"@cparra/apex-reflection": "2.3.0",
|
|
70
70
|
"chalk": "^4.1.2",
|
|
71
71
|
"fast-xml-parser": "^4.0.1",
|
|
72
72
|
"js-yaml": "^4.1.0",
|
package/src/cli/generate.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocCommentAnnotation, MethodMirror } from '@cparra/apex-reflection';
|
|
2
|
+
|
|
3
|
+
export class MethodMirrorWrapper {
|
|
4
|
+
constructor(public methodMirror: MethodMirror) {}
|
|
5
|
+
|
|
6
|
+
public hasDocCommentAnnotation = (annotationName: string) =>
|
|
7
|
+
this.methodMirror.docComment?.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
8
|
+
|
|
9
|
+
public getDocCommentAnnotation = (annotationName: string): DocCommentAnnotation | undefined =>
|
|
10
|
+
this.methodMirror.docComment?.annotations.find((annotation) => annotation.name.toLowerCase() === annotationName);
|
|
11
|
+
}
|
package/src/model/manifest.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ClassMirror,
|
|
3
|
+
EnumMirror,
|
|
4
|
+
InterfaceMirror,
|
|
5
|
+
Type,
|
|
6
|
+
Annotation,
|
|
7
|
+
DocComment,
|
|
8
|
+
DocCommentAnnotation,
|
|
9
|
+
} from '@cparra/apex-reflection';
|
|
2
10
|
|
|
3
|
-
type
|
|
11
|
+
type AccessAndDocAware = { access_modifier: string; annotations: Annotation[]; docComment?: DocComment };
|
|
4
12
|
|
|
5
13
|
/**
|
|
6
14
|
* Represents the full library of Apex top-level types (classes, enums, and interface) for a Salesforce project.
|
|
@@ -49,8 +57,14 @@ export default class Manifest {
|
|
|
49
57
|
return typesToReturn;
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
filterAccessibleModifier(
|
|
53
|
-
return
|
|
60
|
+
filterAccessibleModifier(accessAndDocAwares: AccessAndDocAware[], modifiers: string[]) {
|
|
61
|
+
return accessAndDocAwares.filter((currentType) => {
|
|
62
|
+
const hasIgnoreDocAnnotation = currentType.docComment?.annotations.some(
|
|
63
|
+
(annotation: DocCommentAnnotation) => annotation.name === 'ignore',
|
|
64
|
+
);
|
|
65
|
+
if (hasIgnoreDocAnnotation) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
54
68
|
return (
|
|
55
69
|
modifiers.includes(currentType.access_modifier) ||
|
|
56
70
|
currentType.annotations.some((annotation: Annotation) => modifiers.includes(annotation.type.toLowerCase()))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from '@cparra/apex-reflection';
|
|
2
2
|
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
3
3
|
import { MarkdownFile } from './markdown-file';
|
|
4
|
-
import {
|
|
4
|
+
import { truncate } from '../util/string-utils';
|
|
5
5
|
import { Settings } from '../settings';
|
|
6
6
|
|
|
7
7
|
export class MarkdownHomeFile extends MarkdownFile {
|
|
@@ -34,7 +34,7 @@ export class MarkdownHomeFile extends MarkdownFile {
|
|
|
34
34
|
(previous, current) => previous + current + '\n',
|
|
35
35
|
'',
|
|
36
36
|
);
|
|
37
|
-
this.addText(
|
|
37
|
+
this.addText(truncate(description, 300));
|
|
38
38
|
this.addBlankLine();
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -21,7 +21,7 @@ it('should add a path based on the @UrlResource annotation on the class', functi
|
|
|
21
21
|
const processor = new OpenApiDocsProcessor();
|
|
22
22
|
processor.onProcess(classMirror);
|
|
23
23
|
|
|
24
|
-
expect(processor.openApiModel.paths).toHaveProperty('
|
|
24
|
+
expect(processor.openApiModel.paths).toHaveProperty('Account/');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('should contain a path with a description when the class has an ApexDoc comment', function () {
|
|
@@ -37,5 +37,5 @@ it('should contain a path with a description when the class has an ApexDoc comme
|
|
|
37
37
|
const processor = new OpenApiDocsProcessor();
|
|
38
38
|
processor.onProcess(classMirror);
|
|
39
39
|
|
|
40
|
-
expect(processor.openApiModel.paths['
|
|
40
|
+
expect(processor.openApiModel.paths['Account/'].description).toBe('My Description');
|
|
41
41
|
});
|
|
@@ -81,6 +81,10 @@ export class OpenApiDocsProcessor extends ProcessorTypeTranspiler {
|
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
let endpointPath = urlMapping.value.replaceAll('"', '').replaceAll("'", '').replaceAll('/*', '/');
|
|
85
|
+
if (endpointPath.startsWith('/')) {
|
|
86
|
+
endpointPath = endpointPath.substring(1);
|
|
87
|
+
}
|
|
88
|
+
return endpointPath;
|
|
85
89
|
}
|
|
86
90
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { RequestBodyBuilder } from './RequestBodyBuilder';
|
|
14
14
|
import { ApexDocSchemaAware } from './Builder';
|
|
15
15
|
import { PropertiesObject, ReferenceObject } from '../../../model/openapi/open-api-types';
|
|
16
|
+
import { MethodMirrorWrapper } from '../../../model/apex-type-wrappers/MethodMirrorWrapper';
|
|
16
17
|
|
|
17
18
|
type FallbackMethodParser = (methodMirror: MethodMirror) => void;
|
|
18
19
|
type AddToOpenApi<T extends ApexDocSchemaAware> = (input: T, urlValue: string, httpMethodKey: HttpOperations) => void;
|
|
@@ -42,6 +43,11 @@ export class MethodParser {
|
|
|
42
43
|
if (httpMethod.docComment?.description) {
|
|
43
44
|
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey]!.description = httpMethod.docComment.description;
|
|
44
45
|
}
|
|
46
|
+
const methodMirrorWrapper = new MethodMirrorWrapper(httpMethod);
|
|
47
|
+
if (methodMirrorWrapper.hasDocCommentAnnotation('summary')) {
|
|
48
|
+
this.openApiModel.paths[httpUrlEndpoint][httpMethodKey]!.summary =
|
|
49
|
+
methodMirrorWrapper.getDocCommentAnnotation('summary')?.body;
|
|
50
|
+
}
|
|
45
51
|
|
|
46
52
|
this.parseHttpAnnotation<ApexDocHttpRequestBody>(
|
|
47
53
|
httpMethod,
|
|
@@ -11,22 +11,42 @@ import { ClassMirror, DocCommentAnnotation, FieldMirror, PropertyMirror } from '
|
|
|
11
11
|
import { ListObjectType, ReferencedType } from '@cparra/apex-reflection';
|
|
12
12
|
import { ApexDocSchemaObject } from '../../../model/openapi/apex-doc-types';
|
|
13
13
|
|
|
14
|
-
type
|
|
14
|
+
type TypeBundleWithIsCollectionAndReferenceOverrides = TypeBundle & {
|
|
15
|
+
originalTypeName: string;
|
|
16
|
+
isCollection: boolean;
|
|
17
|
+
referenceOverrides: ReferenceOverride[];
|
|
18
|
+
};
|
|
15
19
|
|
|
16
20
|
export class ReferenceBuilder {
|
|
17
21
|
build(referencedTypeName: string): Reference {
|
|
22
|
+
const originalTypeName = referencedTypeName;
|
|
23
|
+
|
|
24
|
+
// Checking for inline overrides of the type: [memberName:ClassOverrideName]
|
|
25
|
+
const regexForSchemaOverrides = /\[(.*?)]/g;
|
|
26
|
+
const schemaOverrides = referencedTypeName.match(regexForSchemaOverrides);
|
|
27
|
+
let referenceOverrides: ReferenceOverride[] = [];
|
|
28
|
+
if (schemaOverrides && schemaOverrides.length > 0) {
|
|
29
|
+
referenceOverrides = ReferenceOverrides.build(schemaOverrides[0]);
|
|
30
|
+
referencedTypeName = referencedTypeName.replace(regexForSchemaOverrides, '');
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
const [parsedReferencedType, isCollection] = this.handlePossibleCollectionReference(referencedTypeName);
|
|
19
34
|
const referencedTypeBundle = TypesRepository.getInstance().getFromAllByName(parsedReferencedType);
|
|
20
35
|
|
|
21
36
|
if (!referencedTypeBundle) {
|
|
22
|
-
throw new Error(`The referenced type
|
|
37
|
+
throw new Error(`The referenced type ${referencedTypeName} was not found.`);
|
|
23
38
|
}
|
|
24
39
|
if (referencedTypeBundle.type.type_name !== 'class') {
|
|
25
40
|
throw new Error(
|
|
26
41
|
`Expected the referenced type to be a class, but found a ${referencedTypeBundle.type.type_name}.`,
|
|
27
42
|
);
|
|
28
43
|
}
|
|
29
|
-
const typeBundleWithIsCollection = {
|
|
44
|
+
const typeBundleWithIsCollection = {
|
|
45
|
+
...referencedTypeBundle,
|
|
46
|
+
originalTypeName: originalTypeName,
|
|
47
|
+
isCollection: isCollection,
|
|
48
|
+
referenceOverrides: referenceOverrides,
|
|
49
|
+
};
|
|
30
50
|
return this.buildReferenceFromType(typeBundleWithIsCollection);
|
|
31
51
|
}
|
|
32
52
|
|
|
@@ -51,7 +71,7 @@ export class ReferenceBuilder {
|
|
|
51
71
|
return [referencedTypeName, false];
|
|
52
72
|
}
|
|
53
73
|
|
|
54
|
-
private buildReferenceFromType(typeBundle:
|
|
74
|
+
private buildReferenceFromType(typeBundle: TypeBundleWithIsCollectionAndReferenceOverrides): Reference {
|
|
55
75
|
// Filtering based on Salesforce's documentation:
|
|
56
76
|
// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm#ApexRESTUserDefinedTypes
|
|
57
77
|
// We assume that the class only contains object types allowed by Apex Rest:
|
|
@@ -66,18 +86,29 @@ export class ReferenceBuilder {
|
|
|
66
86
|
const properties: PropertiesObject = {};
|
|
67
87
|
let referencedComponents: ReferenceComponent[] = [];
|
|
68
88
|
propertiesAndFields.forEach((current) => {
|
|
69
|
-
// Check for
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
// Check if there are reference overrides for the current property, this takes priority over anything else.
|
|
90
|
+
const referenceOverride = typeBundle.referenceOverrides.find((currentOverride) => {
|
|
91
|
+
return currentOverride.propertyName.toLowerCase() === current.name.toLowerCase();
|
|
92
|
+
});
|
|
93
|
+
if (referenceOverride) {
|
|
94
|
+
const reference = this.build(referenceOverride.referenceName);
|
|
95
|
+
properties[current.name] = reference.entrypointReferenceObject;
|
|
96
|
+
reference.referenceComponents.forEach((current) => referencedComponents.push(current));
|
|
76
97
|
} else {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
// Check for "@http-schema" annotations within properties themselves. If these are specified they
|
|
99
|
+
// take precedence over the property type itself.
|
|
100
|
+
const manuallyDefinedHttpSchema = current.docComment?.annotations.find(
|
|
101
|
+
(annotation) => annotation.name.toLowerCase() === 'http-schema',
|
|
102
|
+
);
|
|
103
|
+
if (manuallyDefinedHttpSchema) {
|
|
104
|
+
this.handleOverriddenSchema(manuallyDefinedHttpSchema, properties, current, referencedComponents);
|
|
105
|
+
} else {
|
|
106
|
+
const pair = this.getReferenceType(current.typeReference);
|
|
107
|
+
properties[current.name] = pair.schema;
|
|
108
|
+
referencedComponents.push(...pair.referenceComponents);
|
|
109
|
+
}
|
|
80
110
|
}
|
|
111
|
+
|
|
81
112
|
properties[current.name].description = current.docComment?.description;
|
|
82
113
|
});
|
|
83
114
|
const mainReferenceComponents = this.buildMainReferenceComponent(typeBundle, properties);
|
|
@@ -102,9 +133,9 @@ export class ReferenceBuilder {
|
|
|
102
133
|
// This can be of type ApexDocSchemaObject
|
|
103
134
|
const inYaml = manuallyDefinedHttpSchema?.bodyLines.reduce((prev, current, _) => prev + '\n' + current);
|
|
104
135
|
const asJson = yaml.load(inYaml) as ApexDocSchemaObject;
|
|
105
|
-
const
|
|
136
|
+
const isReferenceString = this.isReferenceString(asJson);
|
|
106
137
|
|
|
107
|
-
if (
|
|
138
|
+
if (isReferenceString) {
|
|
108
139
|
const reference = this.build(asJson);
|
|
109
140
|
properties[current.name] = reference.entrypointReferenceObject;
|
|
110
141
|
reference.referenceComponents.forEach((current) => referencedComponents.push(current));
|
|
@@ -115,7 +146,7 @@ export class ReferenceBuilder {
|
|
|
115
146
|
}
|
|
116
147
|
}
|
|
117
148
|
|
|
118
|
-
private getReferenceName(typeBundle:
|
|
149
|
+
private getReferenceName(typeBundle: TypeBundleWithIsCollectionAndReferenceOverrides): string {
|
|
119
150
|
let referenceName = typeBundle.type.name;
|
|
120
151
|
if (typeBundle.isChild) {
|
|
121
152
|
referenceName = `${typeBundle.parentType?.name}.${typeBundle.type.name}`;
|
|
@@ -123,11 +154,14 @@ export class ReferenceBuilder {
|
|
|
123
154
|
if (typeBundle.isCollection) {
|
|
124
155
|
referenceName = `${referenceName}_array`;
|
|
125
156
|
}
|
|
157
|
+
if (typeBundle.referenceOverrides.length) {
|
|
158
|
+
referenceName = `${referenceName}_${typeBundle.originalTypeName}`;
|
|
159
|
+
}
|
|
126
160
|
return referenceName;
|
|
127
161
|
}
|
|
128
162
|
|
|
129
163
|
private buildMainReferenceComponent(
|
|
130
|
-
typeBundle:
|
|
164
|
+
typeBundle: TypeBundleWithIsCollectionAndReferenceOverrides,
|
|
131
165
|
properties: PropertiesObject,
|
|
132
166
|
): ReferenceComponent[] {
|
|
133
167
|
// For the main reference, we always want to get the reference of the object without the collection part,
|
|
@@ -191,13 +225,20 @@ export class ReferenceBuilder {
|
|
|
191
225
|
// For Maps, we treat them as objects but do not try to define their shape, because their keys can vary
|
|
192
226
|
// at runtime.
|
|
193
227
|
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
228
|
+
case 'object':
|
|
229
|
+
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
194
230
|
default:
|
|
195
231
|
// If we got here we are dealing with a non-primitive (most likely a custom class or an SObject).
|
|
196
232
|
const referencedType = TypesRepository.getInstance().getFromAllByName(typeName);
|
|
197
233
|
if (!referencedType) {
|
|
198
234
|
return { schema: { type: 'object' }, referenceComponents: [] };
|
|
199
235
|
}
|
|
200
|
-
const reference = this.buildReferenceFromType({
|
|
236
|
+
const reference = this.buildReferenceFromType({
|
|
237
|
+
...referencedType,
|
|
238
|
+
isCollection: false,
|
|
239
|
+
referenceOverrides: [],
|
|
240
|
+
originalTypeName: typeName,
|
|
241
|
+
});
|
|
201
242
|
return {
|
|
202
243
|
schema: reference.entrypointReferenceObject,
|
|
203
244
|
referenceComponents: [...reference.referenceComponents],
|
|
@@ -223,6 +264,22 @@ type SchemaObjectReferencePair = {
|
|
|
223
264
|
referenceComponents: ReferenceComponent[];
|
|
224
265
|
};
|
|
225
266
|
|
|
267
|
+
class ReferenceOverrides {
|
|
268
|
+
static build(referenceAsString: string): ReferenceOverride[] {
|
|
269
|
+
const cleanedUpReference = referenceAsString.replace(/[\[\]]/g, '');
|
|
270
|
+
const referenceStrings = cleanedUpReference.split(',').map((item) => item.replace(/\s/g, ''));
|
|
271
|
+
return referenceStrings.map((item) => {
|
|
272
|
+
const [propertyName, referenceName] = item.split(':');
|
|
273
|
+
return { propertyName, referenceName };
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
type ReferenceOverride = {
|
|
279
|
+
propertyName: string;
|
|
280
|
+
referenceName: string;
|
|
281
|
+
};
|
|
282
|
+
|
|
226
283
|
/**
|
|
227
284
|
* In case where the Request Body contains a reference, this contains information about the handled reference
|
|
228
285
|
*/
|
|
@@ -17,7 +17,7 @@ it('should add an endpoint when there is an HTTP method', function () {
|
|
|
17
17
|
|
|
18
18
|
expect(openApi.paths[urlEndpoint]).not.toHaveProperty('get');
|
|
19
19
|
|
|
20
|
-
new MethodParser(openApi).parseMethod(classWithGetMethod, urlEndpoint, 'get');
|
|
20
|
+
new MethodParser(openApi).parseMethod(classWithGetMethod, urlEndpoint, 'get', '');
|
|
21
21
|
|
|
22
22
|
expect(openApi.paths[urlEndpoint]).toHaveProperty('get');
|
|
23
23
|
});
|
|
@@ -37,7 +37,7 @@ it('should add an endpoint with a description when the method has an ApexDoc', f
|
|
|
37
37
|
const openApi = new OpenApi('Title', '1.0');
|
|
38
38
|
openApi.paths[urlEndpoint] = {};
|
|
39
39
|
|
|
40
|
-
new MethodParser(openApi).parseMethod(classWithGetMethod, urlEndpoint, 'get');
|
|
40
|
+
new MethodParser(openApi).parseMethod(classWithGetMethod, urlEndpoint, 'get', '');
|
|
41
41
|
|
|
42
42
|
expect(openApi.paths[urlEndpoint]).toHaveProperty('get');
|
|
43
43
|
expect(openApi.paths[urlEndpoint]['get']!.description).toBe('Sample Description');
|
|
@@ -623,7 +623,7 @@ describe('ReferenceBuilder', () => {
|
|
|
623
623
|
});
|
|
624
624
|
|
|
625
625
|
describe('References can override their type', () => {
|
|
626
|
-
it(
|
|
626
|
+
it('should correctly parse a reference with an overridden reference', function () {
|
|
627
627
|
const classMirror = new ClassMirrorBuilder()
|
|
628
628
|
.addFiled(
|
|
629
629
|
new FieldMirrorBuilder()
|
|
@@ -703,5 +703,49 @@ describe('ReferenceBuilder', () => {
|
|
|
703
703
|
expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
|
|
704
704
|
expect(result.referenceComponents.some((ref) => ref.referencedClass === 'grandchild')).toBe(true);
|
|
705
705
|
});
|
|
706
|
+
|
|
707
|
+
it('should correctly parse a referenced property overridden inline', function () {
|
|
708
|
+
const mainClassMirror = new ClassMirrorBuilder()
|
|
709
|
+
.withName('parent')
|
|
710
|
+
.addFiled(new FieldMirrorBuilder().withName('childClassMember').withType('Object').build())
|
|
711
|
+
.build();
|
|
712
|
+
|
|
713
|
+
const childClass = new ClassMirrorBuilder()
|
|
714
|
+
.withName('child')
|
|
715
|
+
.addFiled(
|
|
716
|
+
new FieldMirrorBuilder()
|
|
717
|
+
.withName('grandChildClassMember')
|
|
718
|
+
.withReferencedType({
|
|
719
|
+
type: 'GrandChildClass',
|
|
720
|
+
rawDeclaration: 'GrandChildClass',
|
|
721
|
+
})
|
|
722
|
+
.build(),
|
|
723
|
+
)
|
|
724
|
+
.build();
|
|
725
|
+
|
|
726
|
+
const grandChildClass = new ClassMirrorBuilder()
|
|
727
|
+
.withName('grandchild')
|
|
728
|
+
.addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
|
|
729
|
+
.build();
|
|
730
|
+
|
|
731
|
+
TypesRepository.getInstance = jest.fn().mockReturnValue({
|
|
732
|
+
getFromAllByName: jest
|
|
733
|
+
.fn()
|
|
734
|
+
.mockReturnValueOnce({ type: mainClassMirror, isChild: false })
|
|
735
|
+
.mockReturnValueOnce({ type: childClass, isChild: false })
|
|
736
|
+
.mockReturnValueOnce({ type: grandChildClass, isChild: false }),
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
const result = new ReferenceBuilder().build('className[childClassMember:ChildClass]');
|
|
740
|
+
|
|
741
|
+
expect(result.referenceComponents).toHaveLength(3);
|
|
742
|
+
expect(
|
|
743
|
+
result.referenceComponents.some(
|
|
744
|
+
(ref) => ref.referencedClass === 'parent_className[childClassMember:ChildClass]',
|
|
745
|
+
),
|
|
746
|
+
).toBe(true);
|
|
747
|
+
expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
|
|
748
|
+
expect(result.referenceComponents.some((ref) => ref.referencedClass === 'grandchild')).toBe(true);
|
|
749
|
+
});
|
|
706
750
|
});
|
|
707
751
|
});
|
package/src/util/string-utils.ts
CHANGED