cesarParra / apexdocs

Node.js tool to generate documentation for your Salesforce Apex Classes.
https://www.npmjs.com/package/@cparra/apexdocs
MIT License
109 stars 18 forks source link

Open API examples #100

Closed RaviVaranasi closed 10 months ago

RaviVaranasi commented 10 months ago

Is there an example to show the array reference for a custom class? The documentation reference shows custom schemas or is the parser automatically generates the array type?

global AddressDTO {
    public String streetAddress { get; set; }
    public String city { get; set; }
}
global class CustomerDTO {
    /**
     * @description Customer addressed
     * @http-schema
     *   type: array
     *   items:
     *      $ref: "#/components/schemas/AddressDTO"
     */
    public List<AddressDTO> addresses { get; set; }
}
cesarParra commented 10 months ago

Hi @RaviVaranasi

The parser will automatically pick it up in this case, no need to document the property as a custom schema.

There's an example of this in the examples folder, specifically the Reference1 class has a property of type list here: https://github.com/cesarParra/apexdocs/blob/master/examples/force-app/main/default/restapi/references/Reference1.cls#L7

This gets converted to:

...
      "Reference1": {
        "type": "object",
        "properties": {
          "reference2Member": {
            "$ref": "#/components/schemas/Reference2",
            "description": "This is a reference 2 member. Lorem."
          },
          "reference3Member": {
            "$ref": "#/components/schemas/Reference3"
          },
          "reference4Collection": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Reference4"
            }
          },
          "reference5Member": {
            "$ref": "#/components/schemas/Reference5"
          }
        }
      },
...