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

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

Open byp-yezi opened this issue 3 weeks ago • 0 comments

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

byp-yezi avatar Jun 13 '24 07:06 byp-yezi