zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.13k stars 3.94k forks source link

When using the 'goctl api go' command, an error is reported: missing input #4189

Open byp-yezi opened 4 months ago

byp-yezi commented 4 months ago

When I finished editing the API file and layered it according to the directory, I finally imported other API files into a main API file through API import.

Here is my directory structure

071681267b26a77de363d146faf642f

login.api

type (
    LoginRequest {
        Mobile   string `json:"mobile"`
        Password string `json:"password"`
    }
    LoginResponse {
        AccessToken  string `json:"accessToken"`
        AccessExpire int64  `json:"accessExpire"`
    }
)

register.api

type (
    RegisterRequest {
        Name     string `json:"name"`
        Gender   int64  `json:"gender"`
        Mobile   string `json:"mobile"`
        Password string `json:"password"`
    }
    RegisterResponse {
        Id     int64  `json:"id"`
        Name   string `json:"name"`
        Gender int64  `json:"gender"`
        Mobile string `json:"mobile"`
    }
)

userinfo.api

type (
    UserInfoResponse {
        Id     int64  `json:"id"`
        Name   string `json:"name"`
        Gender int64  `json:"gender"`
        Mobile string `json:"mobile"`
    }
)

user.api

import (
    "login/login.api"
    "register/register.api"
    "userinfo/useinfo.api"
)

@server (
    prefix: /user/v1
)
service user-api {
    @handler Login
    post /api/login (LoginRequest) returns (LoginResponse)

    @handler Register
    post /api/register (RegisterRequest) returns (RegisterResponse)
}

@server (
    prefix: /user/v1
    jwt:    Auth
)
service user-api {
    @handler UserInfo
    post /api/userinfo returns (UserInfoResponse)
}

I tried using 'goctl API validate' to check the API file, but still only 'missing input' reported an error

Finally i found in ' user.api ', and in the import, it should have been written as "userinfo/useinfo. apis" instead of "userinfo/useinfo. apis", missing the word "r"

Personal hope: I hope the 'go zero' team can help improve the 'goctl API validate' command, provide a prompt, or highlight the errors in red when using the vscode goctl plugin or goland goctl plugin

dextercai commented 2 months ago

Same problem, after updating goctl toolchain from v1.6.0 to v1.7.0.