@cparra/apexdocs 2.9.0-alpha.1 → 2.10.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 +313 -9
- package/docs/Main/nspc.GroupedClass.md +10 -0
- package/docs/Main/{SampleClass.md → nspc.SampleClass.md} +189 -188
- package/docs/Misc-Group/nspc.AnotherInterface.md +1 -0
- package/docs/Misc-Group/{ChildClass.md → nspc.ChildClass.md} +9 -6
- package/docs/Misc-Group/{GrandparentClass.md → nspc.GrandparentClass.md} +1 -1
- package/docs/Misc-Group/{InterfaceWithInheritance.md → nspc.InterfaceWithInheritance.md} +3 -3
- package/docs/Misc-Group/{ParentClass.md → nspc.ParentClass.md} +5 -5
- package/docs/Misc-Group/nspc.Reference1.md +18 -0
- package/docs/Misc-Group/nspc.Reference2.md +12 -0
- package/docs/Misc-Group/nspc.Reference3.md +7 -0
- package/docs/Misc-Group/nspc.Reference4.md +7 -0
- package/docs/Misc-Group/nspc.Reference5.md +7 -0
- package/docs/Misc-Group/nspc.Reference6.md +9 -0
- package/docs/Misc-Group/{SampleClassWithoutModifier.md → nspc.SampleClassWithoutModifier.md} +1 -1
- package/docs/Misc-Group/nspc.SampleRestResource.md +109 -0
- package/docs/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +37 -0
- package/docs/README.md +41 -11
- package/docs/Sample-Interfaces/{SampleInterface.md → nspc.SampleInterface.md} +1 -1
- package/docs/index.html +22 -22
- package/docs/{openapi.json → restapi.json} +12 -13
- package/examples/force-app/main/default/restapi/SampleRestResource.cls +0 -4
- package/examples/force-app/main/default/restapi/references/Reference2.cls +6 -0
- package/lib/cli/generate.js +12 -0
- package/lib/cli/generate.js.map +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-type-file.d.ts +4 -3
- package/lib/model/markdown-type-file.js +13 -4
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/apex-doc-types.d.ts +1 -0
- package/lib/model/openapi/open-api.d.ts +1 -1
- package/lib/model/openapi/open-api.js.map +1 -1
- package/lib/model/openapi/openapi-type-file.js +3 -2
- package/lib/model/openapi/openapi-type-file.js.map +1 -1
- package/lib/settings.d.ts +5 -0
- package/lib/settings.js +12 -0
- package/lib/settings.js.map +1 -1
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +2 -0
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +6 -1
- package/lib/test-helpers/DocCommentAnnotationBuilder.js.map +1 -1
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +3 -1
- package/lib/test-helpers/FieldMirrorBuilder.js +6 -0
- package/lib/test-helpers/FieldMirrorBuilder.js.map +1 -1
- package/lib/test-helpers/SettingsBuilder.js +1 -0
- package/lib/test-helpers/SettingsBuilder.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.js +2 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/openapi/open-api-docs-processor.d.ts +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js +4 -2
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.js +20 -27
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +2 -0
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +35 -5
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +5 -1
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -1
- package/package.json +6 -6
- package/src/cli/generate.ts +13 -0
- package/src/model/__tests__/manifest-diff.spec.ts +0 -3
- package/src/model/markdown-generation-util/method-declaration-util.ts +1 -1
- package/src/model/markdown-type-file.ts +14 -4
- package/src/model/openapi/apex-doc-types.ts +1 -0
- package/src/model/openapi/open-api-types.ts +2 -2
- package/src/model/openapi/open-api.ts +1 -1
- package/src/model/openapi/openapi-type-file.ts +3 -2
- package/src/service/__tests__/apex-file-reader.spec.ts +1 -0
- package/src/settings.ts +17 -0
- package/src/test-helpers/DocCommentAnnotationBuilder.ts +7 -1
- package/src/test-helpers/FieldMirrorBuilder.ts +8 -1
- package/src/test-helpers/SettingsBuilder.ts +1 -0
- package/src/transpiler/markdown/class-file-generatorHelper.ts +2 -1
- package/src/transpiler/openapi/open-api-docs-processor.ts +4 -2
- package/src/transpiler/openapi/parsers/MethodParser.ts +24 -28
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +41 -5
- package/src/transpiler/openapi/parsers/ResponsesBuilder.ts +5 -1
- package/src/transpiler/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +85 -0
- package/docs/API/SampleClassWithoutModifier.md +0 -11
- package/docs/Main/GroupedClass.md +0 -10
- package/docs/Misc-Group/AnotherInterface.md +0 -1
package/README.md
CHANGED
|
@@ -120,11 +120,14 @@ The CLI supports the following parameters:
|
|
|
120
120
|
| --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
|
|
121
121
|
| --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
|
|
122
122
|
| --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
|
|
123
|
-
| --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private
|
|
124
|
-
| --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports: `jekyll`, `docsify`,
|
|
123
|
+
| --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private. Note that this setting is ignored if generating an OpenApi REST specification since that looks for classes annotated with @RestResource. | `global` | No |
|
|
124
|
+
| --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports: `jekyll`, `docsify`, `plain-markdown`, and `openapi`. | `jekyll` | No |
|
|
125
125
|
| --indexOnly | N/A | Defines whether only the index file should be generated. | `false` | No |
|
|
126
126
|
| --defaultGroupName | N/A | Defines the `@group` name to be used when a file does not specify it. | `Miscellaneous` | No |
|
|
127
|
-
| --sanitizeHtml | N/A | When on, any special character within your ApexDocs is converted into its HTML code representation. This is specially useful when generic objects are described within the docs, e.g. "List< Foo>", "Map<Foo, Bar>" because otherwise the content within < and > would be treated as HTML tags and not shown in the output. Content in @example blocks are never sanitized. |
|
|
127
|
+
| --sanitizeHtml | N/A | When on, any special character within your ApexDocs is converted into its HTML code representation. This is specially useful when generic objects are described within the docs, e.g. "List< Foo>", "Map<Foo, Bar>" because otherwise the content within < and > would be treated as HTML tags and not shown in the output. Content in @example blocks are never sanitized. | `Apex REST Api` | No |
|
|
128
|
+
| --openApiTitle | N/A | If using "openapi" as the target generator, this allows you to specify the OpenApi title value. | true | No |
|
|
129
|
+
| --namespace | N/A | The package namespace, if any. If this value is provided the namespace will be added as a prefix to all of the parsed files. If generating an OpenApi definition, it will be added to the file's Server Url. | N/A | No |
|
|
130
|
+
| --openApiFileName | N/A | If using "openapi" as the target generator, this allows you to specify the name of the output file. | `openapi` | No |
|
|
128
131
|
|
|
129
132
|
### Importing to your project
|
|
130
133
|
|
|
@@ -276,7 +279,7 @@ Apexdocs recognizes 2 different syntax when linking files:
|
|
|
276
279
|
* @param param1 An <<ExampleClass>> instance. Can also do {@link ExampleClass}
|
|
277
280
|
* @return The result of the operation.
|
|
278
281
|
*/
|
|
279
|
-
public static Object
|
|
282
|
+
public static Object doSomething(ExampleClass param1) {}
|
|
280
283
|
```
|
|
281
284
|
|
|
282
285
|
---
|
|
@@ -285,7 +288,7 @@ Email addresses can also be inlined linked by using the `{@email EMAIL_ADDRESS}`
|
|
|
285
288
|
|
|
286
289
|
### HTML support
|
|
287
290
|
|
|
288
|
-
For the most part all HTML is sanitized when the `--sanitizeHtml` flag is passed a true value (which is the default).
|
|
291
|
+
For the most part all HTML is sanitized when the `--sanitizeHtml` flag is passed a true value (which is the default).
|
|
289
292
|
But there are some tags are allowed to have for the possibility of better
|
|
290
293
|
styling long text.
|
|
291
294
|
|
|
@@ -306,8 +309,10 @@ class MyClass {
|
|
|
306
309
|
}
|
|
307
310
|
```
|
|
308
311
|
|
|
309
|
-
⚠️When the `--sanitizeHtml` flag is ON, any special character between code blocks (i.e. \```, \`, or `<code>`) will also
|
|
310
|
-
|
|
312
|
+
⚠️When the `--sanitizeHtml` flag is ON, any special character between code blocks (i.e. \```, \`, or `<code>`) will also
|
|
313
|
+
be escaped.
|
|
314
|
+
So if you have references to Apex generic collections (Set, List, or Maps) they will not look right, as the < and >
|
|
315
|
+
symbols will be escaped.
|
|
311
316
|
To prevent this you can turn the flag off, but be aware of the special considerations when doing this described below.
|
|
312
317
|
|
|
313
318
|
---
|
|
@@ -316,12 +321,311 @@ For full control over the output you can also turn off the `--sanitizeHtml` flag
|
|
|
316
321
|
to have any desired HTML within your docs.
|
|
317
322
|
|
|
318
323
|
⚠️When the `--sanitizeHtml` flag is OFF, references to Apex generic collections (Set, List or Maps) can be problematic
|
|
319
|
-
as they will be treated as an HTML tag and not displayed. For example if you have something
|
|
324
|
+
as they will be treated as an HTML tag and not displayed. For example if you have something
|
|
325
|
+
like `@description Returns a List<String>`
|
|
320
326
|
the `<String>` portion will be treated as HTML and thus not appear on the page.
|
|
321
327
|
|
|
322
|
-
To fix this issue, when not sanitizing HTML, you should wrap any code that contain special characters that can be
|
|
328
|
+
To fix this issue, when not sanitizing HTML, you should wrap any code that contain special characters that can be
|
|
329
|
+
treated as HTML within '\`'
|
|
323
330
|
or within `<code>` tags.
|
|
324
331
|
|
|
332
|
+
## Generating OpenApi REST Definitions
|
|
333
|
+
|
|
334
|
+
ApexDocs supports generating OpenApi 3.1.0 REST definitions based on any `@RestResource` classes in your source code.
|
|
335
|
+
|
|
336
|
+
### Usage
|
|
337
|
+
|
|
338
|
+
To create an OpenApi specification file, run the `apexdocs-generate` and pass `openapi` to the `--targetGenerator` parameter.
|
|
339
|
+
When using this generator, you can also pass a custom title through the `--openApiTitle` parameter. This title will be placed
|
|
340
|
+
in the output file's `info.title` property, as defined by the [OpenApi documentation for the Info Object](https://spec.openapis.org/oas/v3.1.0#info-object)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
```shell
|
|
344
|
+
apexdocs-generate -s ./src -t docs -g openapi --openApiTitle "Custom OpenApi Title"
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### How It Works
|
|
348
|
+
|
|
349
|
+
When generating an OpenApi document, since `@RestResource` classes need to be global in Apex, the `--scope` parameter will be ignored.
|
|
350
|
+
Instead, ApexDocs will run through all classes annotated with `@RestResource` and add it to the output OpenApi file.
|
|
351
|
+
|
|
352
|
+
Once it finishes running, a file named `openapi.json` will be created in the specified `--targetDir`.
|
|
353
|
+
|
|
354
|
+
### Configuring What Gets Created
|
|
355
|
+
|
|
356
|
+
ApexDocs will automatically parse your source code and generate the OpenApi definition based on the HTTP related Apex
|
|
357
|
+
annotations (RestResource, HttpDelete, HttpGet, HttpPatch, HttpPost, HttpGet). The different HTTP annotations will be used to generate a file that complies with the [OpenApi Specification v3.1.0](https://spec.openapis.org/oas/v3.1.0)
|
|
358
|
+
|
|
359
|
+
Besides these annotations, the ApexDocs tool will also use any information provided through your code's Apexdocs, relying on
|
|
360
|
+
some custom annotations that are specific to generating OpenApi definitions:
|
|
361
|
+
|
|
362
|
+
* `@http-request-body`
|
|
363
|
+
* `@http-parameter`
|
|
364
|
+
* `@http-response`
|
|
365
|
+
|
|
366
|
+
#### @http-request-body
|
|
367
|
+
|
|
368
|
+
Allows you to specify the HTTP request's expected request body. It supports receiving a `description`,
|
|
369
|
+
whether it is `required` or not, and a `schema`, which defines the shape of the object that is expected.
|
|
370
|
+
|
|
371
|
+
📝 Note that only one `@http-request-body` should be defined per method. If you add more than one, only
|
|
372
|
+
a single one will be used when generating the OpenApi definition.
|
|
373
|
+
|
|
374
|
+
The `schema` can either be a reference to another class in your source code (see the `Class References` section below)
|
|
375
|
+
or a fully defined custom schema (See the `Custom Schemas` section below).
|
|
376
|
+
|
|
377
|
+
Example
|
|
378
|
+
```apex
|
|
379
|
+
/**
|
|
380
|
+
* @description This is a sample HTTP Post method
|
|
381
|
+
* @http-request-body
|
|
382
|
+
* description: This is an example of a request body
|
|
383
|
+
* required: true
|
|
384
|
+
* schema: ClassName
|
|
385
|
+
*/
|
|
386
|
+
@HttpPost
|
|
387
|
+
global static void doPost() {
|
|
388
|
+
///...
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
|
|
393
|
+
so spacing is important.
|
|
394
|
+
|
|
395
|
+
#### @http-parameter
|
|
396
|
+
|
|
397
|
+
Allows you to specify any HTTP parameter expected by your method. It supports receiving a `name`,
|
|
398
|
+
an `in` as defined by the supported [Parameter Locations](https://spec.openapis.org/oas/v3.1.0#parameter-locations),
|
|
399
|
+
whether it is `required` or not, a `description`, and a `schema`.
|
|
400
|
+
|
|
401
|
+
📝 Note that you can specify as many `@http-parameter` annotations as needed.
|
|
402
|
+
|
|
403
|
+
Example
|
|
404
|
+
```apex
|
|
405
|
+
/**
|
|
406
|
+
* @description This is a sample HTTP Post method
|
|
407
|
+
* @return A String SObject.
|
|
408
|
+
* @http-parameter
|
|
409
|
+
* name: limit
|
|
410
|
+
* in: query
|
|
411
|
+
* required: true
|
|
412
|
+
* description: Limits the number of items on a page
|
|
413
|
+
* schema:
|
|
414
|
+
* type: integer
|
|
415
|
+
* @http-parameter
|
|
416
|
+
* name: complex
|
|
417
|
+
* in: cookie
|
|
418
|
+
* schema: MyClassName
|
|
419
|
+
*/
|
|
420
|
+
@HttpPost
|
|
421
|
+
global static String doPost() {
|
|
422
|
+
// ..
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
|
|
427
|
+
so spacing is important.
|
|
428
|
+
|
|
429
|
+
#### @http-response
|
|
430
|
+
|
|
431
|
+
Allows you to specify any HTTP response returned by your method. It supports receiving a `statusCode` with the response code,
|
|
432
|
+
a `description`, and a `schema`.
|
|
433
|
+
|
|
434
|
+
If no `description` is provided then one will be automatically built using the `statusCode`.
|
|
435
|
+
|
|
436
|
+
📝 Note that you can specify as many `@http-parameter` annotations as needed.
|
|
437
|
+
|
|
438
|
+
```apex
|
|
439
|
+
/**
|
|
440
|
+
* @description This is a sample HTTP Post method
|
|
441
|
+
* @return A String SObject.
|
|
442
|
+
* @http-response
|
|
443
|
+
* statusCode: 200
|
|
444
|
+
* schema: SuccessfulResponseClassName
|
|
445
|
+
* @http-response
|
|
446
|
+
* statusCode: 500
|
|
447
|
+
* description: Status Code 500 - An internal server error occurred.
|
|
448
|
+
* schema:
|
|
449
|
+
* type: string
|
|
450
|
+
*/
|
|
451
|
+
@HttpPost
|
|
452
|
+
global static String doPost() {
|
|
453
|
+
// ...
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### Class References
|
|
458
|
+
|
|
459
|
+
Whenever specifying a `schema` parameter, you can pass as a string the name of any class in your source code. This
|
|
460
|
+
class will be parsed by the ApexDocs tool and automatically converted to a reference in the resulting OpenApi definition.
|
|
461
|
+
|
|
462
|
+
The tool will parse the class and create a reference that complies with [Apex's support for User-Defined Types](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm#ApexRESTUserDefinedTypes)
|
|
463
|
+
|
|
464
|
+
##### Reference Overrides
|
|
465
|
+
|
|
466
|
+
When dealing with references, there might be cases when you want to manually tell the parser what type of object a property
|
|
467
|
+
or field is. For example, let's say we have a class that looks as follows
|
|
468
|
+
|
|
469
|
+
```apex
|
|
470
|
+
public class MyClass {
|
|
471
|
+
public Object myObject;
|
|
472
|
+
public Account myAccountRecord;
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
In this case `myObject` has a type of `Object`, and `myAccountRecord` is an SObject. Neither of these will be accurately
|
|
477
|
+
parsed when building the OpenApi definition, instead they will be simple be referenced as `object` without any properties.
|
|
478
|
+
|
|
479
|
+
To accurately represent the shape of these objects, you can use the `@http-schema` annotation to essentially override its
|
|
480
|
+
type during parsing. In this annotation you can specify the same thing you would in any `schema` property when dealing with any
|
|
481
|
+
of the main `@http-*` methods, meaning a reference to another class, or a Custom Schema (as defined below).
|
|
482
|
+
|
|
483
|
+
```apex
|
|
484
|
+
public class MyClass {
|
|
485
|
+
/**
|
|
486
|
+
* @description This is a generic reference to another class
|
|
487
|
+
* @http-schema MyOtherClassName
|
|
488
|
+
*/
|
|
489
|
+
public Object myObject;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @description This is a reference to an Account SObject
|
|
493
|
+
* @http-schema
|
|
494
|
+
* type: object
|
|
495
|
+
* properties:
|
|
496
|
+
* Id:
|
|
497
|
+
* type: string
|
|
498
|
+
* Name:
|
|
499
|
+
* type: string
|
|
500
|
+
* CustomField__c:
|
|
501
|
+
* type: number
|
|
502
|
+
*/
|
|
503
|
+
public Account myAccountRecord;
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
If dealing with a collection, you can also specify the name of the reference either using the `List` or `Set` syntax.
|
|
510
|
+
|
|
511
|
+
📝 When using List or Set syntax in the `schema` of the ApexDoc `@http-*` annotation, only collections one level
|
|
512
|
+
deep are supported (e.g. List<List<String>> is not supported). This is only a limitation when referencing collections
|
|
513
|
+
on the ApexDoc `schema` property directly, and is fully supported when multi-level collections are inside of a referenced
|
|
514
|
+
class as part of your codebase.
|
|
515
|
+
|
|
516
|
+
Maps are not supported, as it is not possible to know which keys the map will contain, and thus it is not possible
|
|
517
|
+
to convert that to a valid specification. For this use case, define a Custom Schema as explained below.
|
|
518
|
+
|
|
519
|
+
```apex
|
|
520
|
+
/**
|
|
521
|
+
* @description This is a sample HTTP Post method
|
|
522
|
+
* @http-request-body
|
|
523
|
+
* description: This is an example of a request body
|
|
524
|
+
* schema: List<ClassName>
|
|
525
|
+
*/
|
|
526
|
+
@HttpPost
|
|
527
|
+
global static void doPost() {
|
|
528
|
+
///...
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
Inner class references are also supported, but note that you need to pass the full name of the reference,
|
|
533
|
+
by using the `ParentClassName.InnerClassName` syntax, even if the inner class resides on the same class as the HTTP method
|
|
534
|
+
referencing it.
|
|
535
|
+
|
|
536
|
+
```apex
|
|
537
|
+
/**
|
|
538
|
+
* @description This is a sample HTTP Post method
|
|
539
|
+
* @http-request-body
|
|
540
|
+
* description: This is an example of a request body
|
|
541
|
+
* schema: ParentClass.InnerClass
|
|
542
|
+
*/
|
|
543
|
+
@HttpPost
|
|
544
|
+
global static void doPost() {
|
|
545
|
+
///...
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
#### Custom Schemas
|
|
550
|
+
|
|
551
|
+
For any `schema` parameter in any of the HTTP ApexDocs annotations, besides specifying the name of a class, you
|
|
552
|
+
can also specify a custom schema definition. The schema definition can either be for a primitive type, an `object` or an `array`
|
|
553
|
+
|
|
554
|
+
**Primitives**
|
|
555
|
+
|
|
556
|
+
For primitives, you should specify the `type` and an optional `format`, as defined by the [OpenApi Specification on Data Types](https://spec.openapis.org/oas/v3.1.0#data-types)
|
|
557
|
+
|
|
558
|
+
```apex
|
|
559
|
+
/**
|
|
560
|
+
* ...
|
|
561
|
+
* schema:
|
|
562
|
+
* type: string
|
|
563
|
+
* format: password
|
|
564
|
+
*/
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**Objects**
|
|
568
|
+
|
|
569
|
+
To specify a custom object schema, use `object` as the `type`, and specify as many properties as follows:
|
|
570
|
+
|
|
571
|
+
```apex
|
|
572
|
+
/**
|
|
573
|
+
* schema:
|
|
574
|
+
* type: object
|
|
575
|
+
* properties:
|
|
576
|
+
* id:
|
|
577
|
+
* type: string
|
|
578
|
+
* description: The super Id.
|
|
579
|
+
* name:
|
|
580
|
+
* type: string
|
|
581
|
+
* phone:
|
|
582
|
+
* type: string
|
|
583
|
+
* format: byte
|
|
584
|
+
*/
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Properties can be defined as primitives (as explained above), other objects, or arrays (explained below)
|
|
588
|
+
|
|
589
|
+
**Arrays**
|
|
590
|
+
|
|
591
|
+
To specify a custom array schema, use `array` as the `type`, and provide an `items` definition. In `items`
|
|
592
|
+
you can specify the definition of any other custom type (primitives, objects, or other arrays).
|
|
593
|
+
|
|
594
|
+
```apex
|
|
595
|
+
/**
|
|
596
|
+
* schema:
|
|
597
|
+
* type: array
|
|
598
|
+
* items:
|
|
599
|
+
* type: object
|
|
600
|
+
* properties:
|
|
601
|
+
* name:
|
|
602
|
+
* type: string
|
|
603
|
+
*/
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
#### SObject References
|
|
607
|
+
|
|
608
|
+
ApexDocs is not able to automatically parse SObject references, as it can with class references, as it does
|
|
609
|
+
not reach into your org to get existing SObject describes. Because of this, when dealing with SObject references
|
|
610
|
+
you should create a Custom Schema as defined above. This will also allow you to specify which specific
|
|
611
|
+
fields are being received or returned.
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
### Considerations
|
|
615
|
+
|
|
616
|
+
Please be aware of the following when using ApexDocs to create an OpenApi definition:
|
|
617
|
+
|
|
618
|
+
* Map references are resolved as `object` with no properties, as it is not possible to know which keys the map will contain.
|
|
619
|
+
When using maps either create a class that better represents the shape of the object and use a Class Reference, or
|
|
620
|
+
define a Custom Schema in the `schema` section of the ApexDoc itself.
|
|
621
|
+
* Same thing when referencing SObjects, as SObject describe parsing is not supported by the ApexDocs tool. When referencing
|
|
622
|
+
SObjects, consider defining a Custom Schema in the `schema` section of the ApexDoc.
|
|
623
|
+
* ApexDoc is only able to parse through your source code, so references to other packages (namespaced classes) or any
|
|
624
|
+
code that lives outside your source code is not supported. Consider creating a Custom Schema for those situations.
|
|
625
|
+
* The return value and received parameters or your methods are currently not being considered when creating the OpenApi definition file.
|
|
626
|
+
Instead, use the `@http-response` ApexDoc annotation to specify the return value, and `@http-parameter` to specify any
|
|
627
|
+
expected parameter.
|
|
628
|
+
|
|
325
629
|
## Typescript
|
|
326
630
|
|
|
327
631
|
ApexDocs provides all necessary type definitions.
|