master
kingxt 4 years ago committed by GitHub
parent 39540e21d2
commit 1e4e5a02b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -219,7 +219,7 @@ func (p parser) fillService() error {
for _, astRoute := range item.ServiceApi.ServiceRoute { for _, astRoute := range item.ServiceApi.ServiceRoute {
route := spec.Route{ route := spec.Route{
Annotation: spec.Annotation{}, AtServerAnnotation: spec.Annotation{},
Method: astRoute.Route.Method.Text(), Method: astRoute.Route.Method.Text(),
Path: astRoute.Route.Path.Text(), Path: astRoute.Route.Path.Text(),
} }
@ -275,7 +275,7 @@ func (p parser) fillRouteAtServer(astRoute *ast.ServiceRoute, route *spec.Route)
for _, kv := range astRoute.AtServer.Kv { for _, kv := range astRoute.AtServer.Kv {
properties[kv.Key.Text()] = kv.Value.Text() properties[kv.Key.Text()] = kv.Value.Text()
} }
route.Annotation.Properties = properties route.AtServerAnnotation.Properties = properties
if len(route.Handler) == 0 { if len(route.Handler) == 0 {
route.Handler = properties["handler"] route.Handler = properties["handler"]
} }

@ -11,10 +11,11 @@ import (
const ( const (
bodyTagKey = "json" bodyTagKey = "json"
formTagKey = "form" formTagKey = "form"
pathTagKey = "path"
defaultSummaryKey = "summary" defaultSummaryKey = "summary"
) )
var definedKeys = []string{bodyTagKey, formTagKey, "path"} var definedKeys = []string{bodyTagKey, formTagKey, pathTagKey}
// Routes returns all routes in api service // Routes returns all routes in api service
func (s Service) Routes() []Route { func (s Service) Routes() []Route {
@ -25,7 +26,7 @@ func (s Service) Routes() []Route {
return result return result
} }
// Tags retuens all tags in Member // Tags returns all tags in Member
func (m Member) Tags() []*Tag { func (m Member) Tags() []*Tag {
tags, err := Parse(m.Tag) tags, err := Parse(m.Tag)
if err != nil { if err != nil {
@ -141,7 +142,7 @@ func (t DefineStruct) GetFormMembers() []Member {
return result return result
} }
// GetNonBodyMembers retruns all have no tag fields // GetNonBodyMembers returns all have no tag fields
func (t DefineStruct) GetNonBodyMembers() []Member { func (t DefineStruct) GetNonBodyMembers() []Member {
var result []Member var result []Member
for _, member := range t.Members { for _, member := range t.Members {
@ -162,16 +163,16 @@ func (r Route) JoinedDoc() string {
return strings.TrimSpace(doc) return strings.TrimSpace(doc)
} }
// GetAnnotation returns the value by specified key // GetAnnotation returns the value by specified key from @server
func (r Route) GetAnnotation(key string) string { func (r Route) GetAnnotation(key string) string {
if r.Annotation.Properties == nil { if r.AtServerAnnotation.Properties == nil {
return "" return ""
} }
return r.Annotation.Properties[key] return r.AtServerAnnotation.Properties[key]
} }
// GetAnnotation returns the value by specified key // GetAnnotation returns the value by specified key from @server
func (g Group) GetAnnotation(key string) string { func (g Group) GetAnnotation(key string) string {
if g.Annotation.Properties == nil { if g.Annotation.Properties == nil {
return "" return ""

@ -63,7 +63,7 @@ type (
// Route describes api route // Route describes api route
Route struct { Route struct {
Annotation Annotation AtServerAnnotation Annotation
Method string Method string
Path string Path string
RequestType Type RequestType Type

Loading…
Cancel
Save