Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion kotlin/kotlin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
DefaultMap = "emptyMap()"
DefaultLocalTime = "LocalTime.now()"

version = "1.0.1"
version = "1.0.2"
)

var (
Expand Down Expand Up @@ -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
})
Expand Down
7 changes: 7 additions & 0 deletions kotlin/testdata/arith.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 13 additions & 1 deletion kotlin/testdata/protocol.generated.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion kotlin/testdata/rpc.generated.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 10 additions & 1 deletion kotlin/testdata/testdata_zenrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.