zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.

Home Page:https://go-zero.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate routing errors occur when using the prefix option in API file groups

zfkun opened this issue · comments

commented

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
goctl api go -api ./issue.api -dir .

  1. The code is

issue.api

syntax = "v1"

info(
  title: "just demo"
  desc: "type desc here"
  author: "zfkun"
  email: "zfkun@msn.com"
  version: "0.0.1"
)

type (
  UserInitReq {
      Name string `json:"name"`
  }

  UserInitReply {
      Id uint64 `json:"id"`
  }

  UserLoginReq {
      Name string `json:"name"`
  }

  UserLoginReply {
      Success bool `json:"success"`
  }

  AdminInitReq {
      Name string `json:"name"`
  }

  AdminInitReply {
      Id uint64 `json:"id"`
  }

  AdminLoginReq {
      Name string `json:"name"`
  }

  AdminLoginReply {
      Success bool `json:"success"`
  }
)


@server(
  group: user
  prefix: /user
)
service issue-api {
  @doc "init for user service"
  @handler init
  post /init (UserInitReq) returns (UserInitReply)

  @doc "login for user service"
  @handler login
  post /login (UserInitReq) returns (UserInitReply)
}


@server(
  group: admin
  prefix: /admin
)
service issue-api {
  @doc "init for user service"
  @handler init
  post /init (AdminInitReq) returns (AdminInitReply)

  @doc "login for user service"
  @handler login
  post /login (AdminLoginReq) returns (AdminLoginReply)
}
  1. The error is
./issue.api line 68:4  duplicate route 'post /init'
goctl: generation error: ./issue.api line 68:4  duplicate route 'post /init'
goctl version: 1.2.3 darwin/amd64

Expected behavior
I think, route's key for filter should include the value of prefix.
Thanks.

Screenshots
none

Environments (please complete the following information):

  • OS: MacOS
  • go-zero version 1.2.3
  • goctl version 1.2.3

More description
none