Skip to content

Commit

Permalink
Merge pull request #2 from dwjohnston/various-clean-ups
Browse files Browse the repository at this point in the history
Fixes the generator ignore file, adds make file.
  • Loading branch information
David Johnston committed Apr 14, 2023
2 parents 40a8a56 + e604ca9 commit ee42799
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.DS_Store

2 changes: 2 additions & 0 deletions Makefile
@@ -0,0 +1,2 @@
generate_backend_from_source_spec:
openapi-generator generate -g go-server -o ./backend -i ./spec/petstore-separate/spec/swagger.json
2 changes: 1 addition & 1 deletion backend/.openapi-generator-ignore
Expand Up @@ -21,4 +21,4 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
api_default_service.go
go/api_default_service.go
2 changes: 0 additions & 2 deletions backend/.openapi-generator/FILES
@@ -1,11 +1,9 @@
.openapi-generator-ignore
Dockerfile
README.md
api/openapi.yaml
go.mod
go/api.go
go/api_default.go
go/api_default_service.go
go/error.go
go/helpers.go
go/impl.go
Expand Down
2 changes: 1 addition & 1 deletion backend/.openapi-generator/VERSION
@@ -1 +1 @@
6.2.1
6.5.0
2 changes: 1 addition & 1 deletion backend/README.md
Expand Up @@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://openapi-generator.tech)

- API version: 1.0.0
- Build date: 2022-11-23T16:08:42.037+11:00[Australia/Melbourne]
- Build date: 2023-04-14T12:46:04.670471+10:00[Australia/Melbourne]
For more information, please visit [http://swagger.io](http://swagger.io)


Expand Down
18 changes: 15 additions & 3 deletions backend/go/routers.go
Expand Up @@ -69,7 +69,11 @@ func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
w.WriteHeader(http.StatusOK)
}

return json.NewEncoder(w).Encode(i)
if i != nil {
return json.NewEncoder(w).Encode(i)
}

return nil
}

// ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
Expand Down Expand Up @@ -160,7 +164,15 @@ func parseInt32Parameter(param string, required bool) (int32, error) {
}

// parseBoolParameter parses a string parameter to a bool
func parseBoolParameter(param string) (bool, error) {
func parseBoolParameter(param string, required bool) (bool, error) {
if param == "" {
if required {
return false, errors.New(errMsgRequiredMissing)
}

return false, nil
}

val, err := strconv.ParseBool(param)
if err != nil {
return false, err
Expand Down Expand Up @@ -215,4 +227,4 @@ func parseInt32ArrayParameter(param, delim string, required bool) ([]int32, erro
}

return ints, nil
}
}

0 comments on commit ee42799

Please sign in to comment.