Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Plugin cannot generate descriptions for endpoint #2958

Open
2 of 4 tasks
shaunhurryup opened this issue May 22, 2024 · 1 comment
Open
2 of 4 tasks

CLI Plugin cannot generate descriptions for endpoint #2958

shaunhurryup opened this issue May 22, 2024 · 1 comment

Comments

@shaunhurryup
Copy link

shaunhurryup commented May 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I try to use CLI Plugin to generate descriptions for properties and endpoints based on comments, only the property work

Core Code

class HelloQuery {
  /**
   * username description
   * @example shaun
   */
  name: string
  /**
   * age description
   * @example 35 
   */
  age?: number
}

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  /**
   * This is endpoint
   * @description This is endpoint description
   * @summary This is endpoint summary
   */
  @Get()
  // Must use following statement and work :(
  // @ApiOperation({ description: 'Endpint description created by `ApiOperation`' })
  getHello(@Query() query: HelloQuery): string {
    return this.appService.getHello();
  }
}

Output File

{
    "openapi": "3.0.0",
    "paths": {
        "/": {
            "get": {
                "operationId": "AppController_getHello",
                "parameters": [
                    {
                        "name": "name",
                        "required": true,
                        "in": "query",
                        "description": "username description",
                        "example": "shaun",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "age",
                        "required": false,
                        "in": "query",
                        "description": "age description",
                        "example": 35,
                        "schema": {
                            "type": "number"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": ""
                    }
                }
            }
        }
    },
    "info": {
        "title": "nestjs swagger bug resport service",
        "description": "This is description",
        "version": "1.0",
        "contact": {}
    },
    "tags": [],
    "servers": [],
    "components": {
        "schemas": {}
    }
}

Minimum reproduction code

https://github.com/shaunhurryup/nestjs-swagger-bug-report

Steps to reproduce

  1. yarn
  2. yarn start:dev

You can see demo.swagger.json in the root directory

Expected behavior

{
    "openapi": "3.0.0",
    "paths": {
        "/": {
            "get": {
                "operationId": "AppController_getHello",
+                "summary": "",
+                "description": "Endpint description created by `ApiOperation`",
                "parameters": [
                    {
                        "name": "name",
                        "required": true,
                        "in": "query",
                        "description": "username description",
                        "example": "shaun",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "age",
                        "required": false,
                        "in": "query",
                        "description": "age description",
                        "example": 35,
                        "schema": {
                            "type": "number"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": ""
                    }
                }
            }
        }
    },
    "info": {
        "title": "nestjs swagger bug resport service",
        "description": "This is description",
        "version": "1.0",
        "contact": {}
    },
    "tags": [],
    "servers": [],
    "components": {
        "schemas": {}
    }
}

Package version

7.3.1

NestJS version

9.4.3

Node.js version

v16.20.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@shaunhurryup shaunhurryup changed the title CLI Plugin cannot generate description for endpoint CLI Plugin cannot generate descriptions for endpoint May 22, 2024
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants