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

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

@ -63,14 +63,14 @@ type (
// Route describes api route
Route struct {
Annotation Annotation
Method string
Path string
RequestType Type
ResponseType Type
Docs Doc
Handler string
AtDoc AtDoc
AtServerAnnotation Annotation
Method string
Path string
RequestType Type
ResponseType Type
Docs Doc
Handler string
AtDoc AtDoc
}
// Service describes api service

Loading…
Cancel
Save