test.api 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // only one
  2. syntax = "v1"
  3. // import
  4. import "foo.api"
  5. // import group
  6. import(
  7. "foo.api"
  8. "foo/bar.api"
  9. )
  10. // only one
  11. info(
  12. title: "foo title"
  13. desc: "foo
  14. desc"
  15. author: "foo author"
  16. email: "foo email"
  17. version: "foo version"
  18. )
  19. // ignore the following duplicate name
  20. type Foo int
  21. // type single
  22. type Foo {
  23. Bar string
  24. }
  25. type Foo {
  26. Bar string `json:"bar"`
  27. Inline
  28. }
  29. // go struct
  30. type Foo struct {
  31. Bar string `json:"bar"`
  32. }
  33. // type group
  34. type (
  35. Foo int
  36. // go struct
  37. Foo struct {
  38. Bar string `json:"bar"`
  39. }
  40. Foo {
  41. VString string `json:"vString"`
  42. VBool bool `json:"vBool"`
  43. VInt8 int8 `json:"vInt8"`
  44. VInt16 int16 `json:"vInt16"`
  45. VInt32 int32 `json:"vInt32"`
  46. VInt64 int64 `json:"vInt64"`
  47. VInt int `json:"vInt"`
  48. VUInt8 uint8 `json:"vUInt8"`
  49. VUInt16 uint16 `json:"vUInt16"`
  50. VUInt32 uint32 `json:"vUInt32"`
  51. VUInt64 uint64 `json:"vUInt64"`
  52. VFloat32 float32 `json:"vFloat32"`
  53. VFloat64 float64 `json:"vFloat64"`
  54. VByte byte `json:"vByte"`
  55. VRune rune `json:"vRune"`
  56. VMap map[string]int `json:"vMap"`
  57. VArray []int `json:"vArray"`
  58. VStruct Foo `json:"vStruct"`
  59. VStructPointer *Foo `json:"vStructPointer"`
  60. VInterface interface{} `json:"vInterface"`
  61. T time.Time
  62. }
  63. )
  64. @server(
  65. jwt: Foo
  66. group: foo/bar
  67. anotherKey: anotherValue
  68. )
  69. service example-api {
  70. @doc(
  71. summary: "foo1"
  72. )
  73. @server(
  74. handler: fooHandler1
  75. anotherKey: anotherValue
  76. )
  77. post /api/foo1 (SingleExample)
  78. @doc "foo2"
  79. @handler fooHandler2
  80. get /api/foo2 (SingleExample) returns (SingleExample2)
  81. @handler fooHandler3
  82. post /api/foo3/:id returns (SingleExample2)
  83. @handler fooHandler4
  84. get /api/foo4
  85. }