go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

There is an issue with parsing the comments in the API file content

Open licat233 opened this issue 2 years ago • 3 comments

Describe the bug There is an issue with parsing the comments in the API file content. Some comments that do not belong to the parameter will be forcibly added to the comments for that parameter.

To Reproduce Steps to reproduce the behavior, if applicable:

  1. The code is

    type (
    
     //注册请求结构
     RegisterReq {
     	Username string `json:"username"`
     	Password string `json:"password"`
     	Mobile   string `json:"mobile"`
     }
    
     //备注
     // ------------- 不必要的注释,不是LoginReq的注释,仅仅是分割线 ---------
    
     //登录请求
     LoginReq {
     	Username string `json:"username"` //测试
     	Password string `json:"password"` //测试2
     }
    

)


2. The error is

```json
    "/api/user/login": {
   "post": {
     "summary": "登录",
     "operationId": "login",
     "responses": {
       "200": {
         "description": "A successful response.",
         "schema": {}
       }
     },
     "parameters": [
       {
         "name": "body",
         "description": "备注, ------------- 不必要的注释,不是LoginReq的注释,仅仅是分割线 ---------,登录请求",
         "in": "body",
         "required": true,
         "schema": {
           "$ref": "#/definitions/LoginReq"
         }
       }
     ],
     "tags": [
       "user-api"
     ]
   }
 },

Expected behavior The real comments should be distinguished by the blank lines in the "xxx.api" file, instead of treating all comment contents as comments.

Screenshots alt comment-error

Environments (please complete the following information):

  • OS: [e.g. macOS]
  • go-zero version [e.g. 1.5.3]
  • goctl version [e.g. 1.5.3, optional]

More description I hope this issue can be quickly resolved.

licat233 avatar Jul 04 '23 06:07 licat233

goctl-swagger‘s issue?

kesonan avatar Jul 04 '23 13:07 kesonan

goctl-swagger‘s issue?

no, to be precise, it is the issue of goctl, because the data used by goctl swagger is data from the goctl parsing API file.

licat233 avatar Jul 05 '23 01:07 licat233

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 05 '24 01:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Oct 04 '24 02:10 github-actions[bot]