Skip to content

Commit b7f5dff

Browse files
authored
Merge pull request #68 from cesarParra/2.13_rc
2 parents 0be946d + 1546b7f commit b7f5dff

25 files changed

+380
-68
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ the [Java based ApexDoc tool](https://github.com/SalesforceFoundation/ApexDoc) o
1313
later maintained by Salesforce.org, as that tool is no longer being maintained.
1414

1515
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 docGenerator a set of files that fully document each one of you classes.
16+
It offers CLI capabilities to automatically document your source code, based on the ApexDoc style of documentation.
1717
Additionally, it can be imported and consumed directly by your JavaScript code.
1818

1919
There are some key differences between ApexDocs and the Java based ApexDoc tool:
@@ -71,7 +71,10 @@ public class MyClass {
7171
* Apex docs blocks can now all be in a single line
7272
* Support for grouping blocks of related code within a class
7373
* Support for HTML tags
74-
* And more!
74+
* OpenApi REST specification generation
75+
* Support for ignoring files and members from being documented
76+
* Namespace support
77+
* And much, much more!
7578

7679
### Demo
7780

@@ -329,6 +332,23 @@ To fix this issue, when not sanitizing HTML, you should wrap any code that conta
329332
treated as HTML within '\`'
330333
or within `<code>` tags.
331334

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+
332352
## Generating OpenApi REST Definitions
333353

334354
ApexDocs supports generating OpenApi 3.1.0 REST definitions based on any `@RestResource` classes in your source code.

docs/Misc-Group/nspc.Reference7.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# nspc.Reference7
2+
## Fields
3+
4+
### `untypedObject``Object`
5+
6+
7+
---

docs/Misc-Group/nspc.SampleRestResource.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Sample HTTP Delete method with references to other types.
2929

3030
**Http Response** statusCode: 306 schema: List&lt;Reference1&gt;
3131

32+
33+
**Http Response** statusCode: 307 schema: Reference7[untypedObject:Reference2]
34+
3235
### `static doGet()`
3336

3437
`HTTPGET`
@@ -83,6 +86,9 @@ String
8386
A String SObject.
8487

8588

89+
**Summary** Posts an Account 2
90+
91+
8692
**Http Parameter** name: limit in: query required: true description: Limits the number of items on a page schema: type: integer
8793

8894

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
### [nspc.Reference6](/Misc-Group/nspc.Reference6.md)
3838

3939

40+
### [nspc.Reference7](/Misc-Group/nspc.Reference7.md)
41+
42+
4043
### [nspc.SampleClassWithoutModifier](/Misc-Group/nspc.SampleClassWithoutModifier.md)
4144

4245

docs/restapi.json

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
}
1111
],
1212
"paths": {
13-
"/Account/": {
13+
"AccountService/": {
1414
"description": "Account related operations",
1515
"get": {
16+
"tags": [
17+
"Account Service"
18+
],
1619
"description": "This is a sample HTTP Get method",
1720
"parameters": [
1821
{
@@ -135,7 +138,11 @@
135138
}
136139
},
137140
"post": {
141+
"tags": [
142+
"Account Service"
143+
],
138144
"description": "This is a sample HTTP Post method",
145+
"summary": "Posts an Account 2",
139146
"requestBody": {
140147
"description": "This is an example of a request body",
141148
"content": {
@@ -252,6 +259,9 @@
252259
}
253260
},
254261
"delete": {
262+
"tags": [
263+
"Account Service"
264+
],
255265
"description": "Sample HTTP Delete method with references to other types.",
256266
"parameters": [
257267
{
@@ -305,6 +315,16 @@
305315
}
306316
}
307317
},
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+
},
308328
"500": {
309329
"description": "Status code 500",
310330
"content": {
@@ -318,9 +338,12 @@
318338
}
319339
}
320340
},
321-
"/Contact/": {
341+
"Contact/": {
322342
"description": "Contact related operations",
323343
"get": {
344+
"tags": [
345+
"Contact"
346+
],
324347
"description": "This is a sample HTTP Get method",
325348
"responses": {
326349
"200": {
@@ -336,9 +359,12 @@
336359
}
337360
}
338361
},
339-
"/Order/": {
362+
"Order/": {
340363
"description": "Order related operations",
341364
"get": {
365+
"tags": [
366+
"Order"
367+
],
342368
"requestBody": {
343369
"content": {
344370
"application/json": {
@@ -370,6 +396,9 @@
370396
}
371397
},
372398
"patch": {
399+
"tags": [
400+
"Order"
401+
],
373402
"requestBody": {
374403
"content": {
375404
"application/json": {
@@ -402,6 +431,20 @@
402431
}
403432
}
404433
},
434+
"tags": [
435+
{
436+
"name": "Account Service",
437+
"description": "Account related operations"
438+
},
439+
{
440+
"name": "Contact",
441+
"description": "Contact related operations"
442+
},
443+
{
444+
"name": "Order",
445+
"description": "Order related operations"
446+
}
447+
],
405448
"components": {
406449
"schemas": {
407450
"SampleClass": {
@@ -525,6 +568,14 @@
525568
"$ref": "#/components/schemas/Reference1"
526569
}
527570
},
571+
"Reference7_Reference7[untypedObject:Reference2]": {
572+
"type": "object",
573+
"properties": {
574+
"untypedObject": {
575+
"$ref": "#/components/schemas/Reference2"
576+
}
577+
}
578+
},
528579
"SampleRestResourceWithInnerClass.InnerClass": {
529580
"type": "object",
530581
"properties": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
public interface AnotherInterface{}
1+
public interface AnotherInterface{}

examples/force-app/main/default/restapi/SampleRestResource.cls

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @description Account related operations
33
*/
4-
@RestResource(urlMapping='/Account/*')
4+
@RestResource(UrlMapping='/AccountService/*')
55
global with sharing class SampleRestResource {
66
/**
77
* @description Sample HTTP Delete method with references to other types.
@@ -26,6 +26,9 @@ global with sharing class SampleRestResource {
2626
* @http-response
2727
* statusCode: 306
2828
* schema: List<Reference1>
29+
* @http-response
30+
* statusCode: 307
31+
* schema: Reference7[untypedObject:Reference2]
2932
*/
3033
@HttpDelete
3134
global static void doDelete() {
@@ -114,6 +117,7 @@ global with sharing class SampleRestResource {
114117
}
115118

116119
/**
120+
* @summary Posts an Account 2
117121
* @description This is a sample HTTP Post method
118122
* @return A String SObject.
119123
* @http-parameter
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class Reference7 {
2+
public Object untypedObject;
3+
}

package-lock.json

Lines changed: 34 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)