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

Type XxxReq generate error, type ApkGuestLoginReq, json property name not exist, member: OS

Open cdz620 opened this issue 1 year ago • 6 comments

Describe the bug goctl api ts failed to generate ts file.

To Reproduce goctl api ts --api dock.api --caller request --webapi '@/services/request' --dir /your/dir

  1. The code is

     ApkGuestLoginReq {
         OS int32 `header:"x-os"` 
         App int32 `header:"x-app"` 
         Channel int32 `header:"x-ch,optional"` 
     }
    ApkUserLoginResp {}
    
     @server(
         group: apk/user
         middleware: ApkSign
         prefix: /apk/users
     )
     service big-api {
         @doc "游客登录接口"
         @handler GuestLogin
         post /guest/login (ApkGuestLoginReq) returns (ApkUserLoginResp)
     }
    
    
  2. The error is

     2022/08/07 15:23:00 Type ApkGuestLoginReq generate error,  type ApkGuestLoginReq, json property name not exist, member: OS
    

Expected behavior generate ts file

Screenshots nil

Environments (please complete the following information):

  • OS: MacOS
  • github.com/zeromicro/go-zero v1.3.5
  • goctl version 1.3.9 darwin/arm64

More description Add any other context about the problem here.

cdz620 avatar Aug 07 '22 07:08 cdz620

显而易见,goctl 已经提示了需要 json tag

Obviously, goctl has prompted the need for json tag

kesonan avatar Aug 21 '22 14:08 kesonan

the body without data and I just want to get data from header.

cdz620 avatar Aug 22 '22 01:08 cdz620

如果你不需要响应体,你可以写成这样:

If you not need to response, you can declare as follows:

post /guest/login (ApkGuestLoginReq)

kesonan avatar Sep 01 '22 14:09 kesonan

我需要header,所有需要写一个Struct来接收,header的参数,但是我不需要Request Body的内容

cdz620 avatar Sep 02 '22 05:09 cdz620

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I need the header, all I need to write a Struct to receive, the parameters of the header, but I don't need the content of the Request Body

Issues-translate-bot avatar Sep 02 '22 05:09 Issues-translate-bot

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

github-actions[bot] avatar Mar 18 '24 01:03 github-actions[bot]