spec.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. }
  56. Service struct {
  57. Name string
  58. Groups []Group
  59. }
  60. Type interface {
  61. Name() string
  62. }
  63. DefineStruct struct {
  64. RawName string
  65. Members []Member
  66. Docs Doc
  67. }
  68. // 系统预设基本数据类型 bool int32 int64 float32
  69. PrimitiveType struct {
  70. RawName string
  71. }
  72. MapType struct {
  73. RawName string
  74. // only support the PrimitiveType
  75. Key string
  76. // it can be asserted as PrimitiveType: int、bool、
  77. // PointerType: *string、*User、
  78. // MapType: map[${PrimitiveType}]interface、
  79. // ArrayType:[]int、[]User、[]*User
  80. // InterfaceType: interface{}
  81. // Type
  82. Value Type
  83. }
  84. ArrayType struct {
  85. RawName string
  86. Value Type
  87. }
  88. InterfaceType struct {
  89. RawName string
  90. }
  91. PointerType struct {
  92. RawName string
  93. Type Type
  94. }
  95. )