Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLuo committed Jul 9, 2022
1 parent 36fbf97 commit 207179d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ or
##### Arguments
- **field**: The name of the method argument whose value is mapped to the HTTP request body.
+ Optional: When omitted, a struct containing all the arguments, which are not located in **path**/**query**/**header**, will automatically be mapped to the HTTP request body.
+ Optional: When omitted, a struct containing all the arguments (except context.Context), which are not located in **path**/**query**/**header**, will automatically be mapped to the HTTP request body.
+ The special name `-` can be used, to define that there is no HTTP request body. As a result, every argument, which is not located in **path**/**query**/**header**, will automatically be mapped to one or more query parameters.
- **manipulation**:
+ Syntax: `<argName> name=<name> type=<type> descr=<descr>`
Expand Down Expand Up @@ -712,14 +712,14 @@ type Service interface {

### Encoding and decoding

See the [HTTP Codec](https://github.com/RussellLuo/kun/blob/master/pkg/codec/httpcodec/codec.go#L8-L22) interface.
See the [HTTP Codec](https://github.com/RussellLuo/kun/blob/master/pkg/httpcodec/codec.go#L8-L23) interface.

Also see [here](https://github.com/RussellLuo/kun/issues/8) for examples.


### OAS Schema

See the [OAS Schema](https://github.com/RussellLuo/kun/blob/master/pkg/oasv2/schema.go#L18-L21) interface.
See the [OAS Schema](https://github.com/RussellLuo/kun/blob/master/pkg/oas2/schema.go#L18-L21) interface.


## gRPC
Expand Down Expand Up @@ -794,7 +794,7 @@ See the [OAS Schema](https://github.com/RussellLuo/kun/blob/master/pkg/oasv2/sch
- **type**: The type of the event.
+ Optional: Defaults to the name of the corresponding method (snake-case, or lower-camel-case if `-snake=false`) if not specified.
- **data**: The name of the method argument whose value is mapped to the event data.
+ Optional: When omitted, a struct containing all the arguments will automatically be mapped to the event data.
+ Optional: When omitted, a struct containing all the arguments (except context.Context) will automatically be mapped to the event data.
##### Examples
Expand Down
4 changes: 2 additions & 2 deletions examples/eventsvc/event.go

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

3 changes: 1 addition & 2 deletions gen/http/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ func (b *OpBuilder) inferAnnotationParams(methodName string, arg *ifacetool.Para
fmt.Printf("WARNING: manually specified `in:%s` is ignored for struct argument `%s` in method %s\n", a.In, a.ArgName, p.methodName)
}*/

NextField:
for i := 0; i < t.NumFields(); i++ {
var typeName string
switch ft := t.Field(i).Type().Underlying().(type) {
Expand Down Expand Up @@ -390,7 +389,7 @@ func (b *OpBuilder) inferAnnotationParams(methodName string, arg *ifacetool.Para

if field.Omitted {
// Omit this field.
continue NextField
continue
}

params = append(params, field.Params...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oas2/oas2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
{{- end}}
`))

funcs = map[string]interface{}{
funcs = template.FuncMap{
"basicJSONType": func(typ string) string {
switch typ {
case "bool":
Expand Down

0 comments on commit 207179d

Please sign in to comment.