Skip to content

Commit

Permalink
fix: fix generate date error in Get request
Browse files Browse the repository at this point in the history
  • Loading branch information
asjdf committed Feb 20, 2024
1 parent eddf8c8 commit 81d4def
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package generator

import (
"bytes"
"fmt"
"path/filepath"
"strings"
"text/template"
Expand Down Expand Up @@ -49,7 +48,7 @@ func New(paramsMap map[string]string) (*TypeScriptGRPCGatewayGenerator, error) {
}, nil
}

// Generate take a code generator request and returns a response. it analyse request with registry and use the generated data to render ts files
// Generate take a code generator request and returns a response. it analyses request with registry and use the generated data to render ts files
func (t *TypeScriptGRPCGatewayGenerator) Generate(req *plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorResponse, error) {
resp := &plugin.CodeGeneratorResponse{}

Expand Down Expand Up @@ -97,7 +96,7 @@ func (t *TypeScriptGRPCGatewayGenerator) generateFile(fileData *data.File, tmpl
w := bytes.NewBufferString("")

if fileData.IsEmpty() {
w.Write([]byte(fmt.Sprintln("export default {}")))
w.Write([]byte("export default {}\n"))
} else {
err := tmpl.Execute(w, fileData)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions generator/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ function flattenRequestPayload<T extends RequestPayload>(
objectToMerge = flattenRequestPayload(value as RequestPayload, newPath);
} else if (isNonZeroValuePrimitive || isNonEmptyPrimitiveArray) {
objectToMerge = { [newPath]: value };
} else if (value instanceof Date){
objectToMerge = { [newPath]: value.toISOString() };
}
return { ...acc, ...objectToMerge };
Expand Down

0 comments on commit 81d4def

Please sign in to comment.