@cparra/apexdocs 3.0.0-rc.0 → 3.1.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 +61 -576
- package/dist/cli/generate.js +73 -3094
- package/dist/defaults-BcE8DTat.js +13 -0
- package/dist/defaults-D07y_bq4.js +40 -0
- package/dist/defaults-gPzwP66p.js +14 -0
- package/dist/index.d.ts +35 -3
- package/dist/index.js +90 -2
- package/dist/logger-BEbUIfqN.js +3282 -0
- package/dist/logger-BGuf1PnL.js +3281 -0
- package/dist/logger-CWBRF2za.js +3284 -0
- package/dist/logger-CdBmDEN1.js +3283 -0
- package/dist/logger-Ce4QqPFR.js +3278 -0
- package/dist/logger-CyEVYaAC.js +3284 -0
- package/dist/logger-D7a83ycP.js +3277 -0
- package/dist/logger-DGaHeBKk.js +3279 -0
- package/dist/logger-Dqhl_lO_.js +3278 -0
- package/dist/logger-aySSWi0G.js +3280 -0
- package/dist/logger-qLCcAtiy.js +3284 -0
- package/package.json +5 -2
- package/.github/workflows/ci.yaml +0 -22
- package/.github/workflows/close_stale.yml +0 -22
- package/.prettierrc.js +0 -7
- package/__mocks__/chalk.js +0 -12
- package/__mocks__/log-update.js +0 -6
- package/eslint.config.mjs +0 -10
- package/examples/markdown/.forceignore +0 -12
- package/examples/markdown/config/project-scratch-def.json +0 -5
- package/examples/markdown/docs/index.md +0 -109
- package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
- package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
- package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
- package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
- package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
- package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/markdown/docs/miscellaneous/Url.md +0 -311
- package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
- package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
- package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
- package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
- package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
- package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
- package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
- package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
- package/examples/markdown/force-app/classes/SampleException.cls +0 -17
- package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
- package/examples/markdown/force-app/classes/Url.cls +0 -196
- package/examples/markdown/package-lock.json +0 -665
- package/examples/markdown/package.json +0 -20
- package/examples/markdown/sfdx-project.json +0 -12
- package/examples/markdown-jsconfig/.forceignore +0 -12
- package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -21
- package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
- package/examples/markdown-jsconfig/docs/index.md +0 -12
- package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
- package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
- package/examples/markdown-jsconfig/package-lock.json +0 -665
- package/examples/markdown-jsconfig/package.json +0 -15
- package/examples/markdown-jsconfig/sfdx-project.json +0 -12
- package/examples/open-api/config/project-scratch-def.json +0 -13
- package/examples/open-api/docs/openapi.json +0 -582
- package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
- package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
- package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
- package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
- package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
- package/examples/open-api/package-lock.json +0 -724
- package/examples/open-api/package.json +0 -20
- package/examples/open-api/sfdx-project.json +0 -12
- package/examples/vitepress/.forceignore +0 -12
- package/examples/vitepress/apexdocs.config.ts +0 -111
- package/examples/vitepress/config/project-scratch-def.json +0 -13
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/config.mts +0 -21
- package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
- package/examples/vitepress/docs/api-examples.md +0 -49
- package/examples/vitepress/docs/index-frontmatter.md +0 -16
- package/examples/vitepress/docs/index.md +0 -56
- package/examples/vitepress/docs/markdown-examples.md +0 -85
- package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
- package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
- package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
- package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
- package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
- package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
- package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
- package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +0 -72
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +0 -30
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +0 -17
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +0 -46
- package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
- package/examples/vitepress/package-lock.json +0 -2574
- package/examples/vitepress/package.json +0 -18
- package/examples/vitepress/sfdx-project.json +0 -12
- package/jest.config.js +0 -10
- package/jest.d.ts +0 -7
- package/src/application/Apexdocs.ts +0 -72
- package/src/application/__tests__/apex-file-reader.spec.ts +0 -87
- package/src/application/apex-file-reader.ts +0 -55
- package/src/application/file-system.ts +0 -69
- package/src/application/file-writer.ts +0 -43
- package/src/application/generators/markdown.ts +0 -45
- package/src/application/generators/openapi.ts +0 -71
- package/src/cli/args.ts +0 -46
- package/src/cli/commands/markdown.ts +0 -51
- package/src/cli/commands/openapi.ts +0 -36
- package/src/cli/generate.ts +0 -16
- package/src/core/__test__/manifest.spec.ts +0 -16
- package/src/core/manifest.ts +0 -90
- package/src/core/markdown/__test__/expect-extensions.ts +0 -32
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -605
- package/src/core/markdown/__test__/generating-docs.spec.ts +0 -111
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -321
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -397
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -180
- package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
- package/src/core/markdown/__test__/test-helpers.ts +0 -23
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -148
- package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
- package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
- package/src/core/markdown/adapters/apex-types.ts +0 -238
- package/src/core/markdown/adapters/documentables.ts +0 -115
- package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
- package/src/core/markdown/adapters/generate-link.ts +0 -82
- package/src/core/markdown/adapters/inline.ts +0 -143
- package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
- package/src/core/markdown/adapters/reference-guide.ts +0 -37
- package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
- package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -89
- package/src/core/markdown/adapters/type-utils.ts +0 -13
- package/src/core/markdown/adapters/types.d.ts +0 -180
- package/src/core/markdown/generate-docs.ts +0 -212
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -306
- package/src/core/markdown/reflection/filter-scope.ts +0 -13
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
- package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
- package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
- package/src/core/markdown/reflection/reflect-source.ts +0 -123
- package/src/core/markdown/reflection/sort-members.ts +0 -59
- package/src/core/markdown/templates/class-template.ts +0 -75
- package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
- package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
- package/src/core/markdown/templates/enum-template.ts +0 -12
- package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
- package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
- package/src/core/markdown/templates/hookable.ts +0 -7
- package/src/core/markdown/templates/interface-template.ts +0 -16
- package/src/core/markdown/templates/methods-partial-template.ts +0 -43
- package/src/core/markdown/templates/reference-guide.ts +0 -14
- package/src/core/markdown/templates/template.ts +0 -114
- package/src/core/markdown/templates/type-doc-partial.ts +0 -27
- package/src/core/markdown/utils.ts +0 -3
- package/src/core/openApiSettings.ts +0 -41
- package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
- package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -56
- package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
- package/src/core/openapi/apex-doc-types.ts +0 -26
- package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
- package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
- package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
- package/src/core/openapi/file-container.ts +0 -13
- package/src/core/openapi/manifest-factory.ts +0 -16
- package/src/core/openapi/open-api-docs-processor.ts +0 -93
- package/src/core/openapi/open-api-types.ts +0 -119
- package/src/core/openapi/open-api.ts +0 -45
- package/src/core/openapi/openapi-type-file.ts +0 -12
- package/src/core/openapi/parser.ts +0 -160
- package/src/core/openapi/parsers/Builder.ts +0 -40
- package/src/core/openapi/parsers/MethodParser.ts +0 -249
- package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
- package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
- package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
- package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
- package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
- package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
- package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
- package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
- package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
- package/src/core/openapi/transpiler.ts +0 -17
- package/src/core/openapi/types-repository.ts +0 -54
- package/src/core/parse-apex-metadata.ts +0 -30
- package/src/core/shared/types.d.ts +0 -148
- package/src/core/shared/utils.ts +0 -5
- package/src/defaults.ts +0 -9
- package/src/index.ts +0 -49
- package/src/test-helpers/AnnotationBuilder.ts +0 -29
- package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
- package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
- package/src/test-helpers/DocCommentBuilder.ts +0 -36
- package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
- package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
- package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
- package/src/test-helpers/SettingsBuilder.ts +0 -17
- package/src/util/error-logger.ts +0 -92
- package/src/util/fp.ts +0 -3
- package/src/util/logger.ts +0 -44
- package/src/util/string-utils.ts +0 -7
- package/tsconfig.json +0 -25
- package/tslint.json +0 -6
package/README.md
CHANGED
|
@@ -74,22 +74,24 @@ Here are some live projects using ApexDocs:
|
|
|
74
74
|
|
|
75
75
|
## ▶️ Available Commands
|
|
76
76
|
|
|
77
|
+
### Markdown
|
|
78
|
+
|
|
77
79
|
`markdown`
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
#### Flags
|
|
80
82
|
|
|
81
|
-
| Flag
|
|
82
|
-
|
|
83
|
-
| `--sourceDir`
|
|
84
|
-
| `--targetDir`
|
|
85
|
-
| `--scope`
|
|
86
|
-
| `--defaultGroupName`
|
|
87
|
-
| `--namespace`
|
|
88
|
-
| `--
|
|
89
|
-
| `--includeMetadata `
|
|
90
|
-
| `--linkingStrategy`
|
|
83
|
+
| Flag | Alias | Description | Default | Required |
|
|
84
|
+
|------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|----------|
|
|
85
|
+
| `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
|
|
86
|
+
| `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
|
|
87
|
+
| `--scope` | `-p` | A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. | `global` | No |
|
|
88
|
+
| `--defaultGroupName` | N/A | The default group name to use when a group is not specified. | `Miscellaneous` | No |
|
|
89
|
+
| `--namespace` | N/A | The package namespace, if any. If provided, it will be added to the generated files. | N/A | No |
|
|
90
|
+
| `--sortAlphabetically` | N/A | Sorts files appearing in the Reference Guide alphabetically, as well as the members of a class, interface or enum alphabetically. If false, the members will be displayed in the same order as the code. | `false` | No |
|
|
91
|
+
| `--includeMetadata ` | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | `false` | No |
|
|
92
|
+
| `--linkingStrategy` | N/A | The strategy to use when linking to other classes. Possible values are `relative`, `no-link`, and `none` | `relative` | No |
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
##### Linking Strategy
|
|
93
95
|
|
|
94
96
|
The linking strategy determines how ApexDocs will link to other classes in your documentation. For example,
|
|
95
97
|
if I have class `A` that links through class `B` (e.g. through an `{@link B}` tag, the `@see` tag,
|
|
@@ -115,15 +117,19 @@ Does not apply any kind of logic. Instead, the links will be determined by the p
|
|
|
115
117
|
from the root of the documentation site OR by whatever path you have returned in the `transformReference` hook
|
|
116
118
|
for the file.
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
#### Sample Usage
|
|
119
121
|
|
|
120
122
|
```bash
|
|
121
123
|
apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n MyNamespace
|
|
122
124
|
```
|
|
123
125
|
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### OpenApi
|
|
129
|
+
|
|
124
130
|
`openapi`
|
|
125
131
|
|
|
126
|
-
|
|
132
|
+
#### Flags
|
|
127
133
|
|
|
128
134
|
| Flag | Alias | Description | Default | Required |
|
|
129
135
|
|----------------|-------|-------------------------------------------------------------------------------|-----------------|----------|
|
|
@@ -134,7 +140,7 @@ apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n M
|
|
|
134
140
|
| `--title` | N/A | The title of the OpenApi file. | `Apex REST API` | No |
|
|
135
141
|
| `--apiVersion` | N/A | The version of the API. | `1.0.0` | No |
|
|
136
142
|
|
|
137
|
-
|
|
143
|
+
#### Sample Usage
|
|
138
144
|
|
|
139
145
|
```bash
|
|
140
146
|
apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi Title"
|
|
@@ -181,7 +187,8 @@ CLI will be used, or the default value will be used.
|
|
|
181
187
|
|
|
182
188
|
### Config Intellisense
|
|
183
189
|
|
|
184
|
-
Using the `defineMarkdownConfig`
|
|
190
|
+
Using the `defineMarkdownConfig` (or the `defineOpenApiConfig` for OpenApi documentation)
|
|
191
|
+
helper will provide Typescript-powered intellisense
|
|
185
192
|
for the configuration file options. This should work with both Javascript and Typescript files.
|
|
186
193
|
|
|
187
194
|
```typescript
|
|
@@ -195,6 +202,23 @@ export default defineMarkdownConfig({
|
|
|
195
202
|
});
|
|
196
203
|
```
|
|
197
204
|
|
|
205
|
+
### Excluding Tags from Appearing in the Documentation
|
|
206
|
+
|
|
207
|
+
You can exclude tags from appearing in the documentation by using the `excludeTags` property in the configuration file,
|
|
208
|
+
which allow you to pass a list of tags that you want to exclude from the documentation.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { defineMarkdownConfig } from "@cparra/apexdocs";
|
|
212
|
+
|
|
213
|
+
export default defineMarkdownConfig({
|
|
214
|
+
sourceDir: 'force-app',
|
|
215
|
+
targetDir: 'docs',
|
|
216
|
+
scope: ['global', 'public'],
|
|
217
|
+
excludeTags: ['internal', 'ignore'],
|
|
218
|
+
...
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
198
222
|
### Configuration Hooks
|
|
199
223
|
|
|
200
224
|
When defining a `.js` or `.ts` configuration file, your object export can also make use
|
|
@@ -318,579 +342,40 @@ export default {
|
|
|
318
342
|
|
|
319
343
|
## ⤵︎ Importing to your project
|
|
320
344
|
|
|
345
|
+
### Reflection
|
|
346
|
+
|
|
321
347
|
If you are just interested in the Apex parsing capabilities, you can use the
|
|
322
348
|
standalone [Apex Reflection Library](https://www.npmjs.com/package/@cparra/apex-reflection)
|
|
323
349
|
which is what gets used by this library behind the scenes to generate the documentation files.
|
|
324
350
|
|
|
325
|
-
###
|
|
326
|
-
|
|
327
|
-
If using Typescript, ApexDocs provides all necessary type definitions.
|
|
328
|
-
|
|
329
|
-
## 📖 Documentation Guide
|
|
330
|
-
|
|
331
|
-
ApexDocs picks up blocks of comments throughout your `.cls` files. The block must begin with `/**` and end with `*/`.
|
|
332
|
-
|
|
333
|
-
### Top-level files (classes, interfaces, and enums)
|
|
334
|
-
|
|
335
|
-
The following tags are supported at the file level:
|
|
336
|
-
|
|
337
|
-
**Note** Any custom generated tag is also supported. Custom tags can be added with at symbol (`@`) followed by the name
|
|
338
|
-
of the tag. For example `@custom-tag`
|
|
339
|
-
|
|
340
|
-
| Tag | Description |
|
|
341
|
-
|----------------|-----------------------------------------|
|
|
342
|
-
| `@description` | One or more lines describing the file. |
|
|
343
|
-
| `@see` | The name of a related file. |
|
|
344
|
-
| `@group` | The group to which the file belongs to. |
|
|
345
|
-
| `@author` | The author of the file. |
|
|
346
|
-
| `@date` | The date the file was created. |
|
|
347
|
-
| `@example` | Example of how the code can be used. |
|
|
348
|
-
|
|
349
|
-
**Example**
|
|
350
|
-
|
|
351
|
-
```apex
|
|
352
|
-
/**
|
|
353
|
-
* @description This is my class description.
|
|
354
|
-
*/
|
|
355
|
-
public with sharing class TestClass {
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Enum Values
|
|
360
|
-
|
|
361
|
-
The following tags are supported on the enum value level:
|
|
362
|
-
|
|
363
|
-
| Tag | Description |
|
|
364
|
-
|----------------|-----------------------------------------|
|
|
365
|
-
| `@description` | One or more lines describing the value. |
|
|
366
|
-
|
|
367
|
-
**Example**
|
|
368
|
-
|
|
369
|
-
```apex
|
|
370
|
-
public enum ExampleEnum {
|
|
371
|
-
/** @description This is my enum value description. */
|
|
372
|
-
VALUE_1,
|
|
373
|
-
/** @description This is my other enum value description. */
|
|
374
|
-
VALUE_2
|
|
375
|
-
}
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### Properties and Fields
|
|
379
|
-
|
|
380
|
-
The following tags are supported on the property and field level:
|
|
381
|
-
|
|
382
|
-
| Tag | Description |
|
|
383
|
-
|----------------|--------------------------------------------|
|
|
384
|
-
| `@description` | One or more lines describing the property. |
|
|
351
|
+
### Processing
|
|
385
352
|
|
|
386
|
-
|
|
353
|
+
If you would like to use the processing capabilities of ApexDocs directly from Javascript/Typescript
|
|
354
|
+
instead of using the CLI, you can import the `process` function from the library.
|
|
387
355
|
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
* @description This is my property description.
|
|
391
|
-
*/
|
|
392
|
-
public String ExampleProperty { get; set; }
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
### Methods and Constructors
|
|
396
|
-
|
|
397
|
-
Methods and constructors support the same tags.
|
|
398
|
-
|
|
399
|
-
The following tags are supported on the method level:
|
|
400
|
-
|
|
401
|
-
| Tag | Description |
|
|
402
|
-
|------------------------------|---------------------------------------------------|
|
|
403
|
-
| `@description` | One or more lines describing the method. |
|
|
404
|
-
| `@param` _paramName_ | Description of a single parameter. |
|
|
405
|
-
| `@return` | Description of the return value of the method. |
|
|
406
|
-
| `@example` | Example of how the code can be used or called. |
|
|
407
|
-
| `@throws` _ExceptionName_ | Description of an exception thrown by the method. |
|
|
408
|
-
| `@exception` _ExceptionName_ | Same as `@throws`. V2 only |
|
|
409
|
-
| `@mermaid` | Diagrams in Mermaid format. |
|
|
410
|
-
|
|
411
|
-
**Example**
|
|
412
|
-
|
|
413
|
-
```apex
|
|
414
|
-
/**
|
|
415
|
-
* @description This is my method description.
|
|
416
|
-
* @param action The action to execute.
|
|
417
|
-
* @return The result of the operation.
|
|
418
|
-
* @example
|
|
419
|
-
* ```
|
|
420
|
-
* Object result = SampleClass.call('exampleAction');
|
|
421
|
-
* ```
|
|
422
|
-
public static Object call(String action) {
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
### Code Blocks
|
|
427
|
-
|
|
428
|
-
Code blocks can be added to *almost any tag by using the triple backtick syntax. This is useful when you want to display
|
|
429
|
-
code
|
|
430
|
-
snippets with sample usage or examples.
|
|
431
|
-
|
|
432
|
-
*The non-supported tags are the single line tags, like `@param`, `@return`, `@throws`, `@exception`, `@see`, etc*
|
|
433
|
-
|
|
434
|
-
After the triple backticks, you can optionally specify the language of the code block. This defaults to `apex`,
|
|
435
|
-
but it can be useful to override this when displaying code in other languages, such as `javascript` or `soql`.
|
|
436
|
-
|
|
437
|
-
Example
|
|
438
|
-
|
|
439
|
-
```apex
|
|
440
|
-
/**
|
|
441
|
-
* @description This is my method description.
|
|
442
|
-
* @sample-usage
|
|
443
|
-
* This is how you can use this method:
|
|
444
|
-
* ```
|
|
445
|
-
* Object result = SampleClass.call('exampleAction');
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
### Custom Tags
|
|
451
|
-
|
|
452
|
-
You can use custom tags to document your code. Custom tags can be added with at symbol (`@`) followed by the name
|
|
453
|
-
of the tag. Apexdocs will automatically format tags which words are separated by a dash (`-`) by separating them with a
|
|
454
|
-
space and uppercasing them. For example, `@custom-tag` will be displayed as `Custom Tag`.
|
|
455
|
-
|
|
456
|
-
Within a custom tag, you can also add code blocks by using the triple backtick syntax. This is useful when you want to
|
|
457
|
-
display code snippets within your documentation.
|
|
458
|
-
|
|
459
|
-
**Example**
|
|
460
|
-
|
|
461
|
-
```apex
|
|
462
|
-
/**
|
|
463
|
-
* @custom-tag This is a custom tag
|
|
464
|
-
* @custom-tag-with-code
|
|
465
|
-
* ```
|
|
466
|
-
* System.debug('Hello World');
|
|
467
|
-
* ```
|
|
468
|
-
*/
|
|
469
|
-
public class MyClass {
|
|
470
|
-
}
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
Note that the language of the code block will be set to `apex` by default, but you can change it by adding the language
|
|
474
|
-
name after the triple backticks. For example, to display a JavaScript code block you can use:
|
|
475
|
-
|
|
476
|
-
```apex
|
|
477
|
-
/**
|
|
478
|
-
* @custom-tag-with-code
|
|
479
|
-
* ```javascript
|
|
480
|
-
* console.log('Hello World');
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
public class MyClass {
|
|
484
|
-
}
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### Inline Linking
|
|
488
|
-
|
|
489
|
-
Apexdocs allows you to reference other classes from anywhere in your docs, and automatically creates a link to that
|
|
490
|
-
class file for easy navigation.
|
|
491
|
-
|
|
492
|
-
Apexdocs recognizes 2 different syntax when linking files:
|
|
493
|
-
|
|
494
|
-
- Javadoc's `{@link FileName}` syntax
|
|
495
|
-
- A class name wrapped in between `<<` `>>`.
|
|
496
|
-
|
|
497
|
-
**Example**
|
|
498
|
-
|
|
499
|
-
```apex
|
|
500
|
-
/**
|
|
501
|
-
* @description This is my method description. This method receives an <<ExampleClass>>.
|
|
502
|
-
* @param param1 An <<ExampleClass>> instance. Can also do {@link ExampleClass}
|
|
503
|
-
* @return The result of the operation.
|
|
504
|
-
*/
|
|
505
|
-
public static Object doSomething(ExampleClass param1) {
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
#### Email linking
|
|
510
|
-
|
|
511
|
-
Email addresses can also be inlined linked by using the `{@email EMAIL_ADDRESS}` syntax.
|
|
512
|
-
|
|
513
|
-
### Markdown formatting
|
|
514
|
-
|
|
515
|
-
You can use Markdown syntax to format your documentation.
|
|
516
|
-
For example, to create bold text, you can use `**bold text**`, and to create a list you can use the `*` character.
|
|
517
|
-
|
|
518
|
-
**Example**
|
|
519
|
-
|
|
520
|
-
```apex
|
|
521
|
-
/**
|
|
522
|
-
* @description This is a description with **bold text**.
|
|
523
|
-
* Which contains a list:
|
|
524
|
-
*
|
|
525
|
-
* **See Also**
|
|
526
|
-
* * [Title](https://example.com)
|
|
527
|
-
* * [Title 2](https://example.com)
|
|
528
|
-
*/
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
### Grouping Declarations Within A Class
|
|
532
|
-
|
|
533
|
-
A class might have members that should be grouped together. For example, you can have a class for constants with
|
|
534
|
-
groups of constants that should be grouped together because they share a common behavior (e.g. different groups
|
|
535
|
-
of constants representing the possible values for different picklists.)
|
|
536
|
-
|
|
537
|
-
You can group things together within a class by using the following syntax:
|
|
356
|
+
```typescript
|
|
357
|
+
import { process } from '@cparra/apexdocs';
|
|
538
358
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
359
|
+
process({
|
|
360
|
+
sourceDir: 'force-app',
|
|
361
|
+
targetDir: 'docs',
|
|
362
|
+
scope: ['global', 'public'],
|
|
363
|
+
...
|
|
364
|
+
});
|
|
544
365
|
```
|
|
545
366
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
Some notes about grouping:
|
|
549
|
-
|
|
550
|
-
* This is only supported on classes, NOT enums and interfaces
|
|
551
|
-
* Supports
|
|
552
|
-
* Properties
|
|
553
|
-
* Fields (variables and constants)
|
|
554
|
-
* Constructors
|
|
555
|
-
* Methods
|
|
556
|
-
* BUT only members of the same type are grouped together. For example,
|
|
557
|
-
if you have a group that contains properties and methods the properties will be grouped together under Properties ->
|
|
558
|
-
Group Name, and the methods will be grouped together under Methods -> Group Name
|
|
559
|
-
* Does not support inner types (inner classes, interfaces, and enums)
|
|
560
|
-
* It is necessary to use `// @end-group` whenever a group has been started, otherwise a parsing error will be raised for
|
|
561
|
-
that file.
|
|
367
|
+
### 👨💻 Typescript
|
|
562
368
|
|
|
563
|
-
|
|
369
|
+
If using Typescript, ApexDocs provides all necessary type definitions.
|
|
564
370
|
|
|
565
|
-
|
|
566
|
-
file will be ignored. If used at the member level, only that member will be ignored.
|
|
371
|
+
## 📖 Documentation Guide
|
|
567
372
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
```apex
|
|
571
|
-
/**
|
|
572
|
-
* @ignore
|
|
573
|
-
*/
|
|
574
|
-
public class MyClass {
|
|
575
|
-
public static void myMethod() {
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
```
|
|
373
|
+
See the [wiki](https://github.com/cesarParra/apexdocs/wiki/%F0%9F%93%96-Documenting-Apex-code)
|
|
374
|
+
for an in-depth guide on how to document your Apex code to get the most out of ApexDocs.
|
|
579
375
|
|
|
580
376
|
## 📄 Generating OpenApi REST Definitions
|
|
581
377
|
|
|
582
|
-
ApexDocs
|
|
583
|
-
|
|
584
|
-
### Usage
|
|
585
|
-
|
|
586
|
-
To create an OpenApi specification file, run `apexdocs openapi`
|
|
587
|
-
When using this generator, you can also pass a custom title through the `--title` parameter.
|
|
588
|
-
This title will be placed in the output file's `info.title` property,
|
|
589
|
-
as defined by the [OpenApi documentation for the Info Object](https://spec.openapis.org/oas/v3.1.0#info-object)
|
|
590
|
-
|
|
591
|
-
```shell
|
|
592
|
-
apexdocs openapi -s ./src -t docs --title "Custom OpenApi Title"
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
### How It Works
|
|
596
|
-
|
|
597
|
-
When generating an OpenApi document,
|
|
598
|
-
ApexDocs will run through all classes annotated with `@RestResource` and add it to the output OpenApi file.
|
|
599
|
-
|
|
600
|
-
Once it finishes running, a file named `openapi.json` (unless a different name is specified) will be created
|
|
601
|
-
in the specified `--targetDir`.
|
|
602
|
-
|
|
603
|
-
### Configuring What Gets Created
|
|
604
|
-
|
|
605
|
-
ApexDocs will automatically parse your source code and generate the OpenApi definition based on the HTTP related Apex
|
|
606
|
-
annotations (`RestResource`, `HttpDelete`, `HttpGet`, `HttpPatch`, `HttpPost`, `HttpGet`). The different HTTP
|
|
607
|
-
annotations will be used to generate a file that complies with
|
|
608
|
-
the [OpenApi Specification v3.1.0](https://spec.openapis.org/oas/v3.1.0)
|
|
609
|
-
|
|
610
|
-
Besides these annotations, the ApexDocs tool will also use any information provided through your code's Apexdocs,
|
|
611
|
-
relying on
|
|
612
|
-
some custom annotations that are specific to generating OpenApi definitions:
|
|
613
|
-
|
|
614
|
-
* `@http-request-body`
|
|
615
|
-
* `@http-parameter`
|
|
616
|
-
* `@http-response`
|
|
617
|
-
|
|
618
|
-
#### @http-request-body
|
|
619
|
-
|
|
620
|
-
Allows you to specify the HTTP request's expected request body. It supports receiving a `description`,
|
|
621
|
-
whether it is `required` or not, and a `schema`, which defines the shape of the object that is expected.
|
|
622
|
-
|
|
623
|
-
📝 Note that only one `@http-request-body` should be defined per method. If you add more than one, only
|
|
624
|
-
a single one will be used when generating the OpenApi definition.
|
|
625
|
-
|
|
626
|
-
The `schema` can either be a reference to another class in your source code (see the `Class References` section below)
|
|
627
|
-
or a fully defined custom schema (See the `Custom Schemas` section below).
|
|
628
|
-
|
|
629
|
-
Example
|
|
630
|
-
|
|
631
|
-
```apex
|
|
632
|
-
/**
|
|
633
|
-
* @description This is a sample HTTP Post method
|
|
634
|
-
* @http-request-body
|
|
635
|
-
* description: This is an example of a request body
|
|
636
|
-
* required: true
|
|
637
|
-
* schema: ClassName
|
|
638
|
-
*/
|
|
639
|
-
@HttpPost
|
|
640
|
-
global static void doPost() {
|
|
641
|
-
///...
|
|
642
|
-
}
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
|
|
646
|
-
so spacing is important.
|
|
647
|
-
|
|
648
|
-
#### @http-parameter
|
|
649
|
-
|
|
650
|
-
Allows you to specify any HTTP parameter expected by your method. It supports receiving a `name`,
|
|
651
|
-
an `in` as defined by the supported [Parameter Locations](https://spec.openapis.org/oas/v3.1.0#parameter-locations),
|
|
652
|
-
whether it is `required` or not, a `description`, and a `schema`.
|
|
653
|
-
|
|
654
|
-
📝 Note that you can specify as many `@http-parameter` annotations as needed.
|
|
655
|
-
|
|
656
|
-
Example
|
|
657
|
-
|
|
658
|
-
```apex
|
|
659
|
-
/**
|
|
660
|
-
* @description This is a sample HTTP Post method
|
|
661
|
-
* @return A String SObject.
|
|
662
|
-
* @http-parameter
|
|
663
|
-
* name: limit
|
|
664
|
-
* in: query
|
|
665
|
-
* required: true
|
|
666
|
-
* description: Limits the number of items on a page
|
|
667
|
-
* schema:
|
|
668
|
-
* type: integer
|
|
669
|
-
* @http-parameter
|
|
670
|
-
* name: complex
|
|
671
|
-
* in: cookie
|
|
672
|
-
* schema: MyClassName
|
|
673
|
-
*/
|
|
674
|
-
@HttpPost
|
|
675
|
-
global static String doPost() {
|
|
676
|
-
// ..
|
|
677
|
-
}
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
|
|
681
|
-
so spacing is important.
|
|
682
|
-
|
|
683
|
-
#### @http-response
|
|
684
|
-
|
|
685
|
-
Allows you to specify any HTTP response returned by your method. It supports receiving a `statusCode` with the response
|
|
686
|
-
code,
|
|
687
|
-
a `description`, and a `schema`.
|
|
688
|
-
|
|
689
|
-
If no `description` is provided then one will be automatically built using the `statusCode`.
|
|
690
|
-
|
|
691
|
-
📝 Note that you can specify as many `@http-parameter` annotations as needed.
|
|
692
|
-
|
|
693
|
-
```apex
|
|
694
|
-
/**
|
|
695
|
-
* @description This is a sample HTTP Post method
|
|
696
|
-
* @return A String SObject.
|
|
697
|
-
* @http-response
|
|
698
|
-
* statusCode: 200
|
|
699
|
-
* schema: SuccessfulResponseClassName
|
|
700
|
-
* @http-response
|
|
701
|
-
* statusCode: 500
|
|
702
|
-
* description: Status Code 500 - An internal server error occurred.
|
|
703
|
-
* schema:
|
|
704
|
-
* type: string
|
|
705
|
-
*/
|
|
706
|
-
@HttpPost
|
|
707
|
-
global static String doPost() {
|
|
708
|
-
// ...
|
|
709
|
-
}
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
#### Class References
|
|
713
|
-
|
|
714
|
-
Whenever specifying a `schema` parameter, you can pass as a string the name of any class in your source code. This
|
|
715
|
-
class will be parsed by the ApexDocs tool and automatically converted to a reference in the resulting OpenApi
|
|
716
|
-
definition.
|
|
717
|
-
|
|
718
|
-
The tool will parse the class and create a reference that complies
|
|
719
|
-
with [Apex's support for User-Defined Types](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm#ApexRESTUserDefinedTypes)
|
|
720
|
-
|
|
721
|
-
##### Reference Overrides
|
|
722
|
-
|
|
723
|
-
When dealing with references, there might be cases when you want to manually tell the parser what type of object a
|
|
724
|
-
property
|
|
725
|
-
or field is. For example, let's say we have a class that looks as follows
|
|
726
|
-
|
|
727
|
-
```apex
|
|
728
|
-
public class MyClass {
|
|
729
|
-
public Object myObject;
|
|
730
|
-
public Account myAccountRecord;
|
|
731
|
-
}
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
In this case `myObject` has a type of `Object`, and `myAccountRecord` is an SObject. Neither of these will be accurately
|
|
735
|
-
parsed when building the OpenApi definition, instead they will be simple be referenced as `object` without any
|
|
736
|
-
properties.
|
|
737
|
-
|
|
738
|
-
To accurately represent the shape of these objects, you can use the `@http-schema` annotation to essentially override
|
|
739
|
-
its
|
|
740
|
-
type during parsing. In this annotation you can specify the same thing you would in any `schema` property when dealing
|
|
741
|
-
with any
|
|
742
|
-
of the main `@http-*` methods, meaning a reference to another class, or a Custom Schema (as defined below).
|
|
743
|
-
|
|
744
|
-
```apex
|
|
745
|
-
public class MyClass {
|
|
746
|
-
/**
|
|
747
|
-
* @description This is a generic reference to another class
|
|
748
|
-
* @http-schema MyOtherClassName
|
|
749
|
-
*/
|
|
750
|
-
public Object myObject;
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* @description This is a reference to an Account SObject
|
|
754
|
-
* @http-schema
|
|
755
|
-
* type: object
|
|
756
|
-
* properties:
|
|
757
|
-
* Id:
|
|
758
|
-
* type: string
|
|
759
|
-
* Name:
|
|
760
|
-
* type: string
|
|
761
|
-
* CustomField__c:
|
|
762
|
-
* type: number
|
|
763
|
-
*/
|
|
764
|
-
public Account myAccountRecord;
|
|
765
|
-
}
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
---
|
|
769
|
-
|
|
770
|
-
If dealing with a collection, you can also specify the name of the reference either using the `List` or `Set` syntax.
|
|
771
|
-
|
|
772
|
-
📝 When using List or Set syntax in the `schema` of the ApexDoc `@http-*` annotation, only collections one level
|
|
773
|
-
deep are supported (e.g. List<List<String>> is not supported). This is only a limitation when referencing collections
|
|
774
|
-
on the ApexDoc `schema` property directly, and is fully supported when multi-level collections are inside of a
|
|
775
|
-
referenced
|
|
776
|
-
class as part of your codebase.
|
|
777
|
-
|
|
778
|
-
Maps are not supported, as it is not possible to know which keys the map will contain, and thus it is not possible
|
|
779
|
-
to convert that to a valid specification. For this use case, define a Custom Schema as explained below.
|
|
780
|
-
|
|
781
|
-
```apex
|
|
782
|
-
/**
|
|
783
|
-
* @description This is a sample HTTP Post method
|
|
784
|
-
* @http-request-body
|
|
785
|
-
* description: This is an example of a request body
|
|
786
|
-
* schema: List<ClassName>
|
|
787
|
-
*/
|
|
788
|
-
@HttpPost
|
|
789
|
-
global static void doPost() {
|
|
790
|
-
///...
|
|
791
|
-
}
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
Inner class references are also supported, but note that you need to pass the full name of the reference,
|
|
795
|
-
by using the `ParentClassName.InnerClassName` syntax, even if the inner class resides on the same class as the HTTP
|
|
796
|
-
method
|
|
797
|
-
referencing it.
|
|
798
|
-
|
|
799
|
-
```apex
|
|
800
|
-
/**
|
|
801
|
-
* @description This is a sample HTTP Post method
|
|
802
|
-
* @http-request-body
|
|
803
|
-
* description: This is an example of a request body
|
|
804
|
-
* schema: ParentClass.InnerClass
|
|
805
|
-
*/
|
|
806
|
-
@HttpPost
|
|
807
|
-
global static void doPost() {
|
|
808
|
-
///...
|
|
809
|
-
}
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
#### Custom Schemas
|
|
813
|
-
|
|
814
|
-
For any `schema` parameter in any of the HTTP ApexDocs annotations, besides specifying the name of a class, you
|
|
815
|
-
can also specify a custom schema definition. The schema definition can either be for a primitive type, an `object` or an
|
|
816
|
-
`array`
|
|
817
|
-
|
|
818
|
-
**Primitives**
|
|
819
|
-
|
|
820
|
-
For primitives, you should specify the `type` and an optional `format`, as defined by
|
|
821
|
-
the [OpenApi Specification on Data Types](https://spec.openapis.org/oas/v3.1.0#data-types)
|
|
822
|
-
|
|
823
|
-
```apex
|
|
824
|
-
/**
|
|
825
|
-
* ...
|
|
826
|
-
* schema:
|
|
827
|
-
* type: string
|
|
828
|
-
* format: password
|
|
829
|
-
*/
|
|
830
|
-
```
|
|
831
|
-
|
|
832
|
-
**Objects**
|
|
833
|
-
|
|
834
|
-
To specify a custom object schema, use `object` as the `type`, and specify as many properties as follows:
|
|
835
|
-
|
|
836
|
-
```apex
|
|
837
|
-
/**
|
|
838
|
-
* schema:
|
|
839
|
-
* type: object
|
|
840
|
-
* properties:
|
|
841
|
-
* id:
|
|
842
|
-
* type: string
|
|
843
|
-
* description: The super Id.
|
|
844
|
-
* name:
|
|
845
|
-
* type: string
|
|
846
|
-
* phone:
|
|
847
|
-
* type: string
|
|
848
|
-
* format: byte
|
|
849
|
-
*/
|
|
850
|
-
```
|
|
851
|
-
|
|
852
|
-
Properties can be defined as primitives (as explained above), other objects, or arrays (explained below)
|
|
853
|
-
|
|
854
|
-
**Arrays**
|
|
855
|
-
|
|
856
|
-
To specify a custom array schema, use `array` as the `type`, and provide an `items` definition. In `items`
|
|
857
|
-
you can specify the definition of any other custom type (primitives, objects, or other arrays).
|
|
858
|
-
|
|
859
|
-
```apex
|
|
860
|
-
/**
|
|
861
|
-
* schema:
|
|
862
|
-
* type: array
|
|
863
|
-
* items:
|
|
864
|
-
* type: object
|
|
865
|
-
* properties:
|
|
866
|
-
* name:
|
|
867
|
-
* type: string
|
|
868
|
-
*/
|
|
869
|
-
```
|
|
870
|
-
|
|
871
|
-
#### SObject References
|
|
872
|
-
|
|
873
|
-
ApexDocs is not able to automatically parse SObject references, as it can with class references, as it does
|
|
874
|
-
not reach into your org to get existing SObject describes. Because of this, when dealing with SObject references
|
|
875
|
-
you should create a Custom Schema as defined above. This will also allow you to specify which specific
|
|
876
|
-
fields are being received or returned.
|
|
877
|
-
|
|
878
|
-
### Considerations
|
|
879
|
-
|
|
880
|
-
Please be aware of the following when using ApexDocs to create an OpenApi definition:
|
|
881
|
-
|
|
882
|
-
* Map references are resolved as `object` with no properties, as it is not possible to know which keys the map will
|
|
883
|
-
contain.
|
|
884
|
-
When using maps either create a class that better represents the shape of the object and use a Class Reference, or
|
|
885
|
-
define a Custom Schema in the `schema` section of the ApexDoc itself.
|
|
886
|
-
* Same thing when referencing SObjects, as SObject describe parsing is not supported by the ApexDocs tool. When
|
|
887
|
-
referencing
|
|
888
|
-
SObjects, consider defining a Custom Schema in the `schema` section of the ApexDoc.
|
|
889
|
-
* ApexDoc is only able to parse through your source code, so references to other packages (namespaced classes) or any
|
|
890
|
-
code that lives outside your source code is not supported. Consider creating a Custom Schema for those situations.
|
|
891
|
-
* The return value and received parameters or your methods are currently not being considered when creating the OpenApi
|
|
892
|
-
definition file.
|
|
893
|
-
Instead, use the `@http-response` ApexDoc annotation to specify the return value, and `@http-parameter` to specify any
|
|
894
|
-
expected parameter.
|
|
895
|
-
|
|
378
|
+
ApexDocs can also generate OpenApi REST definitions for your Salesforce Apex classes annotated with `@RestResource`.
|
|
896
379
|
|
|
380
|
+
See the [wiki](https://github.com/cesarParra/apexdocs/wiki/%F0%9F%93%84-Generating-OpenApi-REST-Definitions)
|
|
381
|
+
for more information.
|