samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

Want to display parameter examples in Swagger documentation generated by Nestia #1031

Closed shad0xfox closed 1 month ago

shad0xfox commented 1 month ago

I'm using Nestia to generate Swagger documentation, but I'm unable to display example values for parameters in the generated docs.

I tried @example

interface IGetHello {
  /**
   * @example test
   */
  name: string;
}

I'm looking for an effect similar to NestJS's @ApiProperty({ example: 'test' }).

I've searched through the issues but haven't found any similar questions. I also couldn't find any information in the documentation about setting parameter examples. Am I missing something? Thank you for your help.

samchon commented 1 month ago

Not supporting nested property level example.

If you want it, you have to do it like below.

import typia, { tags } from "typia";

interface IGetHello {
  name: string & tags.Plugin<{
    example: "test"
  }>;
}
shad0xfox commented 1 month ago

Hi @samchon,

Thank you for your suggestion! I implemented your method and tried the code below, it solved the issue perfectly.

interface IGetHello {
  name: string &
    tags.JsonSchemaPlugin<{
      example: 'test';
    }>;
}

I really appreciate your help.