spec.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package spec
  2. type (
  3. Doc []string
  4. Annotation struct {
  5. Properties map[string]string
  6. }
  7. ApiSyntax struct {
  8. Version string
  9. }
  10. ApiSpec struct {
  11. Info Info
  12. Syntax ApiSyntax
  13. Imports []Import
  14. Types []Type
  15. Service Service
  16. }
  17. Import struct {
  18. Value string
  19. }
  20. Group struct {
  21. Annotation Annotation
  22. Routes []Route
  23. }
  24. Info struct {
  25. // Deprecated: use Properties instead
  26. Title string
  27. // Deprecated: use Properties instead
  28. Desc string
  29. // Deprecated: use Properties instead
  30. Version string
  31. // Deprecated: use Properties instead
  32. Author string
  33. // Deprecated: use Properties instead
  34. Email string
  35. Properties map[string]string
  36. }
  37. Member struct {
  38. Name string
  39. // 数据类型字面值,如:string、map[int]string、[]int64、[]*User
  40. Type Type
  41. Tag string
  42. Comment string
  43. // 成员头顶注释说明
  44. Docs Doc
  45. IsInline bool
  46. }
  47. Route struct {
  48. Annotation Annotation
  49. Method string
  50. Path string
  51. RequestType Type
  52. ResponseType Type
  53. Docs Doc
  54. Handler string
  55. AtDoc AtDoc
  56. }
  57. Service struct {
  58. Name string
  59. Groups []Group
  60. }
  61. Type interface {
  62. Name() string
  63. }
  64. DefineStruct struct {
  65. RawName string
  66. Members []Member
  67. Docs Doc
  68. }
  69. // 系统预设基本数据类型 bool int32 int64 float32
  70. PrimitiveType struct {
  71. RawName string
  72. }
  73. MapType struct {
  74. RawName string
  75. // only support the PrimitiveType
  76. Key string
  77. // it can be asserted as PrimitiveType: int、bool、
  78. // PointerType: *string、*User、
  79. // MapType: map[${PrimitiveType}]interface、
  80. // ArrayType:[]int、[]User、[]*User
  81. // InterfaceType: interface{}
  82. // Type
  83. Value Type
  84. }
  85. ArrayType struct {
  86. RawName string
  87. Value Type
  88. }
  89. InterfaceType struct {
  90. RawName string
  91. }
  92. PointerType struct {
  93. RawName string
  94. Type Type
  95. }
  96. AtDoc struct {
  97. Properties map[string]string
  98. Text string
  99. }
  100. )