ts-spec / tspec

Type-driven API Documentation library. Auto-generating REST API document based on TypeScript types.
https://ts-spec.github.io/tspec/
MIT License
127 stars 5 forks source link

Allow responses description override #55

Open programatix opened 3 months ago

programatix commented 3 months ago

Is your feature request related to a problem? Please describe. Currently, the JSDoc comments on the response type is used as description. However, it may not accurately represent the actual response description.

Example, image

Describe the solution you'd like It would be great if the description can be overwritten with local JDDoc ccomments.

Exxample,

delete: {
    summary: "Delete a task",
    description: "Delete a specific task by ID.",
    path: {
        /** The identifier of the task to delete */
        id: number
    },
    responses: {
        /** Task deleted */
        204: "",
        /** Invalid params */
        400: ProblemDetails
        /** Task not found */
        404: ProblemDetails
    }
}

For the example above, status 204 description is inserted correctly as seen in the screenshot above.

programatix commented 3 months ago

It turns out that the descriptions are added but to the wrong location. It should be placed in the location as indicated in the arrows in the screenshot below. image

Also, the schema under components already has its own description, thus does not need to be repeated. image

In addition to that, swagger editor produces warning when description is included together with $ref. image