Generate API file

Time:2022-1-7

Enter the path where the API needs to be generated

[email protected] api % pwd
/Users/myself/Golang/common_project/src/shorturl/api
[email protected] api % 

Default content


syntax = "v1"

info(
   title: // TODO: add title
  desc: // TODO: add description
  author: "donglei"
  email: "[email protected]"
)

type request {
   // TODO: add members here and delete this comment
}

type response {
   // TODO: add members here and delete this comment
}

service shorturl-api {
   @handler GetUser // TODO: set handler name and delete this comment
  get /users/id/:userId(request) returns(response)

   @handler CreateUser // TODO: set handler name and delete this comment
  post /users/create(request)
}

Error field para1 is not set

This will report an error
Prompt field para1 is not set

type Request1 {
    //    Para1 string `json:"para1,optional"`
    Para1 string `json:"para1"`
}

It won't
type Request1 {
      Para1 string `json:"para1,optional"`
  //Para1 string `json:"para1"`
}

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

Swift FAQ

1、 Foundation 1. What is the difference between class and struct? a. Struct will automatically generate the required constructor. The constructor with which attribute is not assigned an initial value will be generated with which attribute as the parameter. But class doesn’t. write it yourself struct StructTest { var name:String var age:Int } class ClassTest […]