Skip to content
Open
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
11,175 changes: 0 additions & 11,175 deletions examples/ex_github/oas_json_gen.go

Large diffs are not rendered by default.

1,804 changes: 1,353 additions & 451 deletions examples/ex_github/oas_schemas_gen.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions gen/_template/json/encoders_alias.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- /*gotype: github.com/ogen-go/ogen/gen/ir.Type*/ -}}
{{- define "json/encoders_alias" }}
{{- $a := $.AliasTo }}
{{- if ne $a.Kind "struct" }}
// Encode encodes {{ $.Name }} as json.
func (s {{ $.ReadOnlyReceiver }}) Encode(e *jx.Encoder) {
{{- if $a.DoPassByPointer }}
Expand Down Expand Up @@ -34,3 +35,4 @@ func (s *{{ $.Name }}) Decode(d *jx.Decoder) error {
}

{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion gen/_template/request_decode.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *{{ if $op.WebhookInfo }}Webhook{{ end }}Server) decode{{ $op.Name }}Req
{
var unwrapped {{ $t.AliasTo.Go -}}
{{ template "decode_form_request" elem $t.AliasTo "unwrapped" }}
{{ $v }} = {{ $t.Go }}(unwrapped)
{{ $v }} = {{ $t.Go }}{unwrapped}
}
{{- else if $t.IsGeneric }}
{
Expand Down
6 changes: 6 additions & 0 deletions gen/_template/schema/alias.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{{- /*gotype: github.com/ogen-go/ogen/gen/ir.Type*/ -}}
{{- define "schema/alias" }}
{{- if eq $.AliasTo.Kind "struct" }}
type {{ $.Name }} struct {
{{ $.AliasTo.Go }}
}
{{ else }}
type {{ $.Name }} {{ $.AliasTo.Go }}
{{- end }}
{{ end }}
16 changes: 12 additions & 4 deletions internal/integration/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ func TestRequests(t *testing.T) {
t.Run("AllRequestBodies", func(t *testing.T) {
reqs := []api.AllRequestBodiesReq{
&api.AllRequestBodiesApplicationJSON{
Name: testData,
SimpleObject: api.SimpleObject{
Name: testData,
},
},
&api.AllRequestBodiesReqApplicationOctetStream{
Data: strings.NewReader(testData),
},
&api.AllRequestBodiesApplicationXWwwFormUrlencoded{
Name: testData,
SimpleObject: api.SimpleObject{
Name: testData,
},
},
&api.SimpleObjectMultipart{
Name: testData,
Expand All @@ -152,13 +156,17 @@ func TestRequests(t *testing.T) {
t.Run("AllRequestBodiesOptional", func(t *testing.T) {
reqs := []api.AllRequestBodiesOptionalReq{
&api.AllRequestBodiesOptionalApplicationJSON{
Name: testData,
SimpleObject: api.SimpleObject{
Name: testData,
},
},
&api.AllRequestBodiesOptionalReqApplicationOctetStream{
Data: strings.NewReader(testData),
},
&api.AllRequestBodiesOptionalApplicationXWwwFormUrlencoded{
Name: testData,
SimpleObject: api.SimpleObject{
Name: testData,
},
},
&api.SimpleObjectMultipart{
Name: testData,
Expand Down
100 changes: 0 additions & 100 deletions internal/integration/test_http_requests/oas_json_gen.go

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

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

16 changes: 12 additions & 4 deletions internal/integration/test_http_requests/oas_schemas_gen.go

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

Loading