forked from loafle/openapi-generator-original
[Go-server] Fix formatting of go-server generated code (#7162)
* Add missing go-server petstore batch script * Make go-server confirm to gofmt
This commit is contained in:
@@ -6,14 +6,9 @@ import (
|
||||
)
|
||||
|
||||
type {{classname}} struct {
|
||||
}{{#operation}}
|
||||
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
func {{nickname}}(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}{{/operation}}{{/operations}}
|
||||
|
||||
@@ -20,4 +20,4 @@ func Logger(inner http.Handler, name string) http.Handler {
|
||||
time.Since(start),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
// WARNING!
|
||||
// Change this to a fully-qualified import path
|
||||
// once you place this file into your project.
|
||||
@@ -9,14 +12,12 @@ import (
|
||||
// sw "github.com/myname/myrepo/{{apiPath}}"
|
||||
//
|
||||
sw "./{{apiPath}}"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Printf("Server started")
|
||||
|
||||
router := sw.NewRouter()
|
||||
|
||||
|
||||
log.Fatal(http.ListenAndServe(":{{serverPort}}", router))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
@@ -42,13 +43,12 @@ var routes = Routes{
|
||||
"GET",
|
||||
"{{{basePathWithoutHost}}}/",
|
||||
Index,
|
||||
},
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
||||
},{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
||||
|
||||
Route{
|
||||
"{{operationId}}",
|
||||
"{{httpMethod}}",
|
||||
"{{{basePathWithoutHost}}}{{{path}}}",
|
||||
{{operationId}},
|
||||
},
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
},{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user