diff --git a/kotlin/kotlin_client.go b/kotlin/kotlin_client.go index de4810e..4ba8d17 100644 --- a/kotlin/kotlin_client.go +++ b/kotlin/kotlin_client.go @@ -36,7 +36,7 @@ const ( DefaultMap = "emptyMap()" DefaultLocalTime = "LocalTime.now()" - version = "1.0.1" + version = "1.0.2" ) var ( @@ -259,6 +259,21 @@ func (g *Generator) sortTemplateData(data *templateData) { return data.Methods[i].Name < data.Methods[j].Name }) + // sort errs by erName (it's a number) because they was located in map + for _, m := range data.Methods { + sort.Slice(m.Errors, func(i, j int) bool { + iNum, err := strconv.Atoi(m.Errors[i].Name) + if err != nil { + return m.Errors[i].Name < m.Errors[j].Name + } + jNum, err := strconv.Atoi(m.Errors[j].Name) + if err != nil { + return m.Errors[i].Name < m.Errors[j].Name + } + return iNum < jNum + }) + } + sort.Slice(data.Models, func(i, j int) bool { return data.Models[i].Name < data.Models[j].Name }) diff --git a/kotlin/testdata/arith.go b/kotlin/testdata/arith.go index 6e9cc87..53ed216 100644 --- a/kotlin/testdata/arith.go +++ b/kotlin/testdata/arith.go @@ -44,6 +44,13 @@ type Point struct { type SecondPoint struct { } +//zenrpc:404 was not found +//zenrpc:501 example +//zenrpc:502 given example is different from user's +//zenrpc:503 failed to create new example +//zenrpc:504 failed to send example +//zenrpc:505 given example is invalid +//zenrpc:506 given example is blocked func (as ArithService) GetByID(ctx context.Context, cartId string, categoryId int, baseID int, id int) (*Point, error) { return &Point{}, nil } diff --git a/kotlin/testdata/protocol.generated.kt b/kotlin/testdata/protocol.generated.kt index 2feb4de..1e2a975 100644 --- a/kotlin/testdata/protocol.generated.kt +++ b/kotlin/testdata/protocol.generated.kt @@ -1,4 +1,4 @@ -/// Code generated from jsonrpc schema by rpcgen v2.5.x with kotlin v1.0.1; DO NOT EDIT. +/// Code generated from jsonrpc schema by rpcgen v2.5.x with kotlin v1.0.2; DO NOT EDIT. package api import com.google.gson.reflect.TypeToken @@ -109,6 +109,18 @@ interface Api : Transport { ) /** + * + * Коды ошибок: + * + * "404": "was not found", + * "501": "example", + * "502": "given example is different from user's", + * "503": "failed to create new example", + * "504": "failed to send example", + * "505": "given example is invalid", + * "506": "given example is blocked", + * + * * @return */ fun arithGetByID( diff --git a/kotlin/testdata/rpc.generated.kt b/kotlin/testdata/rpc.generated.kt index ef61d6c..cdd3039 100644 --- a/kotlin/testdata/rpc.generated.kt +++ b/kotlin/testdata/rpc.generated.kt @@ -1,4 +1,4 @@ -/// Code generated from jsonrpc schema by rpcgen v2.5.x with kotlin v1.0.1; DO NOT EDIT. +/// Code generated from jsonrpc schema by rpcgen v2.5.x with kotlin v1.0.2; DO NOT EDIT. package api.model import java.time.LocalTime diff --git a/kotlin/testdata/testdata_zenrpc.go b/kotlin/testdata/testdata_zenrpc.go index 55ff2c8..10160dc 100644 --- a/kotlin/testdata/testdata_zenrpc.go +++ b/kotlin/testdata/testdata_zenrpc.go @@ -1,4 +1,4 @@ -// Code generated by zenrpc v2.2.12; DO NOT EDIT. +// Code generated by zenrpc v2.3.0; DO NOT EDIT. package testdata @@ -382,6 +382,15 @@ func (ArithService) SMD() smd.ServiceInfo { }, }, }, + Errors: map[int]string{ + 404: "was not found", + 501: "example", + 502: "given example is different from user's", + 503: "failed to create new example", + 504: "failed to send example", + 505: "given example is invalid", + 506: "given example is blocked", + }, }, "GetSecondIds": { Parameters: []smd.JSONSchema{},