Apicurio / apicurio-codegen

Repository to hold some code generation utilities.
Apache License 2.0
4 stars 15 forks source link

Improve generated javadoc #285

Open jsenko opened 4 months ago

jsenko commented 4 months ago

Given the following operation:

"/admin/export": {
  "get": {
    "description": "Exports registry data as a ZIP archive.",
    "operationId": "exportData",
    "parameters": [
      {
        "description": "Indicates if the operation is done for a browser.  If true, the response will be a JSON payload with a property called `href`.  This `href` will be a single-use, naked download link suitable for use by a web browser to download the content.",
        "in": "query",
        "name": "forBrowser",
        "schema": {
          "type": "boolean"
        }
      }
    ],
    "responses": {
      "200": {
        "content": {
          "application/zip": {
            "schema": {
              "$ref": "#/components/schemas/FileContent"
            }
          },
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DownloadRef"
            }
          }
        },
        "description": "Response when the export is successful."
      },
      "500": {
        "$ref": "#/components/responses/ServerError"
      }
    },
    ...
    "summary": "Export registry data",
    ...
  },
  "summary": "Provides a way to export registry data."
}

the generated javadoc is simply based on operation description:

/**
 * <p>
 * Exports registry data as a ZIP archive.
 * </p>
 * 
 */
@Path("/export")
@GET
@Produces({"application/json", "application/zip"})
Response exportData(@QueryParam("forBrowser") Boolean forBrowser);

It would be cool if the javadoc contained information from other nested fields, e.g.:

/**
 * Export registry data
 * <p>
 * Exports registry data as a ZIP archive.
 * <p>
 * Responses:
 * <ul>
 *   <li>HTTP 200: Response when the export is successful.
 *     <ul>
 *       <li>application/json: {@link io.apicurio.registry.rest.v2.beans.DownloadRef}</li>
 *       <li>application/zip: string (binary)</li>
 *     </ul>
 *   <li>HTTP 500: Common response for all operations that can fail with an unexpected server error.
 *     <ul>
 *       <li>application/json: {@link io.apicurio.registry.rest.v2.beans.Error}</li>
 *     </ul>
 *   </li>
 * </ul>
 *
 * @param forBrowser Indicates if the operation is done for a browser. If true, the response will be a JSON payload
 *                   with a property called `href`. This `href` will be a single-use, naked download link
 *                   suitable for use by a web browser to download the content.
*/
@Path("/export")
@GET
@Produces({"application/json", "application/zip"})
Response exportData(@QueryParam("forBrowser") Boolean forBrowser);