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:
parent
e70bdf17f2
commit
2e348b27f7
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l go-server -o samples\server\petstore\go-api-server
|
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l go-server -o samples\server\petstore\go-api-server -DpackageName=petstoreserver -Dservice
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l go -o samples\client\petstore\go
|
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l go -o samples\client\petstore\go -DpackageName=petstore
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
@ -6,14 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type {{classname}} struct {
|
type {{classname}} struct {
|
||||||
|
}{{#operation}}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#operation}}
|
|
||||||
func {{nickname}}(w http.ResponseWriter, r *http.Request) {
|
func {{nickname}}(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}{{/operation}}{{/operations}}
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
{{/operations}}
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
// WARNING!
|
// WARNING!
|
||||||
// Change this to a fully-qualified import path
|
// Change this to a fully-qualified import path
|
||||||
// once you place this file into your project.
|
// once you place this file into your project.
|
||||||
@ -9,8 +12,6 @@ import (
|
|||||||
// sw "github.com/myname/myrepo/{{apiPath}}"
|
// sw "github.com/myname/myrepo/{{apiPath}}"
|
||||||
//
|
//
|
||||||
sw "./{{apiPath}}"
|
sw "./{{apiPath}}"
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package {{packageName}}
|
package {{packageName}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,13 +43,12 @@ var routes = Routes{
|
|||||||
"GET",
|
"GET",
|
||||||
"{{{basePathWithoutHost}}}/",
|
"{{{basePathWithoutHost}}}/",
|
||||||
Index,
|
Index,
|
||||||
},
|
},{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
|
|
||||||
Route{
|
Route{
|
||||||
"{{operationId}}",
|
"{{operationId}}",
|
||||||
"{{httpMethod}}",
|
"{{httpMethod}}",
|
||||||
"{{{basePathWithoutHost}}}{{{path}}}",
|
"{{{basePathWithoutHost}}}{{{path}}}",
|
||||||
{{operationId}},
|
{{operationId}},
|
||||||
},
|
},{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
2.2.3-SNAPSHOT
|
2.3.0-SNAPSHOT
|
@ -13,7 +13,8 @@ To see how to make this your own, look here:
|
|||||||
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
|
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
|
||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Build date: 2017-03-12T22:24:15.399-05:00
|
- Build date: 2017-12-12T20:26:23.341Z
|
||||||
|
|
||||||
|
|
||||||
### Running the server
|
### Running the server
|
||||||
To run the server, follow these simple steps:
|
To run the server, follow these simple steps:
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Pet struct {
|
type Pet struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddPet(w http.ResponseWriter, r *http.Request) {
|
func AddPet(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -47,4 +46,3 @@ func UploadFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package petstoreserver
|
package petstoreserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -183,5 +184,4 @@ var routes = Routes{
|
|||||||
"/v2/user/{username}",
|
"/v2/user/{username}",
|
||||||
UpdateUser,
|
UpdateUser,
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Store struct {
|
type Store struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOrder(w http.ResponseWriter, r *http.Request) {
|
func DeleteOrder(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -27,4 +26,3 @@ func PlaceOrder(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateUser(w http.ResponseWriter, r *http.Request) {
|
func CreateUser(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -47,4 +46,3 @@ func UpdateUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
// WARNING!
|
// WARNING!
|
||||||
// Change this to a fully-qualified import path
|
// Change this to a fully-qualified import path
|
||||||
// once you place this file into your project.
|
// once you place this file into your project.
|
||||||
@ -9,8 +12,6 @@ import (
|
|||||||
// sw "github.com/myname/myrepo/go"
|
// sw "github.com/myname/myrepo/go"
|
||||||
//
|
//
|
||||||
sw "./go"
|
sw "./go"
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user