I have had quite a bit of trouble getting my docs to update. Here is a small example:
// export-decorators.ts
export function ApiOkAndErrorResponses() {
return applyDecorators(
HttpCode(200),
ApiOkResponse({
type: ResponseBodyDto,
description:
'Returned upon successful direct action to our database. Action is immediate.',
schema: {
allOf: [{ $ref: getSchemaPath(ResponseBodyDto) }],
example: {
message: 'Success',
data: { id: 1, name: 'John Doe' },
},
},
}) /* statusCode 200 */,
// below, I have 2 more decorators in the same style:
// ApiBadRequestResponse and ApiInternalServerErrorResponse
);
}
In this example, I am using the schema field to add a description and example to my docs. It was working initially but is now failing to add the example. This happened I believe after adding the HttpCode decorator to this function. I am not sure if this is an issue with the nesting of applied properties.
Additionally, when trying to apply a status code besides 200, i.e. 201 with the HttpCode() function in other functions like the one above, it fails to apply and enforces whatever default code is typically applied for that endpoint. I have to manually add @HttpCode(201) to those endpoints individually for it to format correctly. If I remove these individual decorators applied directly to the controllers (and rely on the HttpCode inside the applyDecorators) I get the following update:
I should note, I am using the nestjs/swagger CLI plugin, and it is successfully applying all ApiProperties to my DTOs without listing each out individually.
I am expecting the swagger docs to include the example. This is successfully setting the response type and description (and changes to the description in this file DO apply, so it is applying those decorators).
I tested whether the applyDecorators is working by changing data within that function, and it definitely is functioning in some capacity (changing the description field updates the description accordingly). Additionally and interestingly, this exact codebase at times works in my other environment (I switch between a laptop and desktop), though I think at this current moment, both environments are reflecting this same issue.
Additional context: For those interested in how I arrived at the structure of schema and the usage of allOf, this was an odd solution I found through this thread chain.