Skip to content

Commit

Permalink
Merge pull request #3 from wangqj/master
Browse files Browse the repository at this point in the history
add func to Get Schema information
  • Loading branch information
tianxiaoliang committed May 17, 2019
2 parents e08ecdf + 1b31270 commit 5e36907
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion swagger_webservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (sws SwaggerService) WriteToFile() {

// RegisterSwaggerService add the WebService that provides the API documentation of all services
// conform the Swagger documentation specifcation. (https://github.com/wordnik/swagger-core/wiki).
func RegisterSwaggerService(config Config, wsContainer *restful.Container) {
func RegisterSwaggerService(config Config, wsContainer *restful.Container) *SwaggerService {
sws := newSwaggerService(config)
sws.WriteToFile()
if sws.config.OpenService == true {
Expand Down Expand Up @@ -125,6 +125,7 @@ func RegisterSwaggerService(config Config, wsContainer *restful.Container) {
LogInfo("[restful/swagger] Swagger(File)Path is empty ; no UI is served")
}
}
return sws
}

func staticPathFromRoute(r restful.Route) string {
Expand Down Expand Up @@ -493,3 +494,16 @@ func asParamType(kind int) string {
}
return ""
}

//Get Schema information
func (sws *SwaggerService) GetSchemaInfoList() ([]string, error) {
var result []string
for _, listing := range sws.apiDeclarationMap.List {
list, err := yaml.Marshal(listing)
if err != nil {
return nil, err
}
result = append(result, string(list))
}
return result, nil
}

0 comments on commit 5e36907

Please sign in to comment.