-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(goctl): support nested struct (#4211)
- Loading branch information
Showing
28 changed files
with
317 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "demo title" | ||
desc: "demo desc" | ||
author: "keson.an" | ||
date: "2024-06-25" | ||
version: "v1" | ||
) | ||
|
||
// empty structure | ||
type Foo { | ||
} | ||
|
||
// type lit | ||
type Bar { | ||
Foo int `json:"foo"` | ||
Bar bool `json:"bar"` | ||
Baz []string `json:"baz"` | ||
Qux map[string]string `json:"qux"` | ||
} | ||
|
||
type Baz { | ||
Foo `json:"foo"` | ||
// array type | ||
Arr [2]int `json:"arr"` | ||
// nested type | ||
Bar { | ||
Foo string `json:"foo"` | ||
Bar bool `json:"bar"` | ||
Baz { | ||
Foo string `json:"foo"` | ||
Bar bool `json:"bar"` | ||
} | ||
Qux { | ||
Foo string `json:"foo"` | ||
Bar bool `json:"bar"` | ||
} `json:"qux"` | ||
} `json:"bar"` | ||
} | ||
|
||
|
||
type UpdateReq { | ||
Arg1 string `json:"arg1"` | ||
} | ||
|
||
type ListItem { | ||
Value1 string `json:"value1"` | ||
} | ||
|
||
type LoginReq { | ||
Username string `json:"username"` | ||
Password string `json:"password"` | ||
} | ||
|
||
type LoginResp { | ||
Name string `json:"name"` | ||
} | ||
|
||
type FormExampleReq { | ||
Name string `form:"name"` | ||
} | ||
|
||
type PathExampleReq { | ||
ID string `path:"id"` | ||
} | ||
|
||
type PathExampleResp { | ||
Name string `json:"name"` | ||
} | ||
|
||
@server( | ||
jwt: Auth | ||
prefix: /v1 | ||
group: g1 | ||
timeout: 3s | ||
middleware: AuthInterceptor | ||
maxBytes: 1048576 | ||
) | ||
service Foo { | ||
@handler ping | ||
get /ping | ||
|
||
@handler update | ||
post /update (UpdateReq) | ||
|
||
@handler list | ||
get /list returns ([]ListItem) | ||
|
||
@handler login | ||
post /login (LoginReq) returns (LoginResp) | ||
|
||
@handler formExample | ||
post /form/example (FormExampleReq) | ||
|
||
@handler pathExample | ||
get /path/example/:id (PathExampleReq) returns (PathExampleResp) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.