Repository: ogen-go/ogen
Pull request #691 (2022-11-24 03:31:38)

fix(gen): add special case for `anyOf` with `number` and `integer`

codecov[bot]: # [Codecov](https://codecov.io/gh/ogen-go/ogen/pull/691?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go) Report
Base: **74.08**% // Head: **74.12**% // Increases project coverage by **`+0.04%`** :tada:
> Coverage data is based on head [(`db45837`)](https://codecov.io/gh/ogen-go/ogen/pull/691?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go) compared to base [(`805142a`)](https://codecov.io/gh/ogen-go/ogen/commit/805142a59527d5697572aae42e783d5dfee678c0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go).
> Patch coverage: 88.70% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #691      +/-   ##
==========================================
+ Coverage   74.08%   74.12%   +0.04%     
==========================================
  Files         173      173              
  Lines       12500    12555      +55     
==========================================
+ Hits         9260     9306      +46     
- Misses       2761     2767       +6     
- Partials      479      482       +3     
```


| [Impacted Files](https://codecov.io/gh/ogen-go/ogen/pull/691?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go) | Coverage Δ | |
|---|---|---|
| [gen/schema\_gen\_sum.go](https://codecov.io/gh/ogen-go/ogen/pull/691/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go#diff-Z2VuL3NjaGVtYV9nZW5fc3VtLmdv) | `70.52% <78.26%> (-0.05%)` | :arrow_down: |
| [gen/ir/template\_helpers.go](https://codecov.io/gh/ogen-go/ogen/pull/691/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go#diff-Z2VuL2lyL3RlbXBsYXRlX2hlbHBlcnMuZ28=) | `83.22% <94.87%> (+3.91%)` | :arrow_up: |
| [gen/gen\_contents.go](https://codecov.io/gh/ogen-go/ogen/pull/691/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go#diff-Z2VuL2dlbl9jb250ZW50cy5nbw==) | `74.26% <0.00%> (-0.74%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/ogen-go/ogen/pull/691?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ogen-go).


Patch:
diff --git a/examples/ex_github/oas_json_gen.go b/examples/ex_github/oas_json_gen.go
index e0587f5c..97cd5818 100644
--- a/examples/ex_github/oas_json_gen.go
+++ b/examples/ex_github/oas_json_gen.go
@@ -37240,18 +37240,6 @@ func (s *EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue)
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringEnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue
-	case jx.Object:
-		if err := s.EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue1EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue
 	case jx.Array:
 		s.AnyArray = make([]jx.Raw, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -37267,6 +37255,18 @@ func (s *EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue)
 			return err
 		}
 		s.Type = AnyArrayEnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue
+	case jx.Object:
+		if err := s.EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue1EnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringEnterpriseAdminUpdateAttributeForEnterpriseGroupReqOperationsItemValue
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -56937,6 +56937,11 @@ func (s *IssueLabelsItem) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Object:
+		if err := s.IssueLabelsItem1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = IssueLabelsItem1IssueLabelsItem
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -56944,11 +56949,6 @@ func (s *IssueLabelsItem) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringIssueLabelsItem
-	case jx.Object:
-		if err := s.IssueLabelsItem1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = IssueLabelsItem1IssueLabelsItem
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -60001,6 +60001,11 @@ func (s *IssuesCreateReqLabelsItem) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Object:
+		if err := s.IssuesCreateReqLabelsItem1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = IssuesCreateReqLabelsItem1IssuesCreateReqLabelsItem
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -60008,11 +60013,6 @@ func (s *IssuesCreateReqLabelsItem) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringIssuesCreateReqLabelsItem
-	case jx.Object:
-		if err := s.IssuesCreateReqLabelsItem1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = IssuesCreateReqLabelsItem1IssuesCreateReqLabelsItem
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -60163,13 +60163,6 @@ func (s *IssuesCreateReqMilestone) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringIssuesCreateReqMilestone
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -60177,6 +60170,13 @@ func (s *IssuesCreateReqMilestone) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntIssuesCreateReqMilestone
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringIssuesCreateReqMilestone
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -60213,13 +60213,6 @@ func (s *IssuesCreateReqTitle) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringIssuesCreateReqTitle
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -60227,6 +60220,13 @@ func (s *IssuesCreateReqTitle) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntIssuesCreateReqTitle
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringIssuesCreateReqTitle
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -61832,6 +61832,11 @@ func (s *IssuesUpdateReqLabelsItem) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Object:
+		if err := s.IssuesUpdateReqLabelsItem1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = IssuesUpdateReqLabelsItem1IssuesUpdateReqLabelsItem
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -61839,11 +61844,6 @@ func (s *IssuesUpdateReqLabelsItem) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringIssuesUpdateReqLabelsItem
-	case jx.Object:
-		if err := s.IssuesUpdateReqLabelsItem1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = IssuesUpdateReqLabelsItem1IssuesUpdateReqLabelsItem
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -61994,13 +61994,6 @@ func (s *IssuesUpdateReqMilestone) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringIssuesUpdateReqMilestone
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -62008,6 +62001,13 @@ func (s *IssuesUpdateReqMilestone) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntIssuesUpdateReqMilestone
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringIssuesUpdateReqMilestone
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -62084,13 +62084,6 @@ func (s *IssuesUpdateReqTitle) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringIssuesUpdateReqTitle
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -62098,6 +62091,13 @@ func (s *IssuesUpdateReqTitle) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntIssuesUpdateReqTitle
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringIssuesUpdateReqTitle
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -133181,11 +133181,6 @@ func (s *ReposAddAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposAddAppAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposAddAppAccessRestrictionsReq0ReposAddAppAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -133201,6 +133196,11 @@ func (s *ReposAddAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposAddAppAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposAddAppAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposAddAppAccessRestrictionsReq0ReposAddAppAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -133605,11 +133605,6 @@ func (s *ReposAddStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposAddStatusCheckContextsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposAddStatusCheckContextsReq0ReposAddStatusCheckContextsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -133625,6 +133620,11 @@ func (s *ReposAddStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposAddStatusCheckContextsReq
+	case jx.Object:
+		if err := s.ReposAddStatusCheckContextsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposAddStatusCheckContextsReq0ReposAddStatusCheckContextsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -133824,11 +133824,6 @@ func (s *ReposAddTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposAddTeamAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposAddTeamAccessRestrictionsReq0ReposAddTeamAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -133844,6 +133839,11 @@ func (s *ReposAddTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposAddTeamAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposAddTeamAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposAddTeamAccessRestrictionsReq0ReposAddTeamAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -134043,11 +134043,6 @@ func (s *ReposAddUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposAddUserAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposAddUserAccessRestrictionsReq0ReposAddUserAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -134063,6 +134058,11 @@ func (s *ReposAddUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposAddUserAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposAddUserAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposAddUserAccessRestrictionsReq0ReposAddUserAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -140768,11 +140768,6 @@ func (s *ReposRemoveAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposRemoveAppAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposRemoveAppAccessRestrictionsReq0ReposRemoveAppAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -140788,6 +140783,11 @@ func (s *ReposRemoveAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposRemoveAppAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposRemoveAppAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposRemoveAppAccessRestrictionsReq0ReposRemoveAppAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -140989,11 +140989,6 @@ func (s *ReposRemoveStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposRemoveStatusCheckContextsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposRemoveStatusCheckContextsReq0ReposRemoveStatusCheckContextsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -141009,6 +141004,11 @@ func (s *ReposRemoveStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposRemoveStatusCheckContextsReq
+	case jx.Object:
+		if err := s.ReposRemoveStatusCheckContextsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposRemoveStatusCheckContextsReq0ReposRemoveStatusCheckContextsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -141208,11 +141208,6 @@ func (s *ReposRemoveTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposRemoveTeamAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposRemoveTeamAccessRestrictionsReq0ReposRemoveTeamAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -141228,6 +141223,11 @@ func (s *ReposRemoveTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposRemoveTeamAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposRemoveTeamAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposRemoveTeamAccessRestrictionsReq0ReposRemoveTeamAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -141427,11 +141427,6 @@ func (s *ReposRemoveUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposRemoveUserAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposRemoveUserAccessRestrictionsReq0ReposRemoveUserAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -141447,6 +141442,11 @@ func (s *ReposRemoveUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposRemoveUserAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposRemoveUserAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposRemoveUserAccessRestrictionsReq0ReposRemoveUserAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -141928,11 +141928,6 @@ func (s *ReposSetAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposSetAppAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposSetAppAccessRestrictionsReq0ReposSetAppAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -141948,6 +141943,11 @@ func (s *ReposSetAppAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposSetAppAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposSetAppAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposSetAppAccessRestrictionsReq0ReposSetAppAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -142149,11 +142149,6 @@ func (s *ReposSetStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposSetStatusCheckContextsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposSetStatusCheckContextsReq0ReposSetStatusCheckContextsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -142169,6 +142164,11 @@ func (s *ReposSetStatusCheckContextsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposSetStatusCheckContextsReq
+	case jx.Object:
+		if err := s.ReposSetStatusCheckContextsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposSetStatusCheckContextsReq0ReposSetStatusCheckContextsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -142368,11 +142368,6 @@ func (s *ReposSetTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposSetTeamAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposSetTeamAccessRestrictionsReq0ReposSetTeamAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -142388,6 +142383,11 @@ func (s *ReposSetTeamAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposSetTeamAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposSetTeamAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposSetTeamAccessRestrictionsReq0ReposSetTeamAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -142587,11 +142587,6 @@ func (s *ReposSetUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.ReposSetUserAccessRestrictionsReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = ReposSetUserAccessRestrictionsReq0ReposSetUserAccessRestrictionsReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -142607,6 +142602,11 @@ func (s *ReposSetUserAccessRestrictionsReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayReposSetUserAccessRestrictionsReq
+	case jx.Object:
+		if err := s.ReposSetUserAccessRestrictionsReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = ReposSetUserAccessRestrictionsReq0ReposSetUserAccessRestrictionsReq
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -169102,11 +169102,6 @@ func (s *UsersAddEmailForAuthenticatedReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.UsersAddEmailForAuthenticatedReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = UsersAddEmailForAuthenticatedReq0UsersAddEmailForAuthenticatedReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -169122,6 +169117,11 @@ func (s *UsersAddEmailForAuthenticatedReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayUsersAddEmailForAuthenticatedReq
+	case jx.Object:
+		if err := s.UsersAddEmailForAuthenticatedReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = UsersAddEmailForAuthenticatedReq0UsersAddEmailForAuthenticatedReq
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -170175,11 +170175,6 @@ func (s *UsersDeleteEmailForAuthenticatedReq) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.UsersDeleteEmailForAuthenticatedReq0.Decode(d); err != nil {
-			return err
-		}
-		s.Type = UsersDeleteEmailForAuthenticatedReq0UsersDeleteEmailForAuthenticatedReq
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -170195,6 +170190,11 @@ func (s *UsersDeleteEmailForAuthenticatedReq) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayUsersDeleteEmailForAuthenticatedReq
+	case jx.Object:
+		if err := s.UsersDeleteEmailForAuthenticatedReq0.Decode(d); err != nil {
+			return err
+		}
+		s.Type = UsersDeleteEmailForAuthenticatedReq0UsersDeleteEmailForAuthenticatedReq
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -173092,25 +173092,6 @@ func (s *ValidationErrorErrorsItemValue) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullValidationErrorErrorsItemValue
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringValidationErrorErrorsItemValue
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntValidationErrorErrorsItemValue
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -173126,6 +173107,25 @@ func (s *ValidationErrorErrorsItemValue) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayValidationErrorErrorsItemValue
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullValidationErrorErrorsItemValue
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntValidationErrorErrorsItemValue
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringValidationErrorErrorsItemValue
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -173751,13 +173751,6 @@ func (s *WebhookConfigInsecureSsl) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringWebhookConfigInsecureSsl
 	case jx.Number:
 		v, err := d.Float64()
 		s.Float64 = float64(v)
@@ -173765,6 +173758,13 @@ func (s *WebhookConfigInsecureSsl) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = Float64WebhookConfigInsecureSsl
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringWebhookConfigInsecureSsl
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
diff --git a/examples/ex_gotd/oas_json_gen.go b/examples/ex_gotd/oas_json_gen.go
index 9782977c..15ff8eeb 100644
--- a/examples/ex_gotd/oas_json_gen.go
+++ b/examples/ex_gotd/oas_json_gen.go
@@ -11673,13 +11673,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int64()
 		s.Int64 = int64(v)
@@ -11687,6 +11680,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = Int64ID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -20714,6 +20714,11 @@ func (s *KeyboardButton) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Object:
+		if err := s.KeyboardButtonObject.Decode(d); err != nil {
+			return err
+		}
+		s.Type = KeyboardButtonObjectKeyboardButton
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -20721,11 +20726,6 @@ func (s *KeyboardButton) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringKeyboardButton
-	case jx.Object:
-		if err := s.KeyboardButtonObject.Decode(d); err != nil {
-			return err
-		}
-		s.Type = KeyboardButtonObjectKeyboardButton
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -31647,11 +31647,6 @@ func (s *ResultMessageOrBooleanResult) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.Message.Decode(d); err != nil {
-			return err
-		}
-		s.Type = MessageResultMessageOrBooleanResult
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -31659,6 +31654,11 @@ func (s *ResultMessageOrBooleanResult) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolResultMessageOrBooleanResult
+	case jx.Object:
+		if err := s.Message.Decode(d); err != nil {
+			return err
+		}
+		s.Type = MessageResultMessageOrBooleanResult
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
diff --git a/examples/ex_openapi/output.gen.go b/examples/ex_openapi/output.gen.go
index a98d2b22..81140a15 100644
--- a/examples/ex_openapi/output.gen.go
+++ b/examples/ex_openapi/output.gen.go
@@ -14996,11 +14996,6 @@ func (s *SchemaAdditionalProperties) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Object:
-		if err := s.SchemaOrReference.Decode(d); err != nil {
-			return err
-		}
-		s.Type = SchemaOrReferenceSchemaAdditionalProperties
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -15008,6 +15003,11 @@ func (s *SchemaAdditionalProperties) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolSchemaAdditionalProperties
+	case jx.Object:
+		if err := s.SchemaOrReference.Decode(d); err != nil {
+			return err
+		}
+		s.Type = SchemaOrReferenceSchemaAdditionalProperties
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
diff --git a/examples/ex_telegram/oas_json_gen.go b/examples/ex_telegram/oas_json_gen.go
index 1c7bb01f..cb5780f3 100644
--- a/examples/ex_telegram/oas_json_gen.go
+++ b/examples/ex_telegram/oas_json_gen.go
@@ -11195,13 +11195,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int64()
 		s.Int64 = int64(v)
@@ -11209,6 +11202,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = Int64ID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -20218,6 +20218,11 @@ func (s *KeyboardButton) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Object:
+		if err := s.KeyboardButtonObject.Decode(d); err != nil {
+			return err
+		}
+		s.Type = KeyboardButtonObjectKeyboardButton
 	case jx.String:
 		v, err := d.Str()
 		s.String = string(v)
@@ -20225,11 +20230,6 @@ func (s *KeyboardButton) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringKeyboardButton
-	case jx.Object:
-		if err := s.KeyboardButtonObject.Decode(d); err != nil {
-			return err
-		}
-		s.Type = KeyboardButtonObjectKeyboardButton
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
diff --git a/gen/_template/json/encoders_sum.tmpl b/gen/_template/json/encoders_sum.tmpl
index 3868ce43..31d14fc2 100644
--- a/gen/_template/json/encoders_sum.tmpl
+++ b/gen/_template/json/encoders_sum.tmpl
@@ -31,14 +31,27 @@ func (s *{{ $.Name }}) Decode(d *jx.Decoder) error {
 	// Sum type {{ $d }}.
 	{{- if or ($d.Primitive) ($d.TypeDiscriminator) }}
 	switch t := d.Next(); t {
-	{{- range $s := $.SumOf }}
-	{{- with $typ := $s.JSON.Type }}
-	case jx.{{ $typ }}:
-	{{- else }}
-	case {{ $s.JSON.SumTypes }}:
-	{{- end }}
-		{{- template "json/dec" elem $s (printf "s.%s" $s.Name) }}
-		s.Type = {{ $s.Name }}{{ $.Name }}
+	{{- range $cse := $.TypeDiscriminator }}
+	case {{ $cse.JXTypes }}:
+		{{- with $intType := $cse.IntType }}
+		num, err := d.Num()
+		if err != nil {
+			return errors.Wrap(err, "parse number")
+		}
+		if d := jx.DecodeBytes(num); num.IsInt() {
+			{{- $s := $intType }}
+			{{- template "json/dec" elem $s (printf "s.%s" $s.Name) }}
+			s.Type = {{ $s.Name }}{{ $.Name }}
+		} else {
+        	{{- $s = $cse.Type }}
+        	{{- template "json/dec" elem $s (printf "s.%s" $s.Name) }}
+			s.Type = {{ $s.Name }}{{ $.Name }}
+		}
+		{{- else }}
+			{{- $s := $cse.Type }}
+			{{- template "json/dec" elem $s (printf "s.%s" $s.Name) }}
+			s.Type = {{ $s.Name }}{{ $.Name }}
+		{{- end }}
 	{{- end }}
 	default:
 		return errors.Errorf("unexpected json type %q", t)
@@ -104,12 +117,10 @@ func (s *{{ $.Name }}) Decode(d *jx.Decoder) error {
 	{{- range $s := $.SumOf }}
 	case {{ $s.Name }}{{ $.Name }}:
 		{{- template "json/dec" elem $s (printf "s.%s" $s.Name) }}
-	{{- end}}
+	{{- end }}
 	default:
 		return errors.Errorf("inferred invalid type: %s", s.Type)
 	}
-	{{- else if $d.Discriminator  }}
-
 	{{- end }}
 	return nil
 }
diff --git a/gen/ir/template_helpers.go b/gen/ir/template_helpers.go
index 7fb30248..aad22ab5 100644
--- a/gen/ir/template_helpers.go
+++ b/gen/ir/template_helpers.go
@@ -3,6 +3,8 @@ package ir
 import (
 	"fmt"
 
+	"golang.org/x/exp/slices"
+
 	"github.com/ogen-go/ogen/internal/naming"
 	"github.com/ogen-go/ogen/jsonschema"
 )
@@ -178,3 +180,62 @@ func (t *Type) SetFieldType(name string, newT *Type) {
 
 	panic(fmt.Sprintf("field with name %q not found", name))
 }
+
+// TypeDiscriminatorCase is a helper struct for describing type discriminator case.
+type TypeDiscriminatorCase struct {
+	// JXTypes is jx.Type values list.
+	JXTypes string
+	// Type is the type to be used for this case.
+	Type *Type
+	// IntType is the type to be used for this case when the type discriminator should distinguish
+	// between integer and float types.
+	IntType *Type
+}
+
+func (t *Type) TypeDiscriminator() (r []TypeDiscriminatorCase) {
+	if !t.Is(KindSum) || !t.SumSpec.TypeDiscriminator {
+		panic(unreachable(t))
+	}
+
+	var (
+		numberType *Type
+		intType    *Type
+	)
+	for _, v := range t.SumOf {
+		typ := v.JSON().Type()
+		if typ != "Number" {
+			if typ == "" {
+				typ = v.JSON().SumTypes()
+			} else {
+				typ = "jx." + typ
+			}
+			r = append(r, TypeDiscriminatorCase{
+				JXTypes: typ,
+				Type:    v,
+			})
+			continue
+		}
+		if s := v.Schema; s != nil && s.Type == jsonschema.Integer {
+			intType = v
+			continue
+		}
+		numberType = v
+	}
+
+	if intType != nil || numberType != nil {
+		cse := TypeDiscriminatorCase{
+			JXTypes: "jx.Number",
+			Type:    numberType,
+			IntType: intType,
+		}
+		if numberType == nil {
+			cse.Type = intType
+			cse.IntType = nil
+		}
+		r = append(r, cse)
+	}
+	slices.SortStableFunc(r, func(a, b TypeDiscriminatorCase) bool {
+		return a.JXTypes < b.JXTypes
+	})
+	return r
+}
diff --git a/gen/schema_gen_sum.go b/gen/schema_gen_sum.go
index bbf6cd0e..d5c30270 100644
--- a/gen/schema_gen_sum.go
+++ b/gen/schema_gen_sum.go
@@ -17,15 +17,26 @@ import (
 	"github.com/ogen-go/ogen/jsonschema"
 )
 
-func canUseTypeDiscriminator(sum []*ir.Type) bool {
+func canUseTypeDiscriminator(sum []*ir.Type, isOneOf bool) bool {
 	var (
 		// Collect map of variant kinds.
 		typeMap      = map[string]struct{}{}
 		collectTypes func(sum []*ir.Type)
+
+		getType = func(t *ir.Type) string {
+			typ := t.JSON().Type()
+			if s := t.Schema; s != nil && s.Type == jsonschema.Integer && typ == "Number" {
+				// Special case for anyOf with integer and number.
+				if !isOneOf {
+					typ = "Integer"
+				}
+			}
+			return typ
+		}
 	)
 	collectTypes = func(sum []*ir.Type) {
 		for _, variant := range sum {
-			typ := variant.JSON().Type()
+			typ := getType(variant)
 			if typ == "" {
 				if variant.IsSum() {
 					collectTypes(variant.SumOf)
@@ -36,10 +47,12 @@ func canUseTypeDiscriminator(sum []*ir.Type) bool {
 		}
 	}
 
+	var hasSumVariant bool
 	for _, s := range sum {
-		typ := s.JSON().Type()
+		typ := getType(s)
 		switch {
 		case s.IsSum():
+			hasSumVariant = true
 			switch s.JSON().Sum().Type {
 			case ir.SumJSONDiscriminator, ir.SumJSONFields:
 				typeMap["Object"] = struct{}{}
@@ -53,11 +66,19 @@ func canUseTypeDiscriminator(sum []*ir.Type) bool {
 		}
 
 		if _, ok := typeMap[typ]; ok {
-			// Type kind is not unique, so we can distinguish variants by type.
+			// Type kind is not unique, so we cannot distinguish variants by type.
 			return false
 		}
 		typeMap[typ] = struct{}{}
 	}
+
+	_, hasInteger := typeMap["Integer"]
+	_, hasNumber := typeMap["Number"]
+	if hasInteger && hasNumber && hasSumVariant {
+		// TODO(tdakkota): Do not allow type discriminator for nested sum types with integer and
+		// 	number variants at the same time. We can add support for this later, but it's not trivial.
+		return false
+	}
 	return true
 }
 
@@ -162,8 +183,9 @@ func (g *schemaGen) anyOf(name string, schema *jsonschema.Schema) (*ir.Type, err
 	}
 
 	// Here we try to create sum type from anyOf for variants with JSON type-based discriminator.
-	if canUseTypeDiscriminator(sum.SumOf) {
+	if canUseTypeDiscriminator(sum.SumOf, false) {
 		sum.SumSpec.TypeDiscriminator = true
+
 		for _, v := range sum.SumOf {
 			switch v.Kind {
 			case ir.KindPrimitive, ir.KindEnum:
@@ -306,7 +328,7 @@ func (g *schemaGen) oneOf(name string, schema *jsonschema.Schema) (*ir.Type, err
 	}
 
 	// 2nd case: distinguish by serialization type.
-	if canUseTypeDiscriminator(sum.SumOf) {
+	if canUseTypeDiscriminator(sum.SumOf, true) {
 		sum.SumSpec.TypeDiscriminator = true
 		return sum, nil
 	}
diff --git a/internal/integration/generate.go b/internal/integration/generate.go
index bc77d701..9ec2120b 100644
--- a/internal/integration/generate.go
+++ b/internal/integration/generate.go
@@ -22,6 +22,7 @@ package integration
 //
 //go:generate go run ../../cmd/ogen -v --clean --target referenced_path_item ../../_testdata/positive/referenced_pathItem.json
 //
-//go:generate go run ../../cmd/ogen -v --clean --generate-tests --target test_allof ../../_testdata/positive/allof.yml
+//go:generate go run ../../cmd/ogen -v --clean --generate-tests --target test_allof ../../_testdata/positive/allOf.yml
+//go:generate go run ../../cmd/ogen -v --clean --generate-tests --target test_anyof ../../_testdata/positive/anyOf.json
 //
 //go:generate go run ../../cmd/ogen -v --clean -target test_enum_naming ../../_testdata/positive/enum_naming.yml
diff --git a/internal/integration/sample_api/oas_cfg_gen.go b/internal/integration/sample_api/oas_cfg_gen.go
index 4ec341b5..96f82658 100644
--- a/internal/integration/sample_api/oas_cfg_gen.go
+++ b/internal/integration/sample_api/oas_cfg_gen.go
@@ -20,7 +20,6 @@ import (
 )
 
 var regexMap = map[string]ogenregex.Regexp{
-	"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$": ogenregex.MustCompile("^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"),
 	"^\\d-\\d$":                   ogenregex.MustCompile("^\\d-\\d$"),
 	"foo[^\r\n\u2028\u2029]*":     ogenregex.MustCompile("foo[^\r\n\u2028\u2029]*"),
 	"string_[^\r\n\u2028\u2029]*": ogenregex.MustCompile("string_[^\r\n\u2028\u2029]*"),
diff --git a/internal/integration/sample_api/oas_faker_gen.go b/internal/integration/sample_api/oas_faker_gen.go
index 0e8450d7..e0551d80 100644
--- a/internal/integration/sample_api/oas_faker_gen.go
+++ b/internal/integration/sample_api/oas_faker_gen.go
@@ -12,30 +12,6 @@ import (
 	"github.com/google/uuid"
 )
 
-// SetFake set fake values.
-func (s *AnyOfTest) SetFake() {
-	{
-		{
-			s.Medium = "string"
-		}
-	}
-	{
-		{
-			s.SizeLimit.SetFake()
-		}
-	}
-}
-
-// SetFake set fake values.
-func (s *AnyOfTestSizeLimit) SetFake() {
-	var elem int
-
-	{
-		elem = int(0)
-	}
-	s.SetInt(elem)
-}
-
 // SetFake set fake values.
 func (s *AnyTest) SetFake() {
 	{
@@ -743,15 +719,6 @@ func (s *OnlyPatternedPropsObject) SetFake() {
 	}
 }
 
-// SetFake set fake values.
-func (s *OptAnyOfTest) SetFake() {
-	var elem AnyOfTest
-	{
-		elem.SetFake()
-	}
-	s.SetTo(elem)
-}
-
 // SetFake set fake values.
 func (s *OptAnyTest) SetFake() {
 	var elem AnyTest
@@ -1233,11 +1200,6 @@ func (s *Pet) SetFake() {
 			s.TestAny.SetFake()
 		}
 	}
-	{
-		{
-			s.TestAnyOf.SetFake()
-		}
-	}
 	{
 		{
 			s.TestMaxProperties.SetFake()
diff --git a/internal/integration/sample_api/oas_json_gen.go b/internal/integration/sample_api/oas_json_gen.go
index 2dc8337c..9df4fe56 100644
--- a/internal/integration/sample_api/oas_json_gen.go
+++ b/internal/integration/sample_api/oas_json_gen.go
@@ -14,169 +14,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-// Encode implements json.Marshaler.
-func (s AnyOfTest) Encode(e *jx.Encoder) {
-	e.ObjStart()
-	s.encodeFields(e)
-	e.ObjEnd()
-}
-
-// encodeFields encodes fields.
-func (s AnyOfTest) encodeFields(e *jx.Encoder) {
-	{
-
-		e.FieldStart("medium")
-		e.Str(s.Medium)
-	}
-	{
-
-		e.FieldStart("sizeLimit")
-		s.SizeLimit.Encode(e)
-	}
-}
-
-var jsonFieldsNameOfAnyOfTest = [2]string{
-	0: "medium",
-	1: "sizeLimit",
-}
-
-// Decode decodes AnyOfTest from json.
-func (s *AnyOfTest) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTest to nil")
-	}
-	var requiredBitSet [1]uint8
-
-	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
-		switch string(k) {
-		case "medium":
-			requiredBitSet[0] |= 1 << 0
-			if err := func() error {
-				v, err := d.Str()
-				s.Medium = string(v)
-				if err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"medium\"")
-			}
-		case "sizeLimit":
-			requiredBitSet[0] |= 1 << 1
-			if err := func() error {
-				if err := s.SizeLimit.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"sizeLimit\"")
-			}
-		default:
-			return d.Skip()
-		}
-		return nil
-	}); err != nil {
-		return errors.Wrap(err, "decode AnyOfTest")
-	}
-	// Validate required fields.
-	var failures []validate.FieldError
-	for i, mask := range [1]uint8{
-		0b00000011,
-	} {
-		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
-			// Mask only required fields and check equality to mask using XOR.
-			//
-			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
-			// Bits of fields which would be set are actually bits of missed fields.
-			missed := bits.OnesCount8(result)
-			for bitN := 0; bitN < missed; bitN++ {
-				bitIdx := bits.TrailingZeros8(result)
-				fieldIdx := i*8 + bitIdx
-				var name string
-				if fieldIdx < len(jsonFieldsNameOfAnyOfTest) {
-					name = jsonFieldsNameOfAnyOfTest[fieldIdx]
-				} else {
-					name = strconv.Itoa(fieldIdx)
-				}
-				failures = append(failures, validate.FieldError{
-					Name:  name,
-					Error: validate.ErrFieldRequired,
-				})
-				// Reset bit.
-				result &^= 1 << bitIdx
-			}
-		}
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
-// Encode encodes AnyOfTestSizeLimit as json.
-func (s AnyOfTestSizeLimit) Encode(e *jx.Encoder) {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		e.Int(s.Int)
-	case StringAnyOfTestSizeLimit:
-		e.Str(s.String)
-	}
-}
-
-// Decode decodes AnyOfTestSizeLimit from json.
-func (s *AnyOfTestSizeLimit) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTestSizeLimit to nil")
-	}
-	// Sum type type_discriminator.
-	switch t := d.Next(); t {
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntAnyOfTestSizeLimit
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringAnyOfTestSizeLimit
-	default:
-		return errors.Errorf("unexpected json type %q", t)
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTestSizeLimit) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTestSizeLimit) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode implements json.Marshaler.
 func (s AnyTest) Encode(e *jx.Encoder) {
 	e.ObjStart()
@@ -1691,13 +1528,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -1705,6 +1535,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3449,6 +3286,11 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Array, jx.Null, jx.Number, jx.String:
+		if err := s.OneOfNullables.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -3456,11 +3298,6 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolOneOfBooleanSumNullables
-	case jx.Array, jx.Null, jx.Number, jx.String:
-		if err := s.OneOfNullables.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3946,25 +3783,6 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfNullables
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfNullables
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfNullables
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -3980,6 +3798,25 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfNullables
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfNullables
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfNullables
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4016,6 +3853,11 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Number:
+		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	case jx.String:
 		v, err := json.DecodeUUID(d)
 		s.UUID = v
@@ -4023,11 +3865,6 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = UUIDOneOfUUIDAndIntEnum
-	case jx.Number:
-		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4105,25 +3942,6 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfWithNullable
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfWithNullable
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfWithNullable
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -4139,6 +3957,25 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfWithNullable
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfWithNullable
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfWithNullable
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfWithNullable
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4713,39 +4550,6 @@ func (s *OnlyPatternedPropsObject) UnmarshalJSON(data []byte) error {
 	return s.Decode(d)
 }
 
-// Encode encodes AnyOfTest as json.
-func (o OptAnyOfTest) Encode(e *jx.Encoder) {
-	if !o.Set {
-		return
-	}
-	o.Value.Encode(e)
-}
-
-// Decode decodes AnyOfTest from json.
-func (o *OptAnyOfTest) Decode(d *jx.Decoder) error {
-	if o == nil {
-		return errors.New("invalid: unable to decode OptAnyOfTest to nil")
-	}
-	o.Set = true
-	if err := o.Value.Decode(d); err != nil {
-		return err
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s OptAnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *OptAnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode encodes AnyTest as json.
 func (o OptAnyTest) Encode(e *jx.Encoder) {
 	if !o.Set {
@@ -6262,12 +6066,6 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 			s.TestAny.Encode(e)
 		}
 	}
-	{
-		if s.TestAnyOf.Set {
-			e.FieldStart("testAnyOf")
-			s.TestAnyOf.Encode(e)
-		}
-	}
 	{
 		if s.TestMaxProperties.Set {
 			e.FieldStart("testMaxProperties")
@@ -6306,7 +6104,7 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 	}
 }
 
-var jsonFieldsNameOfPet = [31]string{
+var jsonFieldsNameOfPet = [30]string{
 	0:  "primary",
 	1:  "id",
 	2:  "unique_id",
@@ -6331,13 +6129,12 @@ var jsonFieldsNameOfPet = [31]string{
 	21: "testMap",
 	22: "testMapWithProps",
 	23: "testAny",
-	24: "testAnyOf",
-	25: "testMaxProperties",
-	26: "testDate",
-	27: "testDuration",
-	28: "testTime",
-	29: "testDateTime",
-	30: "nullValue",
+	24: "testMaxProperties",
+	25: "testDate",
+	26: "testDuration",
+	27: "testTime",
+	28: "testDateTime",
+	29: "nullValue",
 }
 
 // Decode decodes Pet from json.
@@ -6633,16 +6430,6 @@ func (s *Pet) Decode(d *jx.Decoder) error {
 			}(); err != nil {
 				return errors.Wrap(err, "decode field \"testAny\"")
 			}
-		case "testAnyOf":
-			if err := func() error {
-				s.TestAnyOf.Reset()
-				if err := s.TestAnyOf.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"testAnyOf\"")
-			}
 		case "testMaxProperties":
 			if err := func() error {
 				s.TestMaxProperties.Reset()
diff --git a/internal/integration/sample_api/oas_schemas_gen.go b/internal/integration/sample_api/oas_schemas_gen.go
index b399fecb..1be8c127 100644
--- a/internal/integration/sample_api/oas_schemas_gen.go
+++ b/internal/integration/sample_api/oas_schemas_gen.go
@@ -26,97 +26,6 @@ func (s *APIKey) SetAPIKey(val string) {
 	s.APIKey = val
 }
 
-// Type for testing some anyOf cases from Jaeger operator API schema.
-// Ref: #/components/schemas/AnyOfTest
-type AnyOfTest struct {
-	Medium    string             `json:"medium"`
-	SizeLimit AnyOfTestSizeLimit `json:"sizeLimit"`
-}
-
-// GetMedium returns the value of Medium.
-func (s AnyOfTest) GetMedium() string {
-	return s.Medium
-}
-
-// GetSizeLimit returns the value of SizeLimit.
-func (s AnyOfTest) GetSizeLimit() AnyOfTestSizeLimit {
-	return s.SizeLimit
-}
-
-// SetMedium sets the value of Medium.
-func (s *AnyOfTest) SetMedium(val string) {
-	s.Medium = val
-}
-
-// SetSizeLimit sets the value of SizeLimit.
-func (s *AnyOfTest) SetSizeLimit(val AnyOfTestSizeLimit) {
-	s.SizeLimit = val
-}
-
-// AnyOfTestSizeLimit represents sum type.
-type AnyOfTestSizeLimit struct {
-	Type   AnyOfTestSizeLimitType // switch on this field
-	Int    int
-	String string
-}
-
-// AnyOfTestSizeLimitType is oneOf type of AnyOfTestSizeLimit.
-type AnyOfTestSizeLimitType string
-
-// Possible values for AnyOfTestSizeLimitType.
-const (
-	IntAnyOfTestSizeLimit    AnyOfTestSizeLimitType = "int"
-	StringAnyOfTestSizeLimit AnyOfTestSizeLimitType = "string"
-)
-
-// IsInt reports whether AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) IsInt() bool { return s.Type == IntAnyOfTestSizeLimit }
-
-// IsString reports whether AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) IsString() bool { return s.Type == StringAnyOfTestSizeLimit }
-
-// SetInt sets AnyOfTestSizeLimit to int.
-func (s *AnyOfTestSizeLimit) SetInt(v int) {
-	s.Type = IntAnyOfTestSizeLimit
-	s.Int = v
-}
-
-// GetInt returns int and true boolean if AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) GetInt() (v int, ok bool) {
-	if !s.IsInt() {
-		return v, false
-	}
-	return s.Int, true
-}
-
-// NewIntAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from int.
-func NewIntAnyOfTestSizeLimit(v int) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetInt(v)
-	return s
-}
-
-// SetString sets AnyOfTestSizeLimit to string.
-func (s *AnyOfTestSizeLimit) SetString(v string) {
-	s.Type = StringAnyOfTestSizeLimit
-	s.String = v
-}
-
-// GetString returns string and true boolean if AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) GetString() (v string, ok bool) {
-	if !s.IsString() {
-		return v, false
-	}
-	return s.String, true
-}
-
-// NewStringAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from string.
-func NewStringAnyOfTestSizeLimit(v string) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetString(v)
-	return s
-}
-
 // Ref: #/components/schemas/AnyTest
 type AnyTest struct {
 	Empty    jx.Raw           `json:"empty"`
@@ -2215,52 +2124,6 @@ func (s *OnlyPatternedPropsObject) init() OnlyPatternedPropsObject {
 	return m
 }
 
-// NewOptAnyOfTest returns new OptAnyOfTest with value set to v.
-func NewOptAnyOfTest(v AnyOfTest) OptAnyOfTest {
-	return OptAnyOfTest{
-		Value: v,
-		Set:   true,
-	}
-}
-
-// OptAnyOfTest is optional AnyOfTest.
-type OptAnyOfTest struct {
-	Value AnyOfTest
-	Set   bool
-}
-
-// IsSet returns true if OptAnyOfTest was set.
-func (o OptAnyOfTest) IsSet() bool { return o.Set }
-
-// Reset unsets value.
-func (o *OptAnyOfTest) Reset() {
-	var v AnyOfTest
-	o.Value = v
-	o.Set = false
-}
-
-// SetTo sets value to v.
-func (o *OptAnyOfTest) SetTo(v AnyOfTest) {
-	o.Set = true
-	o.Value = v
-}
-
-// Get returns value and boolean that denotes whether value was set.
-func (o OptAnyOfTest) Get() (v AnyOfTest, ok bool) {
-	if !o.Set {
-		return v, false
-	}
-	return o.Value, true
-}
-
-// Or returns value if set, or given parameter if does not.
-func (o OptAnyOfTest) Or(d AnyOfTest) AnyOfTest {
-	if v, ok := o.Get(); ok {
-		return v
-	}
-	return d
-}
-
 // NewOptAnyTest returns new OptAnyTest with value set to v.
 func NewOptAnyTest(v AnyTest) OptAnyTest {
 	return OptAnyTest{
@@ -4112,7 +3975,6 @@ type Pet struct {
 	TestMap           OptStringStringMap   `json:"testMap"`
 	TestMapWithProps  OptMapWithProperties `json:"testMapWithProps"`
 	TestAny           OptAnyTest           `json:"testAny"`
-	TestAnyOf         OptAnyOfTest         `json:"testAnyOf"`
 	TestMaxProperties OptMaxPropertiesTest `json:"testMaxProperties"`
 	TestDate          OptDate              `json:"testDate"`
 	TestDuration      OptDuration          `json:"testDuration"`
@@ -4241,11 +4103,6 @@ func (s Pet) GetTestAny() OptAnyTest {
 	return s.TestAny
 }
 
-// GetTestAnyOf returns the value of TestAnyOf.
-func (s Pet) GetTestAnyOf() OptAnyOfTest {
-	return s.TestAnyOf
-}
-
 // GetTestMaxProperties returns the value of TestMaxProperties.
 func (s Pet) GetTestMaxProperties() OptMaxPropertiesTest {
 	return s.TestMaxProperties
@@ -4396,11 +4253,6 @@ func (s *Pet) SetTestAny(val OptAnyTest) {
 	s.TestAny = val
 }
 
-// SetTestAnyOf sets the value of TestAnyOf.
-func (s *Pet) SetTestAnyOf(val OptAnyOfTest) {
-	s.TestAnyOf = val
-}
-
 // SetTestMaxProperties sets the value of TestMaxProperties.
 func (s *Pet) SetTestMaxProperties(val OptMaxPropertiesTest) {
 	s.TestMaxProperties = val
diff --git a/internal/integration/sample_api/oas_validators_gen.go b/internal/integration/sample_api/oas_validators_gen.go
index c4dd32f7..051b03b1 100644
--- a/internal/integration/sample_api/oas_validators_gen.go
+++ b/internal/integration/sample_api/oas_validators_gen.go
@@ -10,46 +10,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-func (s AnyOfTest) Validate() error {
-	var failures []validate.FieldError
-	if err := func() error {
-		if err := s.SizeLimit.Validate(); err != nil {
-			return err
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "sizeLimit",
-			Error: err,
-		})
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-	return nil
-}
-func (s AnyOfTestSizeLimit) Validate() error {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		return nil // no validation needed
-	case StringAnyOfTestSizeLimit:
-		if err := (validate.String{
-			MinLength:    0,
-			MinLengthSet: false,
-			MaxLength:    0,
-			MaxLengthSet: false,
-			Email:        false,
-			Hostname:     false,
-			Regex:        regexMap["^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"],
-		}).Validate(string(s.String)); err != nil {
-			return errors.Wrap(err, "string")
-		}
-		return nil
-	default:
-		return errors.Errorf("invalid type %q", s.Type)
-	}
-}
-
 func (s ArrayTest) Validate() error {
 	var failures []validate.FieldError
 	if err := func() error {
@@ -826,24 +786,6 @@ func (s Pet) Validate() error {
 			Error: err,
 		})
 	}
-	if err := func() error {
-		if s.TestAnyOf.Set {
-			if err := func() error {
-				if err := s.TestAnyOf.Value.Validate(); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return err
-			}
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "testAnyOf",
-			Error: err,
-		})
-	}
 	if len(failures) > 0 {
 		return &validate.Error{Fields: failures}
 	}
diff --git a/internal/integration/sample_api_nc/oas_cfg_gen.go b/internal/integration/sample_api_nc/oas_cfg_gen.go
index 27ba6f03..7269c679 100644
--- a/internal/integration/sample_api_nc/oas_cfg_gen.go
+++ b/internal/integration/sample_api_nc/oas_cfg_gen.go
@@ -19,7 +19,6 @@ import (
 )
 
 var regexMap = map[string]ogenregex.Regexp{
-	"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$": ogenregex.MustCompile("^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"),
 	"^\\d-\\d$":                   ogenregex.MustCompile("^\\d-\\d$"),
 	"foo[^\r\n\u2028\u2029]*":     ogenregex.MustCompile("foo[^\r\n\u2028\u2029]*"),
 	"string_[^\r\n\u2028\u2029]*": ogenregex.MustCompile("string_[^\r\n\u2028\u2029]*"),
diff --git a/internal/integration/sample_api_nc/oas_json_gen.go b/internal/integration/sample_api_nc/oas_json_gen.go
index 2dc8337c..9df4fe56 100644
--- a/internal/integration/sample_api_nc/oas_json_gen.go
+++ b/internal/integration/sample_api_nc/oas_json_gen.go
@@ -14,169 +14,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-// Encode implements json.Marshaler.
-func (s AnyOfTest) Encode(e *jx.Encoder) {
-	e.ObjStart()
-	s.encodeFields(e)
-	e.ObjEnd()
-}
-
-// encodeFields encodes fields.
-func (s AnyOfTest) encodeFields(e *jx.Encoder) {
-	{
-
-		e.FieldStart("medium")
-		e.Str(s.Medium)
-	}
-	{
-
-		e.FieldStart("sizeLimit")
-		s.SizeLimit.Encode(e)
-	}
-}
-
-var jsonFieldsNameOfAnyOfTest = [2]string{
-	0: "medium",
-	1: "sizeLimit",
-}
-
-// Decode decodes AnyOfTest from json.
-func (s *AnyOfTest) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTest to nil")
-	}
-	var requiredBitSet [1]uint8
-
-	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
-		switch string(k) {
-		case "medium":
-			requiredBitSet[0] |= 1 << 0
-			if err := func() error {
-				v, err := d.Str()
-				s.Medium = string(v)
-				if err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"medium\"")
-			}
-		case "sizeLimit":
-			requiredBitSet[0] |= 1 << 1
-			if err := func() error {
-				if err := s.SizeLimit.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"sizeLimit\"")
-			}
-		default:
-			return d.Skip()
-		}
-		return nil
-	}); err != nil {
-		return errors.Wrap(err, "decode AnyOfTest")
-	}
-	// Validate required fields.
-	var failures []validate.FieldError
-	for i, mask := range [1]uint8{
-		0b00000011,
-	} {
-		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
-			// Mask only required fields and check equality to mask using XOR.
-			//
-			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
-			// Bits of fields which would be set are actually bits of missed fields.
-			missed := bits.OnesCount8(result)
-			for bitN := 0; bitN < missed; bitN++ {
-				bitIdx := bits.TrailingZeros8(result)
-				fieldIdx := i*8 + bitIdx
-				var name string
-				if fieldIdx < len(jsonFieldsNameOfAnyOfTest) {
-					name = jsonFieldsNameOfAnyOfTest[fieldIdx]
-				} else {
-					name = strconv.Itoa(fieldIdx)
-				}
-				failures = append(failures, validate.FieldError{
-					Name:  name,
-					Error: validate.ErrFieldRequired,
-				})
-				// Reset bit.
-				result &^= 1 << bitIdx
-			}
-		}
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
-// Encode encodes AnyOfTestSizeLimit as json.
-func (s AnyOfTestSizeLimit) Encode(e *jx.Encoder) {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		e.Int(s.Int)
-	case StringAnyOfTestSizeLimit:
-		e.Str(s.String)
-	}
-}
-
-// Decode decodes AnyOfTestSizeLimit from json.
-func (s *AnyOfTestSizeLimit) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTestSizeLimit to nil")
-	}
-	// Sum type type_discriminator.
-	switch t := d.Next(); t {
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntAnyOfTestSizeLimit
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringAnyOfTestSizeLimit
-	default:
-		return errors.Errorf("unexpected json type %q", t)
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTestSizeLimit) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTestSizeLimit) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode implements json.Marshaler.
 func (s AnyTest) Encode(e *jx.Encoder) {
 	e.ObjStart()
@@ -1691,13 +1528,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -1705,6 +1535,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3449,6 +3286,11 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Array, jx.Null, jx.Number, jx.String:
+		if err := s.OneOfNullables.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -3456,11 +3298,6 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolOneOfBooleanSumNullables
-	case jx.Array, jx.Null, jx.Number, jx.String:
-		if err := s.OneOfNullables.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3946,25 +3783,6 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfNullables
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfNullables
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfNullables
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -3980,6 +3798,25 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfNullables
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfNullables
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfNullables
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4016,6 +3853,11 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Number:
+		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	case jx.String:
 		v, err := json.DecodeUUID(d)
 		s.UUID = v
@@ -4023,11 +3865,6 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = UUIDOneOfUUIDAndIntEnum
-	case jx.Number:
-		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4105,25 +3942,6 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfWithNullable
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfWithNullable
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfWithNullable
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -4139,6 +3957,25 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfWithNullable
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfWithNullable
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfWithNullable
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfWithNullable
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4713,39 +4550,6 @@ func (s *OnlyPatternedPropsObject) UnmarshalJSON(data []byte) error {
 	return s.Decode(d)
 }
 
-// Encode encodes AnyOfTest as json.
-func (o OptAnyOfTest) Encode(e *jx.Encoder) {
-	if !o.Set {
-		return
-	}
-	o.Value.Encode(e)
-}
-
-// Decode decodes AnyOfTest from json.
-func (o *OptAnyOfTest) Decode(d *jx.Decoder) error {
-	if o == nil {
-		return errors.New("invalid: unable to decode OptAnyOfTest to nil")
-	}
-	o.Set = true
-	if err := o.Value.Decode(d); err != nil {
-		return err
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s OptAnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *OptAnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode encodes AnyTest as json.
 func (o OptAnyTest) Encode(e *jx.Encoder) {
 	if !o.Set {
@@ -6262,12 +6066,6 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 			s.TestAny.Encode(e)
 		}
 	}
-	{
-		if s.TestAnyOf.Set {
-			e.FieldStart("testAnyOf")
-			s.TestAnyOf.Encode(e)
-		}
-	}
 	{
 		if s.TestMaxProperties.Set {
 			e.FieldStart("testMaxProperties")
@@ -6306,7 +6104,7 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 	}
 }
 
-var jsonFieldsNameOfPet = [31]string{
+var jsonFieldsNameOfPet = [30]string{
 	0:  "primary",
 	1:  "id",
 	2:  "unique_id",
@@ -6331,13 +6129,12 @@ var jsonFieldsNameOfPet = [31]string{
 	21: "testMap",
 	22: "testMapWithProps",
 	23: "testAny",
-	24: "testAnyOf",
-	25: "testMaxProperties",
-	26: "testDate",
-	27: "testDuration",
-	28: "testTime",
-	29: "testDateTime",
-	30: "nullValue",
+	24: "testMaxProperties",
+	25: "testDate",
+	26: "testDuration",
+	27: "testTime",
+	28: "testDateTime",
+	29: "nullValue",
 }
 
 // Decode decodes Pet from json.
@@ -6633,16 +6430,6 @@ func (s *Pet) Decode(d *jx.Decoder) error {
 			}(); err != nil {
 				return errors.Wrap(err, "decode field \"testAny\"")
 			}
-		case "testAnyOf":
-			if err := func() error {
-				s.TestAnyOf.Reset()
-				if err := s.TestAnyOf.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"testAnyOf\"")
-			}
 		case "testMaxProperties":
 			if err := func() error {
 				s.TestMaxProperties.Reset()
diff --git a/internal/integration/sample_api_nc/oas_schemas_gen.go b/internal/integration/sample_api_nc/oas_schemas_gen.go
index b399fecb..1be8c127 100644
--- a/internal/integration/sample_api_nc/oas_schemas_gen.go
+++ b/internal/integration/sample_api_nc/oas_schemas_gen.go
@@ -26,97 +26,6 @@ func (s *APIKey) SetAPIKey(val string) {
 	s.APIKey = val
 }
 
-// Type for testing some anyOf cases from Jaeger operator API schema.
-// Ref: #/components/schemas/AnyOfTest
-type AnyOfTest struct {
-	Medium    string             `json:"medium"`
-	SizeLimit AnyOfTestSizeLimit `json:"sizeLimit"`
-}
-
-// GetMedium returns the value of Medium.
-func (s AnyOfTest) GetMedium() string {
-	return s.Medium
-}
-
-// GetSizeLimit returns the value of SizeLimit.
-func (s AnyOfTest) GetSizeLimit() AnyOfTestSizeLimit {
-	return s.SizeLimit
-}
-
-// SetMedium sets the value of Medium.
-func (s *AnyOfTest) SetMedium(val string) {
-	s.Medium = val
-}
-
-// SetSizeLimit sets the value of SizeLimit.
-func (s *AnyOfTest) SetSizeLimit(val AnyOfTestSizeLimit) {
-	s.SizeLimit = val
-}
-
-// AnyOfTestSizeLimit represents sum type.
-type AnyOfTestSizeLimit struct {
-	Type   AnyOfTestSizeLimitType // switch on this field
-	Int    int
-	String string
-}
-
-// AnyOfTestSizeLimitType is oneOf type of AnyOfTestSizeLimit.
-type AnyOfTestSizeLimitType string
-
-// Possible values for AnyOfTestSizeLimitType.
-const (
-	IntAnyOfTestSizeLimit    AnyOfTestSizeLimitType = "int"
-	StringAnyOfTestSizeLimit AnyOfTestSizeLimitType = "string"
-)
-
-// IsInt reports whether AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) IsInt() bool { return s.Type == IntAnyOfTestSizeLimit }
-
-// IsString reports whether AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) IsString() bool { return s.Type == StringAnyOfTestSizeLimit }
-
-// SetInt sets AnyOfTestSizeLimit to int.
-func (s *AnyOfTestSizeLimit) SetInt(v int) {
-	s.Type = IntAnyOfTestSizeLimit
-	s.Int = v
-}
-
-// GetInt returns int and true boolean if AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) GetInt() (v int, ok bool) {
-	if !s.IsInt() {
-		return v, false
-	}
-	return s.Int, true
-}
-
-// NewIntAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from int.
-func NewIntAnyOfTestSizeLimit(v int) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetInt(v)
-	return s
-}
-
-// SetString sets AnyOfTestSizeLimit to string.
-func (s *AnyOfTestSizeLimit) SetString(v string) {
-	s.Type = StringAnyOfTestSizeLimit
-	s.String = v
-}
-
-// GetString returns string and true boolean if AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) GetString() (v string, ok bool) {
-	if !s.IsString() {
-		return v, false
-	}
-	return s.String, true
-}
-
-// NewStringAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from string.
-func NewStringAnyOfTestSizeLimit(v string) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetString(v)
-	return s
-}
-
 // Ref: #/components/schemas/AnyTest
 type AnyTest struct {
 	Empty    jx.Raw           `json:"empty"`
@@ -2215,52 +2124,6 @@ func (s *OnlyPatternedPropsObject) init() OnlyPatternedPropsObject {
 	return m
 }
 
-// NewOptAnyOfTest returns new OptAnyOfTest with value set to v.
-func NewOptAnyOfTest(v AnyOfTest) OptAnyOfTest {
-	return OptAnyOfTest{
-		Value: v,
-		Set:   true,
-	}
-}
-
-// OptAnyOfTest is optional AnyOfTest.
-type OptAnyOfTest struct {
-	Value AnyOfTest
-	Set   bool
-}
-
-// IsSet returns true if OptAnyOfTest was set.
-func (o OptAnyOfTest) IsSet() bool { return o.Set }
-
-// Reset unsets value.
-func (o *OptAnyOfTest) Reset() {
-	var v AnyOfTest
-	o.Value = v
-	o.Set = false
-}
-
-// SetTo sets value to v.
-func (o *OptAnyOfTest) SetTo(v AnyOfTest) {
-	o.Set = true
-	o.Value = v
-}
-
-// Get returns value and boolean that denotes whether value was set.
-func (o OptAnyOfTest) Get() (v AnyOfTest, ok bool) {
-	if !o.Set {
-		return v, false
-	}
-	return o.Value, true
-}
-
-// Or returns value if set, or given parameter if does not.
-func (o OptAnyOfTest) Or(d AnyOfTest) AnyOfTest {
-	if v, ok := o.Get(); ok {
-		return v
-	}
-	return d
-}
-
 // NewOptAnyTest returns new OptAnyTest with value set to v.
 func NewOptAnyTest(v AnyTest) OptAnyTest {
 	return OptAnyTest{
@@ -4112,7 +3975,6 @@ type Pet struct {
 	TestMap           OptStringStringMap   `json:"testMap"`
 	TestMapWithProps  OptMapWithProperties `json:"testMapWithProps"`
 	TestAny           OptAnyTest           `json:"testAny"`
-	TestAnyOf         OptAnyOfTest         `json:"testAnyOf"`
 	TestMaxProperties OptMaxPropertiesTest `json:"testMaxProperties"`
 	TestDate          OptDate              `json:"testDate"`
 	TestDuration      OptDuration          `json:"testDuration"`
@@ -4241,11 +4103,6 @@ func (s Pet) GetTestAny() OptAnyTest {
 	return s.TestAny
 }
 
-// GetTestAnyOf returns the value of TestAnyOf.
-func (s Pet) GetTestAnyOf() OptAnyOfTest {
-	return s.TestAnyOf
-}
-
 // GetTestMaxProperties returns the value of TestMaxProperties.
 func (s Pet) GetTestMaxProperties() OptMaxPropertiesTest {
 	return s.TestMaxProperties
@@ -4396,11 +4253,6 @@ func (s *Pet) SetTestAny(val OptAnyTest) {
 	s.TestAny = val
 }
 
-// SetTestAnyOf sets the value of TestAnyOf.
-func (s *Pet) SetTestAnyOf(val OptAnyOfTest) {
-	s.TestAnyOf = val
-}
-
 // SetTestMaxProperties sets the value of TestMaxProperties.
 func (s *Pet) SetTestMaxProperties(val OptMaxPropertiesTest) {
 	s.TestMaxProperties = val
diff --git a/internal/integration/sample_api_nc/oas_validators_gen.go b/internal/integration/sample_api_nc/oas_validators_gen.go
index c4dd32f7..051b03b1 100644
--- a/internal/integration/sample_api_nc/oas_validators_gen.go
+++ b/internal/integration/sample_api_nc/oas_validators_gen.go
@@ -10,46 +10,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-func (s AnyOfTest) Validate() error {
-	var failures []validate.FieldError
-	if err := func() error {
-		if err := s.SizeLimit.Validate(); err != nil {
-			return err
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "sizeLimit",
-			Error: err,
-		})
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-	return nil
-}
-func (s AnyOfTestSizeLimit) Validate() error {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		return nil // no validation needed
-	case StringAnyOfTestSizeLimit:
-		if err := (validate.String{
-			MinLength:    0,
-			MinLengthSet: false,
-			MaxLength:    0,
-			MaxLengthSet: false,
-			Email:        false,
-			Hostname:     false,
-			Regex:        regexMap["^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"],
-		}).Validate(string(s.String)); err != nil {
-			return errors.Wrap(err, "string")
-		}
-		return nil
-	default:
-		return errors.Errorf("invalid type %q", s.Type)
-	}
-}
-
 func (s ArrayTest) Validate() error {
 	var failures []validate.FieldError
 	if err := func() error {
@@ -826,24 +786,6 @@ func (s Pet) Validate() error {
 			Error: err,
 		})
 	}
-	if err := func() error {
-		if s.TestAnyOf.Set {
-			if err := func() error {
-				if err := s.TestAnyOf.Value.Validate(); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return err
-			}
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "testAnyOf",
-			Error: err,
-		})
-	}
 	if len(failures) > 0 {
 		return &validate.Error{Fields: failures}
 	}
diff --git a/internal/integration/sample_api_ns/oas_cfg_gen.go b/internal/integration/sample_api_ns/oas_cfg_gen.go
index 55e6d675..40e60893 100644
--- a/internal/integration/sample_api_ns/oas_cfg_gen.go
+++ b/internal/integration/sample_api_ns/oas_cfg_gen.go
@@ -18,7 +18,6 @@ import (
 )
 
 var regexMap = map[string]ogenregex.Regexp{
-	"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$": ogenregex.MustCompile("^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"),
 	"^\\d-\\d$":                   ogenregex.MustCompile("^\\d-\\d$"),
 	"foo[^\r\n\u2028\u2029]*":     ogenregex.MustCompile("foo[^\r\n\u2028\u2029]*"),
 	"string_[^\r\n\u2028\u2029]*": ogenregex.MustCompile("string_[^\r\n\u2028\u2029]*"),
diff --git a/internal/integration/sample_api_ns/oas_json_gen.go b/internal/integration/sample_api_ns/oas_json_gen.go
index 2dc8337c..9df4fe56 100644
--- a/internal/integration/sample_api_ns/oas_json_gen.go
+++ b/internal/integration/sample_api_ns/oas_json_gen.go
@@ -14,169 +14,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-// Encode implements json.Marshaler.
-func (s AnyOfTest) Encode(e *jx.Encoder) {
-	e.ObjStart()
-	s.encodeFields(e)
-	e.ObjEnd()
-}
-
-// encodeFields encodes fields.
-func (s AnyOfTest) encodeFields(e *jx.Encoder) {
-	{
-
-		e.FieldStart("medium")
-		e.Str(s.Medium)
-	}
-	{
-
-		e.FieldStart("sizeLimit")
-		s.SizeLimit.Encode(e)
-	}
-}
-
-var jsonFieldsNameOfAnyOfTest = [2]string{
-	0: "medium",
-	1: "sizeLimit",
-}
-
-// Decode decodes AnyOfTest from json.
-func (s *AnyOfTest) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTest to nil")
-	}
-	var requiredBitSet [1]uint8
-
-	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
-		switch string(k) {
-		case "medium":
-			requiredBitSet[0] |= 1 << 0
-			if err := func() error {
-				v, err := d.Str()
-				s.Medium = string(v)
-				if err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"medium\"")
-			}
-		case "sizeLimit":
-			requiredBitSet[0] |= 1 << 1
-			if err := func() error {
-				if err := s.SizeLimit.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"sizeLimit\"")
-			}
-		default:
-			return d.Skip()
-		}
-		return nil
-	}); err != nil {
-		return errors.Wrap(err, "decode AnyOfTest")
-	}
-	// Validate required fields.
-	var failures []validate.FieldError
-	for i, mask := range [1]uint8{
-		0b00000011,
-	} {
-		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
-			// Mask only required fields and check equality to mask using XOR.
-			//
-			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
-			// Bits of fields which would be set are actually bits of missed fields.
-			missed := bits.OnesCount8(result)
-			for bitN := 0; bitN < missed; bitN++ {
-				bitIdx := bits.TrailingZeros8(result)
-				fieldIdx := i*8 + bitIdx
-				var name string
-				if fieldIdx < len(jsonFieldsNameOfAnyOfTest) {
-					name = jsonFieldsNameOfAnyOfTest[fieldIdx]
-				} else {
-					name = strconv.Itoa(fieldIdx)
-				}
-				failures = append(failures, validate.FieldError{
-					Name:  name,
-					Error: validate.ErrFieldRequired,
-				})
-				// Reset bit.
-				result &^= 1 << bitIdx
-			}
-		}
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
-// Encode encodes AnyOfTestSizeLimit as json.
-func (s AnyOfTestSizeLimit) Encode(e *jx.Encoder) {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		e.Int(s.Int)
-	case StringAnyOfTestSizeLimit:
-		e.Str(s.String)
-	}
-}
-
-// Decode decodes AnyOfTestSizeLimit from json.
-func (s *AnyOfTestSizeLimit) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTestSizeLimit to nil")
-	}
-	// Sum type type_discriminator.
-	switch t := d.Next(); t {
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntAnyOfTestSizeLimit
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringAnyOfTestSizeLimit
-	default:
-		return errors.Errorf("unexpected json type %q", t)
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTestSizeLimit) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTestSizeLimit) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode implements json.Marshaler.
 func (s AnyTest) Encode(e *jx.Encoder) {
 	e.ObjStart()
@@ -1691,13 +1528,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -1705,6 +1535,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3449,6 +3286,11 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Array, jx.Null, jx.Number, jx.String:
+		if err := s.OneOfNullables.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -3456,11 +3298,6 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolOneOfBooleanSumNullables
-	case jx.Array, jx.Null, jx.Number, jx.String:
-		if err := s.OneOfNullables.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3946,25 +3783,6 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfNullables
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfNullables
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfNullables
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -3980,6 +3798,25 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfNullables
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfNullables
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfNullables
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4016,6 +3853,11 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Number:
+		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	case jx.String:
 		v, err := json.DecodeUUID(d)
 		s.UUID = v
@@ -4023,11 +3865,6 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = UUIDOneOfUUIDAndIntEnum
-	case jx.Number:
-		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4105,25 +3942,6 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfWithNullable
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfWithNullable
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfWithNullable
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -4139,6 +3957,25 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfWithNullable
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfWithNullable
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfWithNullable
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfWithNullable
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4713,39 +4550,6 @@ func (s *OnlyPatternedPropsObject) UnmarshalJSON(data []byte) error {
 	return s.Decode(d)
 }
 
-// Encode encodes AnyOfTest as json.
-func (o OptAnyOfTest) Encode(e *jx.Encoder) {
-	if !o.Set {
-		return
-	}
-	o.Value.Encode(e)
-}
-
-// Decode decodes AnyOfTest from json.
-func (o *OptAnyOfTest) Decode(d *jx.Decoder) error {
-	if o == nil {
-		return errors.New("invalid: unable to decode OptAnyOfTest to nil")
-	}
-	o.Set = true
-	if err := o.Value.Decode(d); err != nil {
-		return err
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s OptAnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *OptAnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode encodes AnyTest as json.
 func (o OptAnyTest) Encode(e *jx.Encoder) {
 	if !o.Set {
@@ -6262,12 +6066,6 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 			s.TestAny.Encode(e)
 		}
 	}
-	{
-		if s.TestAnyOf.Set {
-			e.FieldStart("testAnyOf")
-			s.TestAnyOf.Encode(e)
-		}
-	}
 	{
 		if s.TestMaxProperties.Set {
 			e.FieldStart("testMaxProperties")
@@ -6306,7 +6104,7 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 	}
 }
 
-var jsonFieldsNameOfPet = [31]string{
+var jsonFieldsNameOfPet = [30]string{
 	0:  "primary",
 	1:  "id",
 	2:  "unique_id",
@@ -6331,13 +6129,12 @@ var jsonFieldsNameOfPet = [31]string{
 	21: "testMap",
 	22: "testMapWithProps",
 	23: "testAny",
-	24: "testAnyOf",
-	25: "testMaxProperties",
-	26: "testDate",
-	27: "testDuration",
-	28: "testTime",
-	29: "testDateTime",
-	30: "nullValue",
+	24: "testMaxProperties",
+	25: "testDate",
+	26: "testDuration",
+	27: "testTime",
+	28: "testDateTime",
+	29: "nullValue",
 }
 
 // Decode decodes Pet from json.
@@ -6633,16 +6430,6 @@ func (s *Pet) Decode(d *jx.Decoder) error {
 			}(); err != nil {
 				return errors.Wrap(err, "decode field \"testAny\"")
 			}
-		case "testAnyOf":
-			if err := func() error {
-				s.TestAnyOf.Reset()
-				if err := s.TestAnyOf.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"testAnyOf\"")
-			}
 		case "testMaxProperties":
 			if err := func() error {
 				s.TestMaxProperties.Reset()
diff --git a/internal/integration/sample_api_ns/oas_schemas_gen.go b/internal/integration/sample_api_ns/oas_schemas_gen.go
index b399fecb..1be8c127 100644
--- a/internal/integration/sample_api_ns/oas_schemas_gen.go
+++ b/internal/integration/sample_api_ns/oas_schemas_gen.go
@@ -26,97 +26,6 @@ func (s *APIKey) SetAPIKey(val string) {
 	s.APIKey = val
 }
 
-// Type for testing some anyOf cases from Jaeger operator API schema.
-// Ref: #/components/schemas/AnyOfTest
-type AnyOfTest struct {
-	Medium    string             `json:"medium"`
-	SizeLimit AnyOfTestSizeLimit `json:"sizeLimit"`
-}
-
-// GetMedium returns the value of Medium.
-func (s AnyOfTest) GetMedium() string {
-	return s.Medium
-}
-
-// GetSizeLimit returns the value of SizeLimit.
-func (s AnyOfTest) GetSizeLimit() AnyOfTestSizeLimit {
-	return s.SizeLimit
-}
-
-// SetMedium sets the value of Medium.
-func (s *AnyOfTest) SetMedium(val string) {
-	s.Medium = val
-}
-
-// SetSizeLimit sets the value of SizeLimit.
-func (s *AnyOfTest) SetSizeLimit(val AnyOfTestSizeLimit) {
-	s.SizeLimit = val
-}
-
-// AnyOfTestSizeLimit represents sum type.
-type AnyOfTestSizeLimit struct {
-	Type   AnyOfTestSizeLimitType // switch on this field
-	Int    int
-	String string
-}
-
-// AnyOfTestSizeLimitType is oneOf type of AnyOfTestSizeLimit.
-type AnyOfTestSizeLimitType string
-
-// Possible values for AnyOfTestSizeLimitType.
-const (
-	IntAnyOfTestSizeLimit    AnyOfTestSizeLimitType = "int"
-	StringAnyOfTestSizeLimit AnyOfTestSizeLimitType = "string"
-)
-
-// IsInt reports whether AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) IsInt() bool { return s.Type == IntAnyOfTestSizeLimit }
-
-// IsString reports whether AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) IsString() bool { return s.Type == StringAnyOfTestSizeLimit }
-
-// SetInt sets AnyOfTestSizeLimit to int.
-func (s *AnyOfTestSizeLimit) SetInt(v int) {
-	s.Type = IntAnyOfTestSizeLimit
-	s.Int = v
-}
-
-// GetInt returns int and true boolean if AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) GetInt() (v int, ok bool) {
-	if !s.IsInt() {
-		return v, false
-	}
-	return s.Int, true
-}
-
-// NewIntAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from int.
-func NewIntAnyOfTestSizeLimit(v int) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetInt(v)
-	return s
-}
-
-// SetString sets AnyOfTestSizeLimit to string.
-func (s *AnyOfTestSizeLimit) SetString(v string) {
-	s.Type = StringAnyOfTestSizeLimit
-	s.String = v
-}
-
-// GetString returns string and true boolean if AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) GetString() (v string, ok bool) {
-	if !s.IsString() {
-		return v, false
-	}
-	return s.String, true
-}
-
-// NewStringAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from string.
-func NewStringAnyOfTestSizeLimit(v string) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetString(v)
-	return s
-}
-
 // Ref: #/components/schemas/AnyTest
 type AnyTest struct {
 	Empty    jx.Raw           `json:"empty"`
@@ -2215,52 +2124,6 @@ func (s *OnlyPatternedPropsObject) init() OnlyPatternedPropsObject {
 	return m
 }
 
-// NewOptAnyOfTest returns new OptAnyOfTest with value set to v.
-func NewOptAnyOfTest(v AnyOfTest) OptAnyOfTest {
-	return OptAnyOfTest{
-		Value: v,
-		Set:   true,
-	}
-}
-
-// OptAnyOfTest is optional AnyOfTest.
-type OptAnyOfTest struct {
-	Value AnyOfTest
-	Set   bool
-}
-
-// IsSet returns true if OptAnyOfTest was set.
-func (o OptAnyOfTest) IsSet() bool { return o.Set }
-
-// Reset unsets value.
-func (o *OptAnyOfTest) Reset() {
-	var v AnyOfTest
-	o.Value = v
-	o.Set = false
-}
-
-// SetTo sets value to v.
-func (o *OptAnyOfTest) SetTo(v AnyOfTest) {
-	o.Set = true
-	o.Value = v
-}
-
-// Get returns value and boolean that denotes whether value was set.
-func (o OptAnyOfTest) Get() (v AnyOfTest, ok bool) {
-	if !o.Set {
-		return v, false
-	}
-	return o.Value, true
-}
-
-// Or returns value if set, or given parameter if does not.
-func (o OptAnyOfTest) Or(d AnyOfTest) AnyOfTest {
-	if v, ok := o.Get(); ok {
-		return v
-	}
-	return d
-}
-
 // NewOptAnyTest returns new OptAnyTest with value set to v.
 func NewOptAnyTest(v AnyTest) OptAnyTest {
 	return OptAnyTest{
@@ -4112,7 +3975,6 @@ type Pet struct {
 	TestMap           OptStringStringMap   `json:"testMap"`
 	TestMapWithProps  OptMapWithProperties `json:"testMapWithProps"`
 	TestAny           OptAnyTest           `json:"testAny"`
-	TestAnyOf         OptAnyOfTest         `json:"testAnyOf"`
 	TestMaxProperties OptMaxPropertiesTest `json:"testMaxProperties"`
 	TestDate          OptDate              `json:"testDate"`
 	TestDuration      OptDuration          `json:"testDuration"`
@@ -4241,11 +4103,6 @@ func (s Pet) GetTestAny() OptAnyTest {
 	return s.TestAny
 }
 
-// GetTestAnyOf returns the value of TestAnyOf.
-func (s Pet) GetTestAnyOf() OptAnyOfTest {
-	return s.TestAnyOf
-}
-
 // GetTestMaxProperties returns the value of TestMaxProperties.
 func (s Pet) GetTestMaxProperties() OptMaxPropertiesTest {
 	return s.TestMaxProperties
@@ -4396,11 +4253,6 @@ func (s *Pet) SetTestAny(val OptAnyTest) {
 	s.TestAny = val
 }
 
-// SetTestAnyOf sets the value of TestAnyOf.
-func (s *Pet) SetTestAnyOf(val OptAnyOfTest) {
-	s.TestAnyOf = val
-}
-
 // SetTestMaxProperties sets the value of TestMaxProperties.
 func (s *Pet) SetTestMaxProperties(val OptMaxPropertiesTest) {
 	s.TestMaxProperties = val
diff --git a/internal/integration/sample_api_ns/oas_validators_gen.go b/internal/integration/sample_api_ns/oas_validators_gen.go
index c4dd32f7..051b03b1 100644
--- a/internal/integration/sample_api_ns/oas_validators_gen.go
+++ b/internal/integration/sample_api_ns/oas_validators_gen.go
@@ -10,46 +10,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-func (s AnyOfTest) Validate() error {
-	var failures []validate.FieldError
-	if err := func() error {
-		if err := s.SizeLimit.Validate(); err != nil {
-			return err
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "sizeLimit",
-			Error: err,
-		})
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-	return nil
-}
-func (s AnyOfTestSizeLimit) Validate() error {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		return nil // no validation needed
-	case StringAnyOfTestSizeLimit:
-		if err := (validate.String{
-			MinLength:    0,
-			MinLengthSet: false,
-			MaxLength:    0,
-			MaxLengthSet: false,
-			Email:        false,
-			Hostname:     false,
-			Regex:        regexMap["^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"],
-		}).Validate(string(s.String)); err != nil {
-			return errors.Wrap(err, "string")
-		}
-		return nil
-	default:
-		return errors.Errorf("invalid type %q", s.Type)
-	}
-}
-
 func (s ArrayTest) Validate() error {
 	var failures []validate.FieldError
 	if err := func() error {
@@ -826,24 +786,6 @@ func (s Pet) Validate() error {
 			Error: err,
 		})
 	}
-	if err := func() error {
-		if s.TestAnyOf.Set {
-			if err := func() error {
-				if err := s.TestAnyOf.Value.Validate(); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return err
-			}
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "testAnyOf",
-			Error: err,
-		})
-	}
 	if len(failures) > 0 {
 		return &validate.Error{Fields: failures}
 	}
diff --git a/internal/integration/sample_api_nsnc/oas_cfg_gen.go b/internal/integration/sample_api_nsnc/oas_cfg_gen.go
index bdc50cc6..ceb9c777 100644
--- a/internal/integration/sample_api_nsnc/oas_cfg_gen.go
+++ b/internal/integration/sample_api_nsnc/oas_cfg_gen.go
@@ -10,7 +10,6 @@ import (
 )
 
 var regexMap = map[string]ogenregex.Regexp{
-	"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$": ogenregex.MustCompile("^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"),
 	"^\\d-\\d$":                   ogenregex.MustCompile("^\\d-\\d$"),
 	"foo[^\r\n\u2028\u2029]*":     ogenregex.MustCompile("foo[^\r\n\u2028\u2029]*"),
 	"string_[^\r\n\u2028\u2029]*": ogenregex.MustCompile("string_[^\r\n\u2028\u2029]*"),
diff --git a/internal/integration/sample_api_nsnc/oas_json_gen.go b/internal/integration/sample_api_nsnc/oas_json_gen.go
index 2dc8337c..9df4fe56 100644
--- a/internal/integration/sample_api_nsnc/oas_json_gen.go
+++ b/internal/integration/sample_api_nsnc/oas_json_gen.go
@@ -14,169 +14,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-// Encode implements json.Marshaler.
-func (s AnyOfTest) Encode(e *jx.Encoder) {
-	e.ObjStart()
-	s.encodeFields(e)
-	e.ObjEnd()
-}
-
-// encodeFields encodes fields.
-func (s AnyOfTest) encodeFields(e *jx.Encoder) {
-	{
-
-		e.FieldStart("medium")
-		e.Str(s.Medium)
-	}
-	{
-
-		e.FieldStart("sizeLimit")
-		s.SizeLimit.Encode(e)
-	}
-}
-
-var jsonFieldsNameOfAnyOfTest = [2]string{
-	0: "medium",
-	1: "sizeLimit",
-}
-
-// Decode decodes AnyOfTest from json.
-func (s *AnyOfTest) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTest to nil")
-	}
-	var requiredBitSet [1]uint8
-
-	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
-		switch string(k) {
-		case "medium":
-			requiredBitSet[0] |= 1 << 0
-			if err := func() error {
-				v, err := d.Str()
-				s.Medium = string(v)
-				if err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"medium\"")
-			}
-		case "sizeLimit":
-			requiredBitSet[0] |= 1 << 1
-			if err := func() error {
-				if err := s.SizeLimit.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"sizeLimit\"")
-			}
-		default:
-			return d.Skip()
-		}
-		return nil
-	}); err != nil {
-		return errors.Wrap(err, "decode AnyOfTest")
-	}
-	// Validate required fields.
-	var failures []validate.FieldError
-	for i, mask := range [1]uint8{
-		0b00000011,
-	} {
-		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
-			// Mask only required fields and check equality to mask using XOR.
-			//
-			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
-			// Bits of fields which would be set are actually bits of missed fields.
-			missed := bits.OnesCount8(result)
-			for bitN := 0; bitN < missed; bitN++ {
-				bitIdx := bits.TrailingZeros8(result)
-				fieldIdx := i*8 + bitIdx
-				var name string
-				if fieldIdx < len(jsonFieldsNameOfAnyOfTest) {
-					name = jsonFieldsNameOfAnyOfTest[fieldIdx]
-				} else {
-					name = strconv.Itoa(fieldIdx)
-				}
-				failures = append(failures, validate.FieldError{
-					Name:  name,
-					Error: validate.ErrFieldRequired,
-				})
-				// Reset bit.
-				result &^= 1 << bitIdx
-			}
-		}
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
-// Encode encodes AnyOfTestSizeLimit as json.
-func (s AnyOfTestSizeLimit) Encode(e *jx.Encoder) {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		e.Int(s.Int)
-	case StringAnyOfTestSizeLimit:
-		e.Str(s.String)
-	}
-}
-
-// Decode decodes AnyOfTestSizeLimit from json.
-func (s *AnyOfTestSizeLimit) Decode(d *jx.Decoder) error {
-	if s == nil {
-		return errors.New("invalid: unable to decode AnyOfTestSizeLimit to nil")
-	}
-	// Sum type type_discriminator.
-	switch t := d.Next(); t {
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntAnyOfTestSizeLimit
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringAnyOfTestSizeLimit
-	default:
-		return errors.Errorf("unexpected json type %q", t)
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s AnyOfTestSizeLimit) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *AnyOfTestSizeLimit) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode implements json.Marshaler.
 func (s AnyTest) Encode(e *jx.Encoder) {
 	e.ObjStart()
@@ -1691,13 +1528,6 @@ func (s *ID) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringID
 	case jx.Number:
 		v, err := d.Int()
 		s.Int = int(v)
@@ -1705,6 +1535,13 @@ func (s *ID) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = IntID
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringID
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3449,6 +3286,11 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Array, jx.Null, jx.Number, jx.String:
+		if err := s.OneOfNullables.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	case jx.Bool:
 		v, err := d.Bool()
 		s.Bool = bool(v)
@@ -3456,11 +3298,6 @@ func (s *OneOfBooleanSumNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = BoolOneOfBooleanSumNullables
-	case jx.Array, jx.Null, jx.Number, jx.String:
-		if err := s.OneOfNullables.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfNullablesOneOfBooleanSumNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -3946,25 +3783,6 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfNullables
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfNullables
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfNullables
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -3980,6 +3798,25 @@ func (s *OneOfNullables) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfNullables
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfNullables
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfNullables
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfNullables
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4016,6 +3853,11 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
+	case jx.Number:
+		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
+			return err
+		}
+		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	case jx.String:
 		v, err := json.DecodeUUID(d)
 		s.UUID = v
@@ -4023,11 +3865,6 @@ func (s *OneOfUUIDAndIntEnum) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = UUIDOneOfUUIDAndIntEnum
-	case jx.Number:
-		if err := s.OneOfUUIDAndIntEnum1.Decode(d); err != nil {
-			return err
-		}
-		s.Type = OneOfUUIDAndIntEnum1OneOfUUIDAndIntEnum
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4105,25 +3942,6 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 	}
 	// Sum type type_discriminator.
 	switch t := d.Next(); t {
-	case jx.Null:
-		if err := d.Null(); err != nil {
-			return err
-		}
-		s.Type = NullOneOfWithNullable
-	case jx.String:
-		v, err := d.Str()
-		s.String = string(v)
-		if err != nil {
-			return err
-		}
-		s.Type = StringOneOfWithNullable
-	case jx.Number:
-		v, err := d.Int()
-		s.Int = int(v)
-		if err != nil {
-			return err
-		}
-		s.Type = IntOneOfWithNullable
 	case jx.Array:
 		s.StringArray = make([]string, 0)
 		if err := d.Arr(func(d *jx.Decoder) error {
@@ -4139,6 +3957,25 @@ func (s *OneOfWithNullable) Decode(d *jx.Decoder) error {
 			return err
 		}
 		s.Type = StringArrayOneOfWithNullable
+	case jx.Null:
+		if err := d.Null(); err != nil {
+			return err
+		}
+		s.Type = NullOneOfWithNullable
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntOneOfWithNullable
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringOneOfWithNullable
 	default:
 		return errors.Errorf("unexpected json type %q", t)
 	}
@@ -4713,39 +4550,6 @@ func (s *OnlyPatternedPropsObject) UnmarshalJSON(data []byte) error {
 	return s.Decode(d)
 }
 
-// Encode encodes AnyOfTest as json.
-func (o OptAnyOfTest) Encode(e *jx.Encoder) {
-	if !o.Set {
-		return
-	}
-	o.Value.Encode(e)
-}
-
-// Decode decodes AnyOfTest from json.
-func (o *OptAnyOfTest) Decode(d *jx.Decoder) error {
-	if o == nil {
-		return errors.New("invalid: unable to decode OptAnyOfTest to nil")
-	}
-	o.Set = true
-	if err := o.Value.Decode(d); err != nil {
-		return err
-	}
-	return nil
-}
-
-// MarshalJSON implements stdjson.Marshaler.
-func (s OptAnyOfTest) MarshalJSON() ([]byte, error) {
-	e := jx.Encoder{}
-	s.Encode(&e)
-	return e.Bytes(), nil
-}
-
-// UnmarshalJSON implements stdjson.Unmarshaler.
-func (s *OptAnyOfTest) UnmarshalJSON(data []byte) error {
-	d := jx.DecodeBytes(data)
-	return s.Decode(d)
-}
-
 // Encode encodes AnyTest as json.
 func (o OptAnyTest) Encode(e *jx.Encoder) {
 	if !o.Set {
@@ -6262,12 +6066,6 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 			s.TestAny.Encode(e)
 		}
 	}
-	{
-		if s.TestAnyOf.Set {
-			e.FieldStart("testAnyOf")
-			s.TestAnyOf.Encode(e)
-		}
-	}
 	{
 		if s.TestMaxProperties.Set {
 			e.FieldStart("testMaxProperties")
@@ -6306,7 +6104,7 @@ func (s Pet) encodeFields(e *jx.Encoder) {
 	}
 }
 
-var jsonFieldsNameOfPet = [31]string{
+var jsonFieldsNameOfPet = [30]string{
 	0:  "primary",
 	1:  "id",
 	2:  "unique_id",
@@ -6331,13 +6129,12 @@ var jsonFieldsNameOfPet = [31]string{
 	21: "testMap",
 	22: "testMapWithProps",
 	23: "testAny",
-	24: "testAnyOf",
-	25: "testMaxProperties",
-	26: "testDate",
-	27: "testDuration",
-	28: "testTime",
-	29: "testDateTime",
-	30: "nullValue",
+	24: "testMaxProperties",
+	25: "testDate",
+	26: "testDuration",
+	27: "testTime",
+	28: "testDateTime",
+	29: "nullValue",
 }
 
 // Decode decodes Pet from json.
@@ -6633,16 +6430,6 @@ func (s *Pet) Decode(d *jx.Decoder) error {
 			}(); err != nil {
 				return errors.Wrap(err, "decode field \"testAny\"")
 			}
-		case "testAnyOf":
-			if err := func() error {
-				s.TestAnyOf.Reset()
-				if err := s.TestAnyOf.Decode(d); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return errors.Wrap(err, "decode field \"testAnyOf\"")
-			}
 		case "testMaxProperties":
 			if err := func() error {
 				s.TestMaxProperties.Reset()
diff --git a/internal/integration/sample_api_nsnc/oas_schemas_gen.go b/internal/integration/sample_api_nsnc/oas_schemas_gen.go
index b399fecb..1be8c127 100644
--- a/internal/integration/sample_api_nsnc/oas_schemas_gen.go
+++ b/internal/integration/sample_api_nsnc/oas_schemas_gen.go
@@ -26,97 +26,6 @@ func (s *APIKey) SetAPIKey(val string) {
 	s.APIKey = val
 }
 
-// Type for testing some anyOf cases from Jaeger operator API schema.
-// Ref: #/components/schemas/AnyOfTest
-type AnyOfTest struct {
-	Medium    string             `json:"medium"`
-	SizeLimit AnyOfTestSizeLimit `json:"sizeLimit"`
-}
-
-// GetMedium returns the value of Medium.
-func (s AnyOfTest) GetMedium() string {
-	return s.Medium
-}
-
-// GetSizeLimit returns the value of SizeLimit.
-func (s AnyOfTest) GetSizeLimit() AnyOfTestSizeLimit {
-	return s.SizeLimit
-}
-
-// SetMedium sets the value of Medium.
-func (s *AnyOfTest) SetMedium(val string) {
-	s.Medium = val
-}
-
-// SetSizeLimit sets the value of SizeLimit.
-func (s *AnyOfTest) SetSizeLimit(val AnyOfTestSizeLimit) {
-	s.SizeLimit = val
-}
-
-// AnyOfTestSizeLimit represents sum type.
-type AnyOfTestSizeLimit struct {
-	Type   AnyOfTestSizeLimitType // switch on this field
-	Int    int
-	String string
-}
-
-// AnyOfTestSizeLimitType is oneOf type of AnyOfTestSizeLimit.
-type AnyOfTestSizeLimitType string
-
-// Possible values for AnyOfTestSizeLimitType.
-const (
-	IntAnyOfTestSizeLimit    AnyOfTestSizeLimitType = "int"
-	StringAnyOfTestSizeLimit AnyOfTestSizeLimitType = "string"
-)
-
-// IsInt reports whether AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) IsInt() bool { return s.Type == IntAnyOfTestSizeLimit }
-
-// IsString reports whether AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) IsString() bool { return s.Type == StringAnyOfTestSizeLimit }
-
-// SetInt sets AnyOfTestSizeLimit to int.
-func (s *AnyOfTestSizeLimit) SetInt(v int) {
-	s.Type = IntAnyOfTestSizeLimit
-	s.Int = v
-}
-
-// GetInt returns int and true boolean if AnyOfTestSizeLimit is int.
-func (s AnyOfTestSizeLimit) GetInt() (v int, ok bool) {
-	if !s.IsInt() {
-		return v, false
-	}
-	return s.Int, true
-}
-
-// NewIntAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from int.
-func NewIntAnyOfTestSizeLimit(v int) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetInt(v)
-	return s
-}
-
-// SetString sets AnyOfTestSizeLimit to string.
-func (s *AnyOfTestSizeLimit) SetString(v string) {
-	s.Type = StringAnyOfTestSizeLimit
-	s.String = v
-}
-
-// GetString returns string and true boolean if AnyOfTestSizeLimit is string.
-func (s AnyOfTestSizeLimit) GetString() (v string, ok bool) {
-	if !s.IsString() {
-		return v, false
-	}
-	return s.String, true
-}
-
-// NewStringAnyOfTestSizeLimit returns new AnyOfTestSizeLimit from string.
-func NewStringAnyOfTestSizeLimit(v string) AnyOfTestSizeLimit {
-	var s AnyOfTestSizeLimit
-	s.SetString(v)
-	return s
-}
-
 // Ref: #/components/schemas/AnyTest
 type AnyTest struct {
 	Empty    jx.Raw           `json:"empty"`
@@ -2215,52 +2124,6 @@ func (s *OnlyPatternedPropsObject) init() OnlyPatternedPropsObject {
 	return m
 }
 
-// NewOptAnyOfTest returns new OptAnyOfTest with value set to v.
-func NewOptAnyOfTest(v AnyOfTest) OptAnyOfTest {
-	return OptAnyOfTest{
-		Value: v,
-		Set:   true,
-	}
-}
-
-// OptAnyOfTest is optional AnyOfTest.
-type OptAnyOfTest struct {
-	Value AnyOfTest
-	Set   bool
-}
-
-// IsSet returns true if OptAnyOfTest was set.
-func (o OptAnyOfTest) IsSet() bool { return o.Set }
-
-// Reset unsets value.
-func (o *OptAnyOfTest) Reset() {
-	var v AnyOfTest
-	o.Value = v
-	o.Set = false
-}
-
-// SetTo sets value to v.
-func (o *OptAnyOfTest) SetTo(v AnyOfTest) {
-	o.Set = true
-	o.Value = v
-}
-
-// Get returns value and boolean that denotes whether value was set.
-func (o OptAnyOfTest) Get() (v AnyOfTest, ok bool) {
-	if !o.Set {
-		return v, false
-	}
-	return o.Value, true
-}
-
-// Or returns value if set, or given parameter if does not.
-func (o OptAnyOfTest) Or(d AnyOfTest) AnyOfTest {
-	if v, ok := o.Get(); ok {
-		return v
-	}
-	return d
-}
-
 // NewOptAnyTest returns new OptAnyTest with value set to v.
 func NewOptAnyTest(v AnyTest) OptAnyTest {
 	return OptAnyTest{
@@ -4112,7 +3975,6 @@ type Pet struct {
 	TestMap           OptStringStringMap   `json:"testMap"`
 	TestMapWithProps  OptMapWithProperties `json:"testMapWithProps"`
 	TestAny           OptAnyTest           `json:"testAny"`
-	TestAnyOf         OptAnyOfTest         `json:"testAnyOf"`
 	TestMaxProperties OptMaxPropertiesTest `json:"testMaxProperties"`
 	TestDate          OptDate              `json:"testDate"`
 	TestDuration      OptDuration          `json:"testDuration"`
@@ -4241,11 +4103,6 @@ func (s Pet) GetTestAny() OptAnyTest {
 	return s.TestAny
 }
 
-// GetTestAnyOf returns the value of TestAnyOf.
-func (s Pet) GetTestAnyOf() OptAnyOfTest {
-	return s.TestAnyOf
-}
-
 // GetTestMaxProperties returns the value of TestMaxProperties.
 func (s Pet) GetTestMaxProperties() OptMaxPropertiesTest {
 	return s.TestMaxProperties
@@ -4396,11 +4253,6 @@ func (s *Pet) SetTestAny(val OptAnyTest) {
 	s.TestAny = val
 }
 
-// SetTestAnyOf sets the value of TestAnyOf.
-func (s *Pet) SetTestAnyOf(val OptAnyOfTest) {
-	s.TestAnyOf = val
-}
-
 // SetTestMaxProperties sets the value of TestMaxProperties.
 func (s *Pet) SetTestMaxProperties(val OptMaxPropertiesTest) {
 	s.TestMaxProperties = val
diff --git a/internal/integration/sample_api_nsnc/oas_validators_gen.go b/internal/integration/sample_api_nsnc/oas_validators_gen.go
index c4dd32f7..051b03b1 100644
--- a/internal/integration/sample_api_nsnc/oas_validators_gen.go
+++ b/internal/integration/sample_api_nsnc/oas_validators_gen.go
@@ -10,46 +10,6 @@ import (
 	"github.com/ogen-go/ogen/validate"
 )
 
-func (s AnyOfTest) Validate() error {
-	var failures []validate.FieldError
-	if err := func() error {
-		if err := s.SizeLimit.Validate(); err != nil {
-			return err
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "sizeLimit",
-			Error: err,
-		})
-	}
-	if len(failures) > 0 {
-		return &validate.Error{Fields: failures}
-	}
-	return nil
-}
-func (s AnyOfTestSizeLimit) Validate() error {
-	switch s.Type {
-	case IntAnyOfTestSizeLimit:
-		return nil // no validation needed
-	case StringAnyOfTestSizeLimit:
-		if err := (validate.String{
-			MinLength:    0,
-			MinLengthSet: false,
-			MaxLength:    0,
-			MaxLengthSet: false,
-			Email:        false,
-			Hostname:     false,
-			Regex:        regexMap["^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"],
-		}).Validate(string(s.String)); err != nil {
-			return errors.Wrap(err, "string")
-		}
-		return nil
-	default:
-		return errors.Errorf("invalid type %q", s.Type)
-	}
-}
-
 func (s ArrayTest) Validate() error {
 	var failures []validate.FieldError
 	if err := func() error {
@@ -826,24 +786,6 @@ func (s Pet) Validate() error {
 			Error: err,
 		})
 	}
-	if err := func() error {
-		if s.TestAnyOf.Set {
-			if err := func() error {
-				if err := s.TestAnyOf.Value.Validate(); err != nil {
-					return err
-				}
-				return nil
-			}(); err != nil {
-				return err
-			}
-		}
-		return nil
-	}(); err != nil {
-		failures = append(failures, validate.FieldError{
-			Name:  "testAnyOf",
-			Error: err,
-		})
-	}
 	if len(failures) > 0 {
 		return &validate.Error{Fields: failures}
 	}


Test patch:
diff --git a/_testdata/positive/allof.yml b/_testdata/positive/allOf.yml
similarity index 100%
rename from _testdata/positive/allof.yml
rename to _testdata/positive/allOf.yml
diff --git a/_testdata/positive/anyOf.json b/_testdata/positive/anyOf.json
new file mode 100644
index 00000000..93f00228
--- /dev/null
+++ b/_testdata/positive/anyOf.json
@@ -0,0 +1,150 @@
+{
+  "openapi": "3.0.3",
+  "info": {
+    "title": "title",
+    "version": "v0.1.0"
+  },
+  "paths": {
+    "/jaegerAnyOf": {
+      "get": {
+        "operationId": "jaegerAnyOf",
+        "responses": {
+          "200": {
+            "description": "Type for testing some anyOf cases from Jaeger operator API schema.",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/JaegerAnyOf"
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/oneUUID": {
+      "get": {
+        "operationId": "oneUUID",
+        "responses": {
+          "200": {
+            "description": "Check that anyOf with one UUID works fine.",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/OneUUID"
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/integerNumber": {
+      "get": {
+        "operationId": "integerNumber",
+        "responses": {
+          "200": {
+            "description": "Check that anyOf with integer, number and string works fine.",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/IntegerNumber"
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  },
+  "components": {
+    "schemas": {
+      "JaegerAnyOf": {
+        "type": "object",
+        "required": [
+          "medium",
+          "sizeLimit"
+        ],
+        "properties": {
+          "medium": {
+            "type": "string"
+          },
+          "sizeLimit": {
+            "anyOf": [
+              {
+                "type": "integer"
+              },
+              {
+                "type": "string"
+              }
+            ],
+            "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
+            "x-kubernetes-int-or-string": true
+          }
+        }
+      },
+      "OneUUID": {
+        "required": [
+          "owner",
+          "version",
+          "subscription_id"
+        ],
+        "type": "object",
+        "properties": {
+          "owner": {
+            "type": "string",
+            "example": "uss1"
+          },
+          "version": {
+            "type": "integer",
+            "format": "int32",
+            "minimum": 1,
+            "exclusiveMinimum": false
+          },
+          "subscription_id": {
+            "anyOf": [
+              {
+                "$ref": "#/components/schemas/SubscriptionUUID"
+              }
+            ]
+          }
+        }
+      },
+      "UUIDv4": {
+        "type": "string",
+        "format": "uuid"
+      },
+      "SubscriptionUUID": {
+        "anyOf": [
+          {
+            "$ref": "#/components/schemas/UUIDv4"
+          }
+        ]
+      },
+      "IntegerNumber": {
+        "type": "object",
+        "required": [
+          "plain"
+        ],
+        "properties": {
+          "plain": {
+            "$ref": "#/components/schemas/AnyOfIntegerNumberString"
+          }
+        }
+      },
+      "AnyOfIntegerNumberString": {
+        "anyOf": [
+          {
+            "type": "integer"
+          },
+          {
+            "type": "number"
+          },
+          {
+            "type": "string"
+          }
+        ]
+      }
+    }
+  }
+}
diff --git a/_testdata/positive/anyOf_one_uuid.json b/_testdata/positive/anyOf_one_uuid.json
deleted file mode 100644
index 527ccc42..00000000
--- a/_testdata/positive/anyOf_one_uuid.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
-  "openapi": "3.0.3",
-  "info": {
-    "title": "title",
-    "version": "v0.1.0"
-  },
-  "paths": {
-    "/healthz": {
-      "get": {
-        "operationId": "probeLiveness",
-        "description": "Liveness probe for kubernetes",
-        "responses": {
-          "200": {
-            "description": "User info",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/OperationReference"
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  },
-  "components": {
-    "schemas": {
-      "OperationReference": {
-        "description": "The high-level information of a planned or active Operation with the URL\nof a USS to query for details.  Note: 'OVN' is returned ONLY to the USS that\ncreated the Operation but NEVER to other USS instances.",
-        "required": [
-          "owner",
-          "version",
-          "subscription_id"
-        ],
-        "type": "object",
-        "properties": {
-          "owner": {
-            "type": "string",
-            "example": "uss1",
-            "description": "Created by the DSS based on creating client's ID (via access token).  Used internal\nto the DSS for restricting mutation and deletion operations to owner.  Used by USSs\nto reject Operation update notifications originating from a USS that does not own\nthe Operation."
-          },
-          "version": {
-            "description": "Sequential version that the DSS increments every time the Operation changes.  A USS\nmay use this version to determine which Operation references have new details that\nmust be retrieved.",
-            "type": "integer",
-            "format": "int32",
-            "minimum": 1,
-            "exclusiveMinimum": false
-          },
-          "subscription_id": {
-            "description": "The ID of the Subscription that is ensuring the Operation owner receives relevant\nairspace updates.",
-            "anyOf": [
-              {
-                "$ref": "#/components/schemas/SubscriptionUUID"
-              }
-            ]
-          }
-        }
-      },
-      "UUIDv4": {
-        "type": "string",
-        "format": "uuid"
-      },
-      "SubscriptionUUID": {
-        "anyOf": [
-          {
-            "$ref": "#/components/schemas/UUIDv4"
-          }
-        ]
-      }
-    }
-  }
-}
diff --git a/_testdata/positive/sample.json b/_testdata/positive/sample.json
index 98f7a289..09c70366 100644
--- a/_testdata/positive/sample.json
+++ b/_testdata/positive/sample.json
@@ -1283,9 +1283,6 @@
           "testAny": {
             "$ref": "#/components/schemas/AnyTest"
           },
-          "testAnyOf": {
-            "$ref": "#/components/schemas/AnyOfTest"
-          },
           "testMaxProperties": {
             "$ref": "#/components/schemas/MaxPropertiesTest"
           },
@@ -1365,31 +1362,6 @@
           }
         }
       },
-      "AnyOfTest": {
-        "description": "Type for testing some anyOf cases from Jaeger operator API schema",
-        "required": [
-          "medium",
-          "sizeLimit"
-        ],
-        "properties": {
-          "medium": {
-            "type": "string"
-          },
-          "sizeLimit": {
-            "anyOf": [
-              {
-                "type": "integer"
-              },
-              {
-                "type": "string"
-              }
-            ],
-            "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
-            "x-kubernetes-int-or-string": true
-          }
-        },
-        "type": "object"
-      },
       "OneOfBugs": {
         "type": "object",
         "required": [
@@ -1903,4 +1875,4 @@
       }
     }
   }
-}
\ No newline at end of file
+}
diff --git a/internal/integration/any_of_test.go b/internal/integration/any_of_test.go
new file mode 100644
index 00000000..45c7e0f9
--- /dev/null
+++ b/internal/integration/any_of_test.go
@@ -0,0 +1,127 @@
+package integration
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/go-faster/jx"
+	"github.com/stretchr/testify/require"
+
+	api "github.com/ogen-go/ogen/internal/integration/test_anyof"
+)
+
+func TestValidateSum(t *testing.T) {
+	for i, tc := range []struct {
+		Input string
+		Error bool
+	}{
+		{
+			`{"medium": "text", "sizeLimit": "aboba"}`,
+			true,
+		},
+		{
+			`{"medium": "text", "sizeLimit": 10}`,
+			false,
+		},
+		{
+			`{"medium": "text", "sizeLimit": "10"}`,
+			false,
+		},
+	} {
+		tc := tc
+		t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
+			m := api.JaegerAnyOf{}
+			require.NoError(t, m.Decode(jx.DecodeStr(tc.Input)))
+
+			checker := require.NoError
+			if tc.Error {
+				checker = require.Error
+			}
+			checker(t, m.Validate())
+		})
+	}
+}
+
+func TestAnyOf(t *testing.T) {
+	t.Run("JaegerAnyOf", func(t *testing.T) {
+		for i, tc := range []struct {
+			Input    string
+			Expected api.JaegerAnyOfSizeLimitType
+			Error    bool
+		}{
+			{`10`, api.IntJaegerAnyOfSizeLimit, false},
+			{`"10"`, api.StringJaegerAnyOfSizeLimit, false},
+			{`true`, "", true},
+			{`null`, "", true},
+		} {
+			// Make range value copy to prevent data races.
+			tc := tc
+			t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
+				checker := require.NoError
+				if tc.Error {
+					checker = require.Error
+				}
+				r := api.JaegerAnyOfSizeLimit{}
+				checker(t, r.Decode(jx.DecodeStr(tc.Input)))
+				require.Equal(t, tc.Expected, r.Type)
+			})
+		}
+	})
+	t.Run("OneUUID", func(t *testing.T) {
+		for i, tc := range []struct {
+			Input    string
+			Expected api.OneUUIDSubscriptionIDType
+			Error    bool
+		}{
+			{`"fc9d49c6-1f3d-4ecb-92c7-be6d5049b3c8"`, api.SubscriptionUUIDOneUUIDSubscriptionID, false},
+			{`true`, "", true},
+			{`null`, "", true},
+		} {
+			// Make range value copy to prevent data races.
+			tc := tc
+			t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
+				checker := require.NoError
+				if tc.Error {
+					checker = require.Error
+				}
+				r := api.OneUUIDSubscriptionID{}
+				checker(t, r.Decode(jx.DecodeStr(tc.Input)))
+				require.Equal(t, tc.Expected, r.Type)
+			})
+		}
+	})
+	t.Run("AnyOfIntegerNumberString", func(t *testing.T) {
+		vInt := api.NewIntAnyOfIntegerNumberString
+		vFloat := api.NewFloat64AnyOfIntegerNumberString
+		vString := api.NewStringAnyOfIntegerNumberString
+		zero := api.AnyOfIntegerNumberString{}
+		for i, tc := range []struct {
+			Input    string
+			Expected api.AnyOfIntegerNumberString
+			Error    bool
+		}{
+			{`0`, vInt(0), false},
+			{`10`, vInt(10), false},
+			{`0.0`, vFloat(0.0), false},
+			{`10.0`, vFloat(10.0), false},
+			{`0e0`, vFloat(0e0), false},
+			{`0E0`, vFloat(0e0), false},
+			{`"10e0"`, vString("10e0"), false},
+			{`"foo"`, vString("foo"), false},
+			{`true`, zero, true},
+			{`null`, zero, true},
+		} {
+			// Make range value copy to prevent data races.
+			tc := tc
+			t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
+				checker := require.NoError
+				if tc.Error {
+					checker = require.Error
+				}
+				r := api.AnyOfIntegerNumberString{}
+				checker(t, r.Decode(jx.DecodeStr(tc.Input)))
+				require.Equal(t, tc.Expected, r)
+			})
+		}
+	})
+}
diff --git a/internal/integration/json_test.go b/internal/integration/json_test.go
index 0e3c1f10..fabf3989 100644
--- a/internal/integration/json_test.go
+++ b/internal/integration/json_test.go
@@ -833,30 +833,6 @@ func TestJSONSum(t *testing.T) {
 			})
 		}
 	})
-	t.Run("AnyOfTestSizeLimit", func(t *testing.T) {
-		for i, tc := range []struct {
-			Input    string
-			Expected api.AnyOfTestSizeLimitType
-			Error    bool
-		}{
-			{`10`, api.IntAnyOfTestSizeLimit, false},
-			{`"10"`, api.StringAnyOfTestSizeLimit, false},
-			{`true`, "", true},
-			{`null`, "", true},
-		} {
-			// Make range value copy to prevent data races.
-			tc := tc
-			t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
-				checker := require.NoError
-				if tc.Error {
-					checker = require.Error
-				}
-				r := api.AnyOfTestSizeLimit{}
-				checker(t, r.Decode(jx.DecodeStr(tc.Input)))
-				require.Equal(t, tc.Expected, r.Type)
-			})
-		}
-	})
 	t.Run("OptionalSum", func(t *testing.T) {
 		variant := func(t api.OneOfUUIDAndIntEnumType) api.OptOneOfUUIDAndIntEnum {
 			return api.NewOptOneOfUUIDAndIntEnum(api.OneOfUUIDAndIntEnum{
diff --git a/internal/integration/sample_api/oas_test_examples_gen_test.go b/internal/integration/sample_api/oas_test_examples_gen_test.go
index cf7fe623..62944706 100644
--- a/internal/integration/sample_api/oas_test_examples_gen_test.go
+++ b/internal/integration/sample_api/oas_test_examples_gen_test.go
@@ -11,30 +11,6 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
-func TestAnyOfTest_EncodeDecode(t *testing.T) {
-	var typ AnyOfTest
-	typ.SetFake()
-
-	e := jx.Encoder{}
-	typ.Encode(&e)
-	data := e.Bytes()
-	require.True(t, std.Valid(data), "Encoded: %s", data)
-
-	var typ2 AnyOfTest
-	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
-}
-func TestAnyOfTestSizeLimit_EncodeDecode(t *testing.T) {
-	var typ AnyOfTestSizeLimit
-	typ.SetFake()
-
-	e := jx.Encoder{}
-	typ.Encode(&e)
-	data := e.Bytes()
-	require.True(t, std.Valid(data), "Encoded: %s", data)
-
-	var typ2 AnyOfTestSizeLimit
-	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
-}
 func TestAnyTest_EncodeDecode(t *testing.T) {
 	var typ AnyTest
 	typ.SetFake()
diff --git a/internal/integration/test_anyof/oas_cfg_gen.go b/internal/integration/test_anyof/oas_cfg_gen.go
new file mode 100644
index 00000000..bb332e72
--- /dev/null
+++ b/internal/integration/test_anyof/oas_cfg_gen.go
@@ -0,0 +1,281 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"net/http"
+
+	"go.opentelemetry.io/otel"
+	"go.opentelemetry.io/otel/metric"
+	"go.opentelemetry.io/otel/metric/instrument/syncint64"
+	"go.opentelemetry.io/otel/trace"
+
+	ht "github.com/ogen-go/ogen/http"
+	"github.com/ogen-go/ogen/middleware"
+	"github.com/ogen-go/ogen/ogenerrors"
+	"github.com/ogen-go/ogen/ogenregex"
+	"github.com/ogen-go/ogen/otelogen"
+)
+
+var regexMap = map[string]ogenregex.Regexp{
+	"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$": ogenregex.MustCompile("^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"),
+}
+var (
+	// Allocate option closure once.
+	clientSpanKind = trace.WithSpanKind(trace.SpanKindClient)
+	// Allocate option closure once.
+	serverSpanKind = trace.WithSpanKind(trace.SpanKindServer)
+)
+
+type (
+	optionFunc[C any] func(*C)
+	otelOptionFunc    func(*otelConfig)
+)
+
+type otelConfig struct {
+	TracerProvider trace.TracerProvider
+	Tracer         trace.Tracer
+	MeterProvider  metric.MeterProvider
+	Meter          metric.Meter
+}
+
+func (cfg *otelConfig) initOTEL() {
+	if cfg.TracerProvider == nil {
+		cfg.TracerProvider = otel.GetTracerProvider()
+	}
+	if cfg.MeterProvider == nil {
+		cfg.MeterProvider = metric.NewNoopMeterProvider()
+	}
+	cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name,
+		trace.WithInstrumentationVersion(otelogen.SemVersion()),
+	)
+	cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name)
+}
+
+// ErrorHandler is error handler.
+type ErrorHandler = ogenerrors.ErrorHandler
+
+type serverConfig struct {
+	otelConfig
+	NotFound           http.HandlerFunc
+	MethodNotAllowed   func(w http.ResponseWriter, r *http.Request, allowed string)
+	ErrorHandler       ErrorHandler
+	Prefix             string
+	Middleware         Middleware
+	MaxMultipartMemory int64
+}
+
+// ServerOption is server config option.
+type ServerOption interface {
+	applyServer(*serverConfig)
+}
+
+var _ = []ServerOption{
+	(optionFunc[serverConfig])(nil),
+	(otelOptionFunc)(nil),
+}
+
+func (o optionFunc[C]) applyServer(c *C) {
+	o(c)
+}
+
+func (o otelOptionFunc) applyServer(c *serverConfig) {
+	o(&c.otelConfig)
+}
+
+func newServerConfig(opts ...ServerOption) serverConfig {
+	cfg := serverConfig{
+		NotFound: http.NotFound,
+		MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) {
+			w.Header().Set("Allow", allowed)
+			w.WriteHeader(http.StatusMethodNotAllowed)
+		},
+		ErrorHandler:       ogenerrors.DefaultErrorHandler,
+		Middleware:         nil,
+		MaxMultipartMemory: 32 << 20, // 32 MB
+	}
+	for _, opt := range opts {
+		opt.applyServer(&cfg)
+	}
+	cfg.initOTEL()
+	return cfg
+}
+
+type baseServer struct {
+	cfg      serverConfig
+	requests syncint64.Counter
+	errors   syncint64.Counter
+	duration syncint64.Histogram
+}
+
+func (s baseServer) notFound(w http.ResponseWriter, r *http.Request) {
+	s.cfg.NotFound(w, r)
+}
+
+func (s baseServer) notAllowed(w http.ResponseWriter, r *http.Request, allowed string) {
+	s.cfg.MethodNotAllowed(w, r, allowed)
+}
+
+func (cfg serverConfig) baseServer() (s baseServer, err error) {
+	s = baseServer{cfg: cfg}
+	if s.requests, err = s.cfg.Meter.SyncInt64().Counter(otelogen.ServerRequestCount); err != nil {
+		return s, err
+	}
+	if s.errors, err = s.cfg.Meter.SyncInt64().Counter(otelogen.ServerErrorsCount); err != nil {
+		return s, err
+	}
+	if s.duration, err = s.cfg.Meter.SyncInt64().Histogram(otelogen.ServerDuration); err != nil {
+		return s, err
+	}
+	return s, nil
+}
+
+type clientConfig struct {
+	otelConfig
+	Client ht.Client
+}
+
+// ClientOption is client config option.
+type ClientOption interface {
+	applyClient(*clientConfig)
+}
+
+var _ = []ClientOption{
+	(optionFunc[clientConfig])(nil),
+	(otelOptionFunc)(nil),
+}
+
+func (o optionFunc[C]) applyClient(c *C) {
+	o(c)
+}
+
+func (o otelOptionFunc) applyClient(c *clientConfig) {
+	o(&c.otelConfig)
+}
+
+func newClientConfig(opts ...ClientOption) clientConfig {
+	cfg := clientConfig{
+		Client: http.DefaultClient,
+	}
+	for _, opt := range opts {
+		opt.applyClient(&cfg)
+	}
+	cfg.initOTEL()
+	return cfg
+}
+
+type baseClient struct {
+	cfg      clientConfig
+	requests syncint64.Counter
+	errors   syncint64.Counter
+	duration syncint64.Histogram
+}
+
+func (cfg clientConfig) baseClient() (c baseClient, err error) {
+	c = baseClient{cfg: cfg}
+	if c.requests, err = c.cfg.Meter.SyncInt64().Counter(otelogen.ClientRequestCount); err != nil {
+		return c, err
+	}
+	if c.errors, err = c.cfg.Meter.SyncInt64().Counter(otelogen.ClientErrorsCount); err != nil {
+		return c, err
+	}
+	if c.duration, err = c.cfg.Meter.SyncInt64().Histogram(otelogen.ClientDuration); err != nil {
+		return c, err
+	}
+	return c, nil
+}
+
+// Option is config option.
+type Option interface {
+	ServerOption
+	ClientOption
+}
+
+// WithTracerProvider specifies a tracer provider to use for creating a tracer.
+//
+// If none is specified, the global provider is used.
+func WithTracerProvider(provider trace.TracerProvider) Option {
+	return otelOptionFunc(func(cfg *otelConfig) {
+		if provider != nil {
+			cfg.TracerProvider = provider
+		}
+	})
+}
+
+// WithMeterProvider specifies a meter provider to use for creating a meter.
+//
+// If none is specified, the metric.NewNoopMeterProvider is used.
+func WithMeterProvider(provider metric.MeterProvider) Option {
+	return otelOptionFunc(func(cfg *otelConfig) {
+		if provider != nil {
+			cfg.MeterProvider = provider
+		}
+	})
+}
+
+// WithClient specifies http client to use.
+func WithClient(client ht.Client) ClientOption {
+	return optionFunc[clientConfig](func(cfg *clientConfig) {
+		if client != nil {
+			cfg.Client = client
+		}
+	})
+}
+
+// WithNotFound specifies Not Found handler to use.
+func WithNotFound(notFound http.HandlerFunc) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		if notFound != nil {
+			cfg.NotFound = notFound
+		}
+	})
+}
+
+// WithMethodNotAllowed specifies Method Not Allowed handler to use.
+func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		if methodNotAllowed != nil {
+			cfg.MethodNotAllowed = methodNotAllowed
+		}
+	})
+}
+
+// WithErrorHandler specifies error handler to use.
+func WithErrorHandler(h ErrorHandler) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		if h != nil {
+			cfg.ErrorHandler = h
+		}
+	})
+}
+
+// WithPathPrefix specifies server path prefix.
+func WithPathPrefix(prefix string) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		cfg.Prefix = prefix
+	})
+}
+
+// WithMiddleware specifies middlewares to use.
+func WithMiddleware(m ...Middleware) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		switch len(m) {
+		case 0:
+			cfg.Middleware = nil
+		case 1:
+			cfg.Middleware = m[0]
+		default:
+			cfg.Middleware = middleware.ChainMiddlewares(m...)
+		}
+	})
+}
+
+// WithMaxMultipartMemory specifies limit of memory for storing file parts.
+// File parts which can't be stored in memory will be stored on disk in temporary files.
+func WithMaxMultipartMemory(max int64) ServerOption {
+	return optionFunc[serverConfig](func(cfg *serverConfig) {
+		if max > 0 {
+			cfg.MaxMultipartMemory = max
+		}
+	})
+}
diff --git a/internal/integration/test_anyof/oas_client_gen.go b/internal/integration/test_anyof/oas_client_gen.go
new file mode 100644
index 00000000..4a8f7d8a
--- /dev/null
+++ b/internal/integration/test_anyof/oas_client_gen.go
@@ -0,0 +1,239 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"context"
+	"net/url"
+	"time"
+
+	"github.com/go-faster/errors"
+	"go.opentelemetry.io/otel/attribute"
+	"go.opentelemetry.io/otel/codes"
+	"go.opentelemetry.io/otel/trace"
+
+	ht "github.com/ogen-go/ogen/http"
+	"github.com/ogen-go/ogen/otelogen"
+	"github.com/ogen-go/ogen/uri"
+)
+
+var _ Handler = struct {
+	*Client
+}{}
+
+// Client implements OAS client.
+type Client struct {
+	serverURL *url.URL
+	baseClient
+}
+
+// NewClient initializes new Client defined by OAS.
+func NewClient(serverURL string, opts ...ClientOption) (*Client, error) {
+	u, err := url.Parse(serverURL)
+	if err != nil {
+		return nil, err
+	}
+	c, err := newClientConfig(opts...).baseClient()
+	if err != nil {
+		return nil, err
+	}
+	return &Client{
+		serverURL:  u,
+		baseClient: c,
+	}, nil
+}
+
+type serverURLKey struct{}
+
+// WithServerURL sets context key to override server URL.
+func WithServerURL(ctx context.Context, u *url.URL) context.Context {
+	return context.WithValue(ctx, serverURLKey{}, u)
+}
+
+func (c *Client) requestURL(ctx context.Context) *url.URL {
+	u, ok := ctx.Value(serverURLKey{}).(*url.URL)
+	if !ok {
+		return c.serverURL
+	}
+	return u
+}
+
+// IntegerNumber invokes integerNumber operation.
+//
+// GET /integerNumber
+func (c *Client) IntegerNumber(ctx context.Context) (res IntegerNumber, err error) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("integerNumber"),
+	}
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	c.requests.Add(ctx, 1, otelAttrs...)
+
+	// Start a span for this request.
+	ctx, span := c.cfg.Tracer.Start(ctx, "IntegerNumber",
+		trace.WithAttributes(otelAttrs...),
+		clientSpanKind,
+	)
+	// Track stage for error reporting.
+	var stage string
+	defer func() {
+		if err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			c.errors.Add(ctx, 1, otelAttrs...)
+		}
+		span.End()
+	}()
+
+	stage = "BuildURL"
+	u := uri.Clone(c.requestURL(ctx))
+	u.Path += "/integerNumber"
+
+	stage = "EncodeRequest"
+	r, err := ht.NewRequest(ctx, "GET", u, nil)
+	if err != nil {
+		return res, errors.Wrap(err, "create request")
+	}
+
+	stage = "SendRequest"
+	resp, err := c.cfg.Client.Do(r)
+	if err != nil {
+		return res, errors.Wrap(err, "do request")
+	}
+	defer resp.Body.Close()
+
+	stage = "DecodeResponse"
+	result, err := decodeIntegerNumberResponse(resp)
+	if err != nil {
+		return res, errors.Wrap(err, "decode response")
+	}
+
+	return result, nil
+}
+
+// JaegerAnyOf invokes jaegerAnyOf operation.
+//
+// GET /jaegerAnyOf
+func (c *Client) JaegerAnyOf(ctx context.Context) (res JaegerAnyOf, err error) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("jaegerAnyOf"),
+	}
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	c.requests.Add(ctx, 1, otelAttrs...)
+
+	// Start a span for this request.
+	ctx, span := c.cfg.Tracer.Start(ctx, "JaegerAnyOf",
+		trace.WithAttributes(otelAttrs...),
+		clientSpanKind,
+	)
+	// Track stage for error reporting.
+	var stage string
+	defer func() {
+		if err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			c.errors.Add(ctx, 1, otelAttrs...)
+		}
+		span.End()
+	}()
+
+	stage = "BuildURL"
+	u := uri.Clone(c.requestURL(ctx))
+	u.Path += "/jaegerAnyOf"
+
+	stage = "EncodeRequest"
+	r, err := ht.NewRequest(ctx, "GET", u, nil)
+	if err != nil {
+		return res, errors.Wrap(err, "create request")
+	}
+
+	stage = "SendRequest"
+	resp, err := c.cfg.Client.Do(r)
+	if err != nil {
+		return res, errors.Wrap(err, "do request")
+	}
+	defer resp.Body.Close()
+
+	stage = "DecodeResponse"
+	result, err := decodeJaegerAnyOfResponse(resp)
+	if err != nil {
+		return res, errors.Wrap(err, "decode response")
+	}
+
+	return result, nil
+}
+
+// OneUUID invokes oneUUID operation.
+//
+// GET /oneUUID
+func (c *Client) OneUUID(ctx context.Context) (res OneUUID, err error) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("oneUUID"),
+	}
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	c.requests.Add(ctx, 1, otelAttrs...)
+
+	// Start a span for this request.
+	ctx, span := c.cfg.Tracer.Start(ctx, "OneUUID",
+		trace.WithAttributes(otelAttrs...),
+		clientSpanKind,
+	)
+	// Track stage for error reporting.
+	var stage string
+	defer func() {
+		if err != nil {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			c.errors.Add(ctx, 1, otelAttrs...)
+		}
+		span.End()
+	}()
+
+	stage = "BuildURL"
+	u := uri.Clone(c.requestURL(ctx))
+	u.Path += "/oneUUID"
+
+	stage = "EncodeRequest"
+	r, err := ht.NewRequest(ctx, "GET", u, nil)
+	if err != nil {
+		return res, errors.Wrap(err, "create request")
+	}
+
+	stage = "SendRequest"
+	resp, err := c.cfg.Client.Do(r)
+	if err != nil {
+		return res, errors.Wrap(err, "do request")
+	}
+	defer resp.Body.Close()
+
+	stage = "DecodeResponse"
+	result, err := decodeOneUUIDResponse(resp)
+	if err != nil {
+		return res, errors.Wrap(err, "decode response")
+	}
+
+	return result, nil
+}
diff --git a/internal/integration/test_anyof/oas_faker_gen.go b/internal/integration/test_anyof/oas_faker_gen.go
new file mode 100644
index 00000000..802e8903
--- /dev/null
+++ b/internal/integration/test_anyof/oas_faker_gen.go
@@ -0,0 +1,98 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"github.com/google/uuid"
+)
+
+// SetFake set fake values.
+func (s *AnyOfIntegerNumberString) SetFake() {
+	var elem int
+
+	{
+		elem = int(0)
+	}
+	s.SetInt(elem)
+}
+
+// SetFake set fake values.
+func (s *IntegerNumber) SetFake() {
+	{
+		{
+			s.Plain.SetFake()
+		}
+	}
+}
+
+// SetFake set fake values.
+func (s *JaegerAnyOf) SetFake() {
+	{
+		{
+			s.Medium = "string"
+		}
+	}
+	{
+		{
+			s.SizeLimit.SetFake()
+		}
+	}
+}
+
+// SetFake set fake values.
+func (s *JaegerAnyOfSizeLimit) SetFake() {
+	var elem int
+
+	{
+		elem = int(0)
+	}
+	s.SetInt(elem)
+}
+
+// SetFake set fake values.
+func (s *OneUUID) SetFake() {
+	{
+		{
+			s.Owner = "string"
+		}
+	}
+	{
+		{
+			s.Version = int32(0)
+		}
+	}
+	{
+		{
+			s.SubscriptionID.SetFake()
+		}
+	}
+}
+
+// SetFake set fake values.
+func (s *OneUUIDSubscriptionID) SetFake() {
+	var elem SubscriptionUUID
+
+	{
+		elem.SetFake()
+	}
+	s.SetSubscriptionUUID(elem)
+}
+
+// SetFake set fake values.
+func (s *SubscriptionUUID) SetFake() {
+	var elem UUIDv4
+
+	{
+		elem.SetFake()
+	}
+	s.SetUUIDv4(elem)
+}
+
+// SetFake set fake values.
+func (s *UUIDv4) SetFake() {
+	var unwrapped uuid.UUID
+	{
+		unwrapped = uuid.New()
+	}
+	*s = UUIDv4(unwrapped)
+}
diff --git a/internal/integration/test_anyof/oas_handlers_gen.go b/internal/integration/test_anyof/oas_handlers_gen.go
new file mode 100644
index 00000000..0f025c05
--- /dev/null
+++ b/internal/integration/test_anyof/oas_handlers_gen.go
@@ -0,0 +1,250 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"context"
+	"net/http"
+	"time"
+
+	"go.opentelemetry.io/otel/attribute"
+	"go.opentelemetry.io/otel/codes"
+	"go.opentelemetry.io/otel/trace"
+
+	"github.com/ogen-go/ogen/middleware"
+	"github.com/ogen-go/ogen/otelogen"
+)
+
+// handleIntegerNumberRequest handles integerNumber operation.
+//
+// GET /integerNumber
+func (s *Server) handleIntegerNumberRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("integerNumber"),
+	}
+
+	// Start a span for this request.
+	ctx, span := s.cfg.Tracer.Start(r.Context(), "IntegerNumber",
+		trace.WithAttributes(otelAttrs...),
+		serverSpanKind,
+	)
+	defer span.End()
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	s.requests.Add(ctx, 1, otelAttrs...)
+
+	var (
+		recordError = func(stage string, err error) {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			s.errors.Add(ctx, 1, otelAttrs...)
+		}
+		err error
+	)
+
+	var response IntegerNumber
+	if m := s.cfg.Middleware; m != nil {
+		mreq := middleware.Request{
+			Context:       ctx,
+			OperationName: "IntegerNumber",
+			OperationID:   "integerNumber",
+			Body:          nil,
+			Params:        middleware.Parameters{},
+			Raw:           r,
+		}
+
+		type (
+			Request  = struct{}
+			Params   = struct{}
+			Response = IntegerNumber
+		)
+		response, err = middleware.HookMiddleware[
+			Request,
+			Params,
+			Response,
+		](
+			m,
+			mreq,
+			nil,
+			func(ctx context.Context, request Request, params Params) (Response, error) {
+				return s.h.IntegerNumber(ctx)
+			},
+		)
+	} else {
+		response, err = s.h.IntegerNumber(ctx)
+	}
+	if err != nil {
+		recordError("Internal", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+
+	if err := encodeIntegerNumberResponse(response, w, span); err != nil {
+		recordError("EncodeResponse", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+}
+
+// handleJaegerAnyOfRequest handles jaegerAnyOf operation.
+//
+// GET /jaegerAnyOf
+func (s *Server) handleJaegerAnyOfRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("jaegerAnyOf"),
+	}
+
+	// Start a span for this request.
+	ctx, span := s.cfg.Tracer.Start(r.Context(), "JaegerAnyOf",
+		trace.WithAttributes(otelAttrs...),
+		serverSpanKind,
+	)
+	defer span.End()
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	s.requests.Add(ctx, 1, otelAttrs...)
+
+	var (
+		recordError = func(stage string, err error) {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			s.errors.Add(ctx, 1, otelAttrs...)
+		}
+		err error
+	)
+
+	var response JaegerAnyOf
+	if m := s.cfg.Middleware; m != nil {
+		mreq := middleware.Request{
+			Context:       ctx,
+			OperationName: "JaegerAnyOf",
+			OperationID:   "jaegerAnyOf",
+			Body:          nil,
+			Params:        middleware.Parameters{},
+			Raw:           r,
+		}
+
+		type (
+			Request  = struct{}
+			Params   = struct{}
+			Response = JaegerAnyOf
+		)
+		response, err = middleware.HookMiddleware[
+			Request,
+			Params,
+			Response,
+		](
+			m,
+			mreq,
+			nil,
+			func(ctx context.Context, request Request, params Params) (Response, error) {
+				return s.h.JaegerAnyOf(ctx)
+			},
+		)
+	} else {
+		response, err = s.h.JaegerAnyOf(ctx)
+	}
+	if err != nil {
+		recordError("Internal", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+
+	if err := encodeJaegerAnyOfResponse(response, w, span); err != nil {
+		recordError("EncodeResponse", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+}
+
+// handleOneUUIDRequest handles oneUUID operation.
+//
+// GET /oneUUID
+func (s *Server) handleOneUUIDRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
+	otelAttrs := []attribute.KeyValue{
+		otelogen.OperationID("oneUUID"),
+	}
+
+	// Start a span for this request.
+	ctx, span := s.cfg.Tracer.Start(r.Context(), "OneUUID",
+		trace.WithAttributes(otelAttrs...),
+		serverSpanKind,
+	)
+	defer span.End()
+
+	// Run stopwatch.
+	startTime := time.Now()
+	defer func() {
+		elapsedDuration := time.Since(startTime)
+		s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
+	}()
+
+	// Increment request counter.
+	s.requests.Add(ctx, 1, otelAttrs...)
+
+	var (
+		recordError = func(stage string, err error) {
+			span.RecordError(err)
+			span.SetStatus(codes.Error, stage)
+			s.errors.Add(ctx, 1, otelAttrs...)
+		}
+		err error
+	)
+
+	var response OneUUID
+	if m := s.cfg.Middleware; m != nil {
+		mreq := middleware.Request{
+			Context:       ctx,
+			OperationName: "OneUUID",
+			OperationID:   "oneUUID",
+			Body:          nil,
+			Params:        middleware.Parameters{},
+			Raw:           r,
+		}
+
+		type (
+			Request  = struct{}
+			Params   = struct{}
+			Response = OneUUID
+		)
+		response, err = middleware.HookMiddleware[
+			Request,
+			Params,
+			Response,
+		](
+			m,
+			mreq,
+			nil,
+			func(ctx context.Context, request Request, params Params) (Response, error) {
+				return s.h.OneUUID(ctx)
+			},
+		)
+	} else {
+		response, err = s.h.OneUUID(ctx)
+	}
+	if err != nil {
+		recordError("Internal", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+
+	if err := encodeOneUUIDResponse(response, w, span); err != nil {
+		recordError("EncodeResponse", err)
+		s.cfg.ErrorHandler(ctx, w, r, err)
+		return
+	}
+}
diff --git a/internal/integration/test_anyof/oas_json_gen.go b/internal/integration/test_anyof/oas_json_gen.go
new file mode 100644
index 00000000..0ffcdff5
--- /dev/null
+++ b/internal/integration/test_anyof/oas_json_gen.go
@@ -0,0 +1,587 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"math/bits"
+	"strconv"
+
+	"github.com/go-faster/errors"
+	"github.com/go-faster/jx"
+	"github.com/google/uuid"
+
+	"github.com/ogen-go/ogen/json"
+	"github.com/ogen-go/ogen/validate"
+)
+
+// Encode encodes AnyOfIntegerNumberString as json.
+func (s AnyOfIntegerNumberString) Encode(e *jx.Encoder) {
+	switch s.Type {
+	case IntAnyOfIntegerNumberString:
+		e.Int(s.Int)
+	case Float64AnyOfIntegerNumberString:
+		e.Float64(s.Float64)
+	case StringAnyOfIntegerNumberString:
+		e.Str(s.String)
+	}
+}
+
+// Decode decodes AnyOfIntegerNumberString from json.
+func (s *AnyOfIntegerNumberString) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode AnyOfIntegerNumberString to nil")
+	}
+	// Sum type type_discriminator.
+	switch t := d.Next(); t {
+	case jx.Number:
+		num, err := d.Num()
+		if err != nil {
+			return errors.Wrap(err, "parse number")
+		}
+		if d := jx.DecodeBytes(num); num.IsInt() {
+			v, err := d.Int()
+			s.Int = int(v)
+			if err != nil {
+				return err
+			}
+			s.Type = IntAnyOfIntegerNumberString
+		} else {
+			v, err := d.Float64()
+			s.Float64 = float64(v)
+			if err != nil {
+				return err
+			}
+			s.Type = Float64AnyOfIntegerNumberString
+		}
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringAnyOfIntegerNumberString
+	default:
+		return errors.Errorf("unexpected json type %q", t)
+	}
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s AnyOfIntegerNumberString) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *AnyOfIntegerNumberString) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode implements json.Marshaler.
+func (s IntegerNumber) Encode(e *jx.Encoder) {
+	e.ObjStart()
+	s.encodeFields(e)
+	e.ObjEnd()
+}
+
+// encodeFields encodes fields.
+func (s IntegerNumber) encodeFields(e *jx.Encoder) {
+	{
+
+		e.FieldStart("plain")
+		s.Plain.Encode(e)
+	}
+}
+
+var jsonFieldsNameOfIntegerNumber = [1]string{
+	0: "plain",
+}
+
+// Decode decodes IntegerNumber from json.
+func (s *IntegerNumber) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode IntegerNumber to nil")
+	}
+	var requiredBitSet [1]uint8
+
+	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
+		switch string(k) {
+		case "plain":
+			requiredBitSet[0] |= 1 << 0
+			if err := func() error {
+				if err := s.Plain.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"plain\"")
+			}
+		default:
+			return d.Skip()
+		}
+		return nil
+	}); err != nil {
+		return errors.Wrap(err, "decode IntegerNumber")
+	}
+	// Validate required fields.
+	var failures []validate.FieldError
+	for i, mask := range [1]uint8{
+		0b00000001,
+	} {
+		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
+			// Mask only required fields and check equality to mask using XOR.
+			//
+			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
+			// Bits of fields which would be set are actually bits of missed fields.
+			missed := bits.OnesCount8(result)
+			for bitN := 0; bitN < missed; bitN++ {
+				bitIdx := bits.TrailingZeros8(result)
+				fieldIdx := i*8 + bitIdx
+				var name string
+				if fieldIdx < len(jsonFieldsNameOfIntegerNumber) {
+					name = jsonFieldsNameOfIntegerNumber[fieldIdx]
+				} else {
+					name = strconv.Itoa(fieldIdx)
+				}
+				failures = append(failures, validate.FieldError{
+					Name:  name,
+					Error: validate.ErrFieldRequired,
+				})
+				// Reset bit.
+				result &^= 1 << bitIdx
+			}
+		}
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s IntegerNumber) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *IntegerNumber) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode implements json.Marshaler.
+func (s JaegerAnyOf) Encode(e *jx.Encoder) {
+	e.ObjStart()
+	s.encodeFields(e)
+	e.ObjEnd()
+}
+
+// encodeFields encodes fields.
+func (s JaegerAnyOf) encodeFields(e *jx.Encoder) {
+	{
+
+		e.FieldStart("medium")
+		e.Str(s.Medium)
+	}
+	{
+
+		e.FieldStart("sizeLimit")
+		s.SizeLimit.Encode(e)
+	}
+}
+
+var jsonFieldsNameOfJaegerAnyOf = [2]string{
+	0: "medium",
+	1: "sizeLimit",
+}
+
+// Decode decodes JaegerAnyOf from json.
+func (s *JaegerAnyOf) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode JaegerAnyOf to nil")
+	}
+	var requiredBitSet [1]uint8
+
+	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
+		switch string(k) {
+		case "medium":
+			requiredBitSet[0] |= 1 << 0
+			if err := func() error {
+				v, err := d.Str()
+				s.Medium = string(v)
+				if err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"medium\"")
+			}
+		case "sizeLimit":
+			requiredBitSet[0] |= 1 << 1
+			if err := func() error {
+				if err := s.SizeLimit.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"sizeLimit\"")
+			}
+		default:
+			return d.Skip()
+		}
+		return nil
+	}); err != nil {
+		return errors.Wrap(err, "decode JaegerAnyOf")
+	}
+	// Validate required fields.
+	var failures []validate.FieldError
+	for i, mask := range [1]uint8{
+		0b00000011,
+	} {
+		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
+			// Mask only required fields and check equality to mask using XOR.
+			//
+			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
+			// Bits of fields which would be set are actually bits of missed fields.
+			missed := bits.OnesCount8(result)
+			for bitN := 0; bitN < missed; bitN++ {
+				bitIdx := bits.TrailingZeros8(result)
+				fieldIdx := i*8 + bitIdx
+				var name string
+				if fieldIdx < len(jsonFieldsNameOfJaegerAnyOf) {
+					name = jsonFieldsNameOfJaegerAnyOf[fieldIdx]
+				} else {
+					name = strconv.Itoa(fieldIdx)
+				}
+				failures = append(failures, validate.FieldError{
+					Name:  name,
+					Error: validate.ErrFieldRequired,
+				})
+				// Reset bit.
+				result &^= 1 << bitIdx
+			}
+		}
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s JaegerAnyOf) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *JaegerAnyOf) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode encodes JaegerAnyOfSizeLimit as json.
+func (s JaegerAnyOfSizeLimit) Encode(e *jx.Encoder) {
+	switch s.Type {
+	case IntJaegerAnyOfSizeLimit:
+		e.Int(s.Int)
+	case StringJaegerAnyOfSizeLimit:
+		e.Str(s.String)
+	}
+}
+
+// Decode decodes JaegerAnyOfSizeLimit from json.
+func (s *JaegerAnyOfSizeLimit) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode JaegerAnyOfSizeLimit to nil")
+	}
+	// Sum type type_discriminator.
+	switch t := d.Next(); t {
+	case jx.Number:
+		v, err := d.Int()
+		s.Int = int(v)
+		if err != nil {
+			return err
+		}
+		s.Type = IntJaegerAnyOfSizeLimit
+	case jx.String:
+		v, err := d.Str()
+		s.String = string(v)
+		if err != nil {
+			return err
+		}
+		s.Type = StringJaegerAnyOfSizeLimit
+	default:
+		return errors.Errorf("unexpected json type %q", t)
+	}
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s JaegerAnyOfSizeLimit) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *JaegerAnyOfSizeLimit) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode implements json.Marshaler.
+func (s OneUUID) Encode(e *jx.Encoder) {
+	e.ObjStart()
+	s.encodeFields(e)
+	e.ObjEnd()
+}
+
+// encodeFields encodes fields.
+func (s OneUUID) encodeFields(e *jx.Encoder) {
+	{
+
+		e.FieldStart("owner")
+		e.Str(s.Owner)
+	}
+	{
+
+		e.FieldStart("version")
+		e.Int32(s.Version)
+	}
+	{
+
+		e.FieldStart("subscription_id")
+		s.SubscriptionID.Encode(e)
+	}
+}
+
+var jsonFieldsNameOfOneUUID = [3]string{
+	0: "owner",
+	1: "version",
+	2: "subscription_id",
+}
+
+// Decode decodes OneUUID from json.
+func (s *OneUUID) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode OneUUID to nil")
+	}
+	var requiredBitSet [1]uint8
+
+	if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
+		switch string(k) {
+		case "owner":
+			requiredBitSet[0] |= 1 << 0
+			if err := func() error {
+				v, err := d.Str()
+				s.Owner = string(v)
+				if err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"owner\"")
+			}
+		case "version":
+			requiredBitSet[0] |= 1 << 1
+			if err := func() error {
+				v, err := d.Int32()
+				s.Version = int32(v)
+				if err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"version\"")
+			}
+		case "subscription_id":
+			requiredBitSet[0] |= 1 << 2
+			if err := func() error {
+				if err := s.SubscriptionID.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return errors.Wrap(err, "decode field \"subscription_id\"")
+			}
+		default:
+			return d.Skip()
+		}
+		return nil
+	}); err != nil {
+		return errors.Wrap(err, "decode OneUUID")
+	}
+	// Validate required fields.
+	var failures []validate.FieldError
+	for i, mask := range [1]uint8{
+		0b00000111,
+	} {
+		if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
+			// Mask only required fields and check equality to mask using XOR.
+			//
+			// If XOR result is not zero, result is not equal to expected, so some fields are missed.
+			// Bits of fields which would be set are actually bits of missed fields.
+			missed := bits.OnesCount8(result)
+			for bitN := 0; bitN < missed; bitN++ {
+				bitIdx := bits.TrailingZeros8(result)
+				fieldIdx := i*8 + bitIdx
+				var name string
+				if fieldIdx < len(jsonFieldsNameOfOneUUID) {
+					name = jsonFieldsNameOfOneUUID[fieldIdx]
+				} else {
+					name = strconv.Itoa(fieldIdx)
+				}
+				failures = append(failures, validate.FieldError{
+					Name:  name,
+					Error: validate.ErrFieldRequired,
+				})
+				// Reset bit.
+				result &^= 1 << bitIdx
+			}
+		}
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s OneUUID) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *OneUUID) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode encodes OneUUIDSubscriptionID as json.
+func (s OneUUIDSubscriptionID) Encode(e *jx.Encoder) {
+	switch s.Type {
+	case SubscriptionUUIDOneUUIDSubscriptionID:
+		s.SubscriptionUUID.Encode(e)
+	}
+}
+
+// Decode decodes OneUUIDSubscriptionID from json.
+func (s *OneUUIDSubscriptionID) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode OneUUIDSubscriptionID to nil")
+	}
+	// Sum type type_discriminator.
+	switch t := d.Next(); t {
+	case jx.String:
+		if err := s.SubscriptionUUID.Decode(d); err != nil {
+			return err
+		}
+		s.Type = SubscriptionUUIDOneUUIDSubscriptionID
+	default:
+		return errors.Errorf("unexpected json type %q", t)
+	}
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s OneUUIDSubscriptionID) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *OneUUIDSubscriptionID) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode encodes SubscriptionUUID as json.
+func (s SubscriptionUUID) Encode(e *jx.Encoder) {
+	switch s.Type {
+	case UUIDv4SubscriptionUUID:
+		s.UUIDv4.Encode(e)
+	}
+}
+
+// Decode decodes SubscriptionUUID from json.
+func (s *SubscriptionUUID) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode SubscriptionUUID to nil")
+	}
+	// Sum type type_discriminator.
+	switch t := d.Next(); t {
+	case jx.String:
+		if err := s.UUIDv4.Decode(d); err != nil {
+			return err
+		}
+		s.Type = UUIDv4SubscriptionUUID
+	default:
+		return errors.Errorf("unexpected json type %q", t)
+	}
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s SubscriptionUUID) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *SubscriptionUUID) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
+
+// Encode encodes UUIDv4 as json.
+func (s UUIDv4) Encode(e *jx.Encoder) {
+	unwrapped := uuid.UUID(s)
+
+	json.EncodeUUID(e, unwrapped)
+}
+
+// Decode decodes UUIDv4 from json.
+func (s *UUIDv4) Decode(d *jx.Decoder) error {
+	if s == nil {
+		return errors.New("invalid: unable to decode UUIDv4 to nil")
+	}
+	var unwrapped uuid.UUID
+	if err := func() error {
+		v, err := json.DecodeUUID(d)
+		unwrapped = v
+		if err != nil {
+			return err
+		}
+		return nil
+	}(); err != nil {
+		return errors.Wrap(err, "alias")
+	}
+	*s = UUIDv4(unwrapped)
+	return nil
+}
+
+// MarshalJSON implements stdjson.Marshaler.
+func (s UUIDv4) MarshalJSON() ([]byte, error) {
+	e := jx.Encoder{}
+	s.Encode(&e)
+	return e.Bytes(), nil
+}
+
+// UnmarshalJSON implements stdjson.Unmarshaler.
+func (s *UUIDv4) UnmarshalJSON(data []byte) error {
+	d := jx.DecodeBytes(data)
+	return s.Decode(d)
+}
diff --git a/internal/integration/test_anyof/oas_middleware_gen.go b/internal/integration/test_anyof/oas_middleware_gen.go
new file mode 100644
index 00000000..6f58a1a7
--- /dev/null
+++ b/internal/integration/test_anyof/oas_middleware_gen.go
@@ -0,0 +1,10 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"github.com/ogen-go/ogen/middleware"
+)
+
+// Middleware is middleware type.
+type Middleware = middleware.Middleware
diff --git a/internal/integration/test_anyof/oas_request_decoders_gen.go b/internal/integration/test_anyof/oas_request_decoders_gen.go
new file mode 100644
index 00000000..ae379a2d
--- /dev/null
+++ b/internal/integration/test_anyof/oas_request_decoders_gen.go
@@ -0,0 +1,3 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
diff --git a/internal/integration/test_anyof/oas_request_encoders_gen.go b/internal/integration/test_anyof/oas_request_encoders_gen.go
new file mode 100644
index 00000000..ae379a2d
--- /dev/null
+++ b/internal/integration/test_anyof/oas_request_encoders_gen.go
@@ -0,0 +1,3 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
diff --git a/internal/integration/test_anyof/oas_response_decoders_gen.go b/internal/integration/test_anyof/oas_response_decoders_gen.go
new file mode 100644
index 00000000..914247ed
--- /dev/null
+++ b/internal/integration/test_anyof/oas_response_decoders_gen.go
@@ -0,0 +1,122 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"io"
+	"mime"
+	"net/http"
+
+	"github.com/go-faster/errors"
+	"github.com/go-faster/jx"
+
+	"github.com/ogen-go/ogen/validate"
+)
+
+func decodeIntegerNumberResponse(resp *http.Response) (res IntegerNumber, err error) {
+	switch resp.StatusCode {
+	case 200:
+		// Code 200.
+		ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
+		if err != nil {
+			return res, errors.Wrap(err, "parse media type")
+		}
+		switch {
+		case ct == "application/json":
+			b, err := io.ReadAll(resp.Body)
+			if err != nil {
+				return res, err
+			}
+
+			d := jx.DecodeBytes(b)
+			var response IntegerNumber
+			if err := func() error {
+				if err := response.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return res, errors.Wrap(err, "decode \"application/json\"")
+			}
+			if err := d.Skip(); err != io.EOF {
+				return res, errors.New("unexpected trailing data")
+			}
+			return response, nil
+		default:
+			return res, validate.InvalidContentType(ct)
+		}
+	}
+	return res, validate.UnexpectedStatusCode(resp.StatusCode)
+}
+
+func decodeJaegerAnyOfResponse(resp *http.Response) (res JaegerAnyOf, err error) {
+	switch resp.StatusCode {
+	case 200:
+		// Code 200.
+		ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
+		if err != nil {
+			return res, errors.Wrap(err, "parse media type")
+		}
+		switch {
+		case ct == "application/json":
+			b, err := io.ReadAll(resp.Body)
+			if err != nil {
+				return res, err
+			}
+
+			d := jx.DecodeBytes(b)
+			var response JaegerAnyOf
+			if err := func() error {
+				if err := response.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return res, errors.Wrap(err, "decode \"application/json\"")
+			}
+			if err := d.Skip(); err != io.EOF {
+				return res, errors.New("unexpected trailing data")
+			}
+			return response, nil
+		default:
+			return res, validate.InvalidContentType(ct)
+		}
+	}
+	return res, validate.UnexpectedStatusCode(resp.StatusCode)
+}
+
+func decodeOneUUIDResponse(resp *http.Response) (res OneUUID, err error) {
+	switch resp.StatusCode {
+	case 200:
+		// Code 200.
+		ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
+		if err != nil {
+			return res, errors.Wrap(err, "parse media type")
+		}
+		switch {
+		case ct == "application/json":
+			b, err := io.ReadAll(resp.Body)
+			if err != nil {
+				return res, err
+			}
+
+			d := jx.DecodeBytes(b)
+			var response OneUUID
+			if err := func() error {
+				if err := response.Decode(d); err != nil {
+					return err
+				}
+				return nil
+			}(); err != nil {
+				return res, errors.Wrap(err, "decode \"application/json\"")
+			}
+			if err := d.Skip(); err != io.EOF {
+				return res, errors.New("unexpected trailing data")
+			}
+			return response, nil
+		default:
+			return res, validate.InvalidContentType(ct)
+		}
+	}
+	return res, validate.UnexpectedStatusCode(resp.StatusCode)
+}
diff --git a/internal/integration/test_anyof/oas_response_encoders_gen.go b/internal/integration/test_anyof/oas_response_encoders_gen.go
new file mode 100644
index 00000000..b7b388c3
--- /dev/null
+++ b/internal/integration/test_anyof/oas_response_encoders_gen.go
@@ -0,0 +1,51 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"net/http"
+
+	"github.com/go-faster/errors"
+	"github.com/go-faster/jx"
+	"go.opentelemetry.io/otel/codes"
+	"go.opentelemetry.io/otel/trace"
+)
+
+func encodeIntegerNumberResponse(response IntegerNumber, w http.ResponseWriter, span trace.Span) error {
+	w.Header().Set("Content-Type", "application/json")
+	w.WriteHeader(200)
+	span.SetStatus(codes.Ok, http.StatusText(200))
+
+	e := jx.GetEncoder()
+	response.Encode(e)
+	if _, err := e.WriteTo(w); err != nil {
+		return errors.Wrap(err, "write")
+	}
+	return nil
+}
+
+func encodeJaegerAnyOfResponse(response JaegerAnyOf, w http.ResponseWriter, span trace.Span) error {
+	w.Header().Set("Content-Type", "application/json")
+	w.WriteHeader(200)
+	span.SetStatus(codes.Ok, http.StatusText(200))
+
+	e := jx.GetEncoder()
+	response.Encode(e)
+	if _, err := e.WriteTo(w); err != nil {
+		return errors.Wrap(err, "write")
+	}
+	return nil
+}
+
+func encodeOneUUIDResponse(response OneUUID, w http.ResponseWriter, span trace.Span) error {
+	w.Header().Set("Content-Type", "application/json")
+	w.WriteHeader(200)
+	span.SetStatus(codes.Ok, http.StatusText(200))
+
+	e := jx.GetEncoder()
+	response.Encode(e)
+	if _, err := e.WriteTo(w); err != nil {
+		return errors.Wrap(err, "write")
+	}
+	return nil
+}
diff --git a/internal/integration/test_anyof/oas_router_gen.go b/internal/integration/test_anyof/oas_router_gen.go
new file mode 100644
index 00000000..0c5fa51f
--- /dev/null
+++ b/internal/integration/test_anyof/oas_router_gen.go
@@ -0,0 +1,225 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"net/http"
+	"strings"
+)
+
+// ServeHTTP serves http request as defined by OpenAPI v3 specification,
+// calling handler that matches the path or returning not found error.
+func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+	elem := r.URL.Path
+	if prefix := s.cfg.Prefix; len(prefix) > 0 {
+		if strings.HasPrefix(elem, prefix) {
+			// Cut prefix from the path.
+			elem = strings.TrimPrefix(elem, prefix)
+		} else {
+			// Prefix doesn't match.
+			s.notFound(w, r)
+			return
+		}
+	}
+	if len(elem) == 0 {
+		s.notFound(w, r)
+		return
+	}
+
+	// Static code generated router with unwrapped path search.
+	switch {
+	default:
+		if len(elem) == 0 {
+			break
+		}
+		switch elem[0] {
+		case '/': // Prefix: "/"
+			if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
+				elem = elem[l:]
+			} else {
+				break
+			}
+
+			if len(elem) == 0 {
+				break
+			}
+			switch elem[0] {
+			case 'i': // Prefix: "integerNumber"
+				if l := len("integerNumber"); len(elem) >= l && elem[0:l] == "integerNumber" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					// Leaf node.
+					switch r.Method {
+					case "GET":
+						s.handleIntegerNumberRequest([0]string{}, w, r)
+					default:
+						s.notAllowed(w, r, "GET")
+					}
+
+					return
+				}
+			case 'j': // Prefix: "jaegerAnyOf"
+				if l := len("jaegerAnyOf"); len(elem) >= l && elem[0:l] == "jaegerAnyOf" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					// Leaf node.
+					switch r.Method {
+					case "GET":
+						s.handleJaegerAnyOfRequest([0]string{}, w, r)
+					default:
+						s.notAllowed(w, r, "GET")
+					}
+
+					return
+				}
+			case 'o': // Prefix: "oneUUID"
+				if l := len("oneUUID"); len(elem) >= l && elem[0:l] == "oneUUID" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					// Leaf node.
+					switch r.Method {
+					case "GET":
+						s.handleOneUUIDRequest([0]string{}, w, r)
+					default:
+						s.notAllowed(w, r, "GET")
+					}
+
+					return
+				}
+			}
+		}
+	}
+	s.notFound(w, r)
+}
+
+// Route is route object.
+type Route struct {
+	name        string
+	operationID string
+	count       int
+	args        [0]string
+}
+
+// Name returns ogen operation name.
+//
+// It is guaranteed to be unique and not empty.
+func (r Route) Name() string {
+	return r.name
+}
+
+// OperationID returns OpenAPI operationId.
+func (r Route) OperationID() string {
+	return r.operationID
+}
+
+// Args returns parsed arguments.
+func (r Route) Args() []string {
+	return r.args[:r.count]
+}
+
+// FindRoute finds Route for given method and path.
+func (s *Server) FindRoute(method, path string) (r Route, _ bool) {
+	var (
+		args = [0]string{}
+		elem = path
+	)
+	r.args = args
+	if elem == "" {
+		return r, false
+	}
+
+	// Static code generated router with unwrapped path search.
+	switch {
+	default:
+		if len(elem) == 0 {
+			break
+		}
+		switch elem[0] {
+		case '/': // Prefix: "/"
+			if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
+				elem = elem[l:]
+			} else {
+				break
+			}
+
+			if len(elem) == 0 {
+				break
+			}
+			switch elem[0] {
+			case 'i': // Prefix: "integerNumber"
+				if l := len("integerNumber"); len(elem) >= l && elem[0:l] == "integerNumber" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					switch method {
+					case "GET":
+						// Leaf: IntegerNumber
+						r.name = "IntegerNumber"
+						r.operationID = "integerNumber"
+						r.args = args
+						r.count = 0
+						return r, true
+					default:
+						return
+					}
+				}
+			case 'j': // Prefix: "jaegerAnyOf"
+				if l := len("jaegerAnyOf"); len(elem) >= l && elem[0:l] == "jaegerAnyOf" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					switch method {
+					case "GET":
+						// Leaf: JaegerAnyOf
+						r.name = "JaegerAnyOf"
+						r.operationID = "jaegerAnyOf"
+						r.args = args
+						r.count = 0
+						return r, true
+					default:
+						return
+					}
+				}
+			case 'o': // Prefix: "oneUUID"
+				if l := len("oneUUID"); len(elem) >= l && elem[0:l] == "oneUUID" {
+					elem = elem[l:]
+				} else {
+					break
+				}
+
+				if len(elem) == 0 {
+					switch method {
+					case "GET":
+						// Leaf: OneUUID
+						r.name = "OneUUID"
+						r.operationID = "oneUUID"
+						r.args = args
+						r.count = 0
+						return r, true
+					default:
+						return
+					}
+				}
+			}
+		}
+	}
+	return r, false
+}
diff --git a/internal/integration/test_anyof/oas_schemas_gen.go b/internal/integration/test_anyof/oas_schemas_gen.go
new file mode 100644
index 00000000..42ef4907
--- /dev/null
+++ b/internal/integration/test_anyof/oas_schemas_gen.go
@@ -0,0 +1,321 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"github.com/google/uuid"
+)
+
+// Ref: #/components/schemas/AnyOfIntegerNumberString
+// AnyOfIntegerNumberString represents sum type.
+type AnyOfIntegerNumberString struct {
+	Type    AnyOfIntegerNumberStringType // switch on this field
+	Int     int
+	Float64 float64
+	String  string
+}
+
+// AnyOfIntegerNumberStringType is oneOf type of AnyOfIntegerNumberString.
+type AnyOfIntegerNumberStringType string
+
+// Possible values for AnyOfIntegerNumberStringType.
+const (
+	IntAnyOfIntegerNumberString     AnyOfIntegerNumberStringType = "int"
+	Float64AnyOfIntegerNumberString AnyOfIntegerNumberStringType = "float64"
+	StringAnyOfIntegerNumberString  AnyOfIntegerNumberStringType = "string"
+)
+
+// IsInt reports whether AnyOfIntegerNumberString is int.
+func (s AnyOfIntegerNumberString) IsInt() bool { return s.Type == IntAnyOfIntegerNumberString }
+
+// IsFloat64 reports whether AnyOfIntegerNumberString is float64.
+func (s AnyOfIntegerNumberString) IsFloat64() bool { return s.Type == Float64AnyOfIntegerNumberString }
+
+// IsString reports whether AnyOfIntegerNumberString is string.
+func (s AnyOfIntegerNumberString) IsString() bool { return s.Type == StringAnyOfIntegerNumberString }
+
+// SetInt sets AnyOfIntegerNumberString to int.
+func (s *AnyOfIntegerNumberString) SetInt(v int) {
+	s.Type = IntAnyOfIntegerNumberString
+	s.Int = v
+}
+
+// GetInt returns int and true boolean if AnyOfIntegerNumberString is int.
+func (s AnyOfIntegerNumberString) GetInt() (v int, ok bool) {
+	if !s.IsInt() {
+		return v, false
+	}
+	return s.Int, true
+}
+
+// NewIntAnyOfIntegerNumberString returns new AnyOfIntegerNumberString from int.
+func NewIntAnyOfIntegerNumberString(v int) AnyOfIntegerNumberString {
+	var s AnyOfIntegerNumberString
+	s.SetInt(v)
+	return s
+}
+
+// SetFloat64 sets AnyOfIntegerNumberString to float64.
+func (s *AnyOfIntegerNumberString) SetFloat64(v float64) {
+	s.Type = Float64AnyOfIntegerNumberString
+	s.Float64 = v
+}
+
+// GetFloat64 returns float64 and true boolean if AnyOfIntegerNumberString is float64.
+func (s AnyOfIntegerNumberString) GetFloat64() (v float64, ok bool) {
+	if !s.IsFloat64() {
+		return v, false
+	}
+	return s.Float64, true
+}
+
+// NewFloat64AnyOfIntegerNumberString returns new AnyOfIntegerNumberString from float64.
+func NewFloat64AnyOfIntegerNumberString(v float64) AnyOfIntegerNumberString {
+	var s AnyOfIntegerNumberString
+	s.SetFloat64(v)
+	return s
+}
+
+// SetString sets AnyOfIntegerNumberString to string.
+func (s *AnyOfIntegerNumberString) SetString(v string) {
+	s.Type = StringAnyOfIntegerNumberString
+	s.String = v
+}
+
+// GetString returns string and true boolean if AnyOfIntegerNumberString is string.
+func (s AnyOfIntegerNumberString) GetString() (v string, ok bool) {
+	if !s.IsString() {
+		return v, false
+	}
+	return s.String, true
+}
+
+// NewStringAnyOfIntegerNumberString returns new AnyOfIntegerNumberString from string.
+func NewStringAnyOfIntegerNumberString(v string) AnyOfIntegerNumberString {
+	var s AnyOfIntegerNumberString
+	s.SetString(v)
+	return s
+}
+
+// Ref: #/components/schemas/IntegerNumber
+type IntegerNumber struct {
+	Plain AnyOfIntegerNumberString `json:"plain"`
+}
+
+// GetPlain returns the value of Plain.
+func (s IntegerNumber) GetPlain() AnyOfIntegerNumberString {
+	return s.Plain
+}
+
+// SetPlain sets the value of Plain.
+func (s *IntegerNumber) SetPlain(val AnyOfIntegerNumberString) {
+	s.Plain = val
+}
+
+// Ref: #/components/schemas/JaegerAnyOf
+type JaegerAnyOf struct {
+	Medium    string               `json:"medium"`
+	SizeLimit JaegerAnyOfSizeLimit `json:"sizeLimit"`
+}
+
+// GetMedium returns the value of Medium.
+func (s JaegerAnyOf) GetMedium() string {
+	return s.Medium
+}
+
+// GetSizeLimit returns the value of SizeLimit.
+func (s JaegerAnyOf) GetSizeLimit() JaegerAnyOfSizeLimit {
+	return s.SizeLimit
+}
+
+// SetMedium sets the value of Medium.
+func (s *JaegerAnyOf) SetMedium(val string) {
+	s.Medium = val
+}
+
+// SetSizeLimit sets the value of SizeLimit.
+func (s *JaegerAnyOf) SetSizeLimit(val JaegerAnyOfSizeLimit) {
+	s.SizeLimit = val
+}
+
+// JaegerAnyOfSizeLimit represents sum type.
+type JaegerAnyOfSizeLimit struct {
+	Type   JaegerAnyOfSizeLimitType // switch on this field
+	Int    int
+	String string
+}
+
+// JaegerAnyOfSizeLimitType is oneOf type of JaegerAnyOfSizeLimit.
+type JaegerAnyOfSizeLimitType string
+
+// Possible values for JaegerAnyOfSizeLimitType.
+const (
+	IntJaegerAnyOfSizeLimit    JaegerAnyOfSizeLimitType = "int"
+	StringJaegerAnyOfSizeLimit JaegerAnyOfSizeLimitType = "string"
+)
+
+// IsInt reports whether JaegerAnyOfSizeLimit is int.
+func (s JaegerAnyOfSizeLimit) IsInt() bool { return s.Type == IntJaegerAnyOfSizeLimit }
+
+// IsString reports whether JaegerAnyOfSizeLimit is string.
+func (s JaegerAnyOfSizeLimit) IsString() bool { return s.Type == StringJaegerAnyOfSizeLimit }
+
+// SetInt sets JaegerAnyOfSizeLimit to int.
+func (s *JaegerAnyOfSizeLimit) SetInt(v int) {
+	s.Type = IntJaegerAnyOfSizeLimit
+	s.Int = v
+}
+
+// GetInt returns int and true boolean if JaegerAnyOfSizeLimit is int.
+func (s JaegerAnyOfSizeLimit) GetInt() (v int, ok bool) {
+	if !s.IsInt() {
+		return v, false
+	}
+	return s.Int, true
+}
+
+// NewIntJaegerAnyOfSizeLimit returns new JaegerAnyOfSizeLimit from int.
+func NewIntJaegerAnyOfSizeLimit(v int) JaegerAnyOfSizeLimit {
+	var s JaegerAnyOfSizeLimit
+	s.SetInt(v)
+	return s
+}
+
+// SetString sets JaegerAnyOfSizeLimit to string.
+func (s *JaegerAnyOfSizeLimit) SetString(v string) {
+	s.Type = StringJaegerAnyOfSizeLimit
+	s.String = v
+}
+
+// GetString returns string and true boolean if JaegerAnyOfSizeLimit is string.
+func (s JaegerAnyOfSizeLimit) GetString() (v string, ok bool) {
+	if !s.IsString() {
+		return v, false
+	}
+	return s.String, true
+}
+
+// NewStringJaegerAnyOfSizeLimit returns new JaegerAnyOfSizeLimit from string.
+func NewStringJaegerAnyOfSizeLimit(v string) JaegerAnyOfSizeLimit {
+	var s JaegerAnyOfSizeLimit
+	s.SetString(v)
+	return s
+}
+
+// Ref: #/components/schemas/OneUUID
+type OneUUID struct {
+	Owner          string                `json:"owner"`
+	Version        int32                 `json:"version"`
+	SubscriptionID OneUUIDSubscriptionID `json:"subscription_id"`
+}
+
+// GetOwner returns the value of Owner.
+func (s OneUUID) GetOwner() string {
+	return s.Owner
+}
+
+// GetVersion returns the value of Version.
+func (s OneUUID) GetVersion() int32 {
+	return s.Version
+}
+
+// GetSubscriptionID returns the value of SubscriptionID.
+func (s OneUUID) GetSubscriptionID() OneUUIDSubscriptionID {
+	return s.SubscriptionID
+}
+
+// SetOwner sets the value of Owner.
+func (s *OneUUID) SetOwner(val string) {
+	s.Owner = val
+}
+
+// SetVersion sets the value of Version.
+func (s *OneUUID) SetVersion(val int32) {
+	s.Version = val
+}
+
+// SetSubscriptionID sets the value of SubscriptionID.
+func (s *OneUUID) SetSubscriptionID(val OneUUIDSubscriptionID) {
+	s.SubscriptionID = val
+}
+
+// OneUUIDSubscriptionID represents sum type.
+type OneUUIDSubscriptionID struct {
+	Type             OneUUIDSubscriptionIDType // switch on this field
+	SubscriptionUUID SubscriptionUUID
+}
+
+// OneUUIDSubscriptionIDType is oneOf type of OneUUIDSubscriptionID.
+type OneUUIDSubscriptionIDType string
+
+// Possible values for OneUUIDSubscriptionIDType.
+const (
+	SubscriptionUUIDOneUUIDSubscriptionID OneUUIDSubscriptionIDType = "SubscriptionUUID"
+)
+
+// IsSubscriptionUUID reports whether OneUUIDSubscriptionID is SubscriptionUUID.
+func (s OneUUIDSubscriptionID) IsSubscriptionUUID() bool {
+	return s.Type == SubscriptionUUIDOneUUIDSubscriptionID
+}
+
+// SetSubscriptionUUID sets OneUUIDSubscriptionID to SubscriptionUUID.
+func (s *OneUUIDSubscriptionID) SetSubscriptionUUID(v SubscriptionUUID) {
+	s.Type = SubscriptionUUIDOneUUIDSubscriptionID
+	s.SubscriptionUUID = v
+}
+
+// GetSubscriptionUUID returns SubscriptionUUID and true boolean if OneUUIDSubscriptionID is SubscriptionUUID.
+func (s OneUUIDSubscriptionID) GetSubscriptionUUID() (v SubscriptionUUID, ok bool) {
+	if !s.IsSubscriptionUUID() {
+		return v, false
+	}
+	return s.SubscriptionUUID, true
+}
+
+// NewSubscriptionUUIDOneUUIDSubscriptionID returns new OneUUIDSubscriptionID from SubscriptionUUID.
+func NewSubscriptionUUIDOneUUIDSubscriptionID(v SubscriptionUUID) OneUUIDSubscriptionID {
+	var s OneUUIDSubscriptionID
+	s.SetSubscriptionUUID(v)
+	return s
+}
+
+// Ref: #/components/schemas/SubscriptionUUID
+// SubscriptionUUID represents sum type.
+type SubscriptionUUID struct {
+	Type   SubscriptionUUIDType // switch on this field
+	UUIDv4 UUIDv4
+}
+
+// SubscriptionUUIDType is oneOf type of SubscriptionUUID.
+type SubscriptionUUIDType string
+
+// Possible values for SubscriptionUUIDType.
+const (
+	UUIDv4SubscriptionUUID SubscriptionUUIDType = "UUIDv4"
+)
+
+// IsUUIDv4 reports whether SubscriptionUUID is UUIDv4.
+func (s SubscriptionUUID) IsUUIDv4() bool { return s.Type == UUIDv4SubscriptionUUID }
+
+// SetUUIDv4 sets SubscriptionUUID to UUIDv4.
+func (s *SubscriptionUUID) SetUUIDv4(v UUIDv4) {
+	s.Type = UUIDv4SubscriptionUUID
+	s.UUIDv4 = v
+}
+
+// GetUUIDv4 returns UUIDv4 and true boolean if SubscriptionUUID is UUIDv4.
+func (s SubscriptionUUID) GetUUIDv4() (v UUIDv4, ok bool) {
+	if !s.IsUUIDv4() {
+		return v, false
+	}
+	return s.UUIDv4, true
+}
+
+// NewUUIDv4SubscriptionUUID returns new SubscriptionUUID from UUIDv4.
+func NewUUIDv4SubscriptionUUID(v UUIDv4) SubscriptionUUID {
+	var s SubscriptionUUID
+	s.SetUUIDv4(v)
+	return s
+}
+
+type UUIDv4 uuid.UUID
diff --git a/internal/integration/test_anyof/oas_server_gen.go b/internal/integration/test_anyof/oas_server_gen.go
new file mode 100644
index 00000000..253c1763
--- /dev/null
+++ b/internal/integration/test_anyof/oas_server_gen.go
@@ -0,0 +1,42 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"context"
+)
+
+// Handler handles operations described by OpenAPI v3 specification.
+type Handler interface {
+	// IntegerNumber implements integerNumber operation.
+	//
+	// GET /integerNumber
+	IntegerNumber(ctx context.Context) (IntegerNumber, error)
+	// JaegerAnyOf implements jaegerAnyOf operation.
+	//
+	// GET /jaegerAnyOf
+	JaegerAnyOf(ctx context.Context) (JaegerAnyOf, error)
+	// OneUUID implements oneUUID operation.
+	//
+	// GET /oneUUID
+	OneUUID(ctx context.Context) (OneUUID, error)
+}
+
+// Server implements http server based on OpenAPI v3 specification and
+// calls Handler to handle requests.
+type Server struct {
+	h Handler
+	baseServer
+}
+
+// NewServer creates new Server.
+func NewServer(h Handler, opts ...ServerOption) (*Server, error) {
+	s, err := newServerConfig(opts...).baseServer()
+	if err != nil {
+		return nil, err
+	}
+	return &Server{
+		h:          h,
+		baseServer: s,
+	}, nil
+}
diff --git a/internal/integration/test_anyof/oas_test_examples_gen_test.go b/internal/integration/test_anyof/oas_test_examples_gen_test.go
new file mode 100644
index 00000000..8051c154
--- /dev/null
+++ b/internal/integration/test_anyof/oas_test_examples_gen_test.go
@@ -0,0 +1,109 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"github.com/go-faster/jx"
+
+	std "encoding/json"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestAnyOfIntegerNumberString_EncodeDecode(t *testing.T) {
+	var typ AnyOfIntegerNumberString
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 AnyOfIntegerNumberString
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestIntegerNumber_EncodeDecode(t *testing.T) {
+	var typ IntegerNumber
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 IntegerNumber
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestJaegerAnyOf_EncodeDecode(t *testing.T) {
+	var typ JaegerAnyOf
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 JaegerAnyOf
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestJaegerAnyOfSizeLimit_EncodeDecode(t *testing.T) {
+	var typ JaegerAnyOfSizeLimit
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 JaegerAnyOfSizeLimit
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestOneUUID_EncodeDecode(t *testing.T) {
+	var typ OneUUID
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 OneUUID
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestOneUUIDSubscriptionID_EncodeDecode(t *testing.T) {
+	var typ OneUUIDSubscriptionID
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 OneUUIDSubscriptionID
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestSubscriptionUUID_EncodeDecode(t *testing.T) {
+	var typ SubscriptionUUID
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 SubscriptionUUID
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
+func TestUUIDv4_EncodeDecode(t *testing.T) {
+	var typ UUIDv4
+	typ.SetFake()
+
+	e := jx.Encoder{}
+	typ.Encode(&e)
+	data := e.Bytes()
+	require.True(t, std.Valid(data), "Encoded: %s", data)
+
+	var typ2 UUIDv4
+	require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
+}
diff --git a/internal/integration/test_anyof/oas_unimplemented_gen.go b/internal/integration/test_anyof/oas_unimplemented_gen.go
new file mode 100644
index 00000000..403d78d1
--- /dev/null
+++ b/internal/integration/test_anyof/oas_unimplemented_gen.go
@@ -0,0 +1,35 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"context"
+
+	ht "github.com/ogen-go/ogen/http"
+)
+
+// UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.
+type UnimplementedHandler struct{}
+
+var _ Handler = UnimplementedHandler{}
+
+// IntegerNumber implements integerNumber operation.
+//
+// GET /integerNumber
+func (UnimplementedHandler) IntegerNumber(ctx context.Context) (r IntegerNumber, _ error) {
+	return r, ht.ErrNotImplemented
+}
+
+// JaegerAnyOf implements jaegerAnyOf operation.
+//
+// GET /jaegerAnyOf
+func (UnimplementedHandler) JaegerAnyOf(ctx context.Context) (r JaegerAnyOf, _ error) {
+	return r, ht.ErrNotImplemented
+}
+
+// OneUUID implements oneUUID operation.
+//
+// GET /oneUUID
+func (UnimplementedHandler) OneUUID(ctx context.Context) (r OneUUID, _ error) {
+	return r, ht.ErrNotImplemented
+}
diff --git a/internal/integration/test_anyof/oas_validators_gen.go b/internal/integration/test_anyof/oas_validators_gen.go
new file mode 100644
index 00000000..286cbc5c
--- /dev/null
+++ b/internal/integration/test_anyof/oas_validators_gen.go
@@ -0,0 +1,111 @@
+// Code generated by ogen, DO NOT EDIT.
+
+package api
+
+import (
+	"github.com/go-faster/errors"
+
+	"github.com/ogen-go/ogen/validate"
+)
+
+func (s AnyOfIntegerNumberString) Validate() error {
+	switch s.Type {
+	case IntAnyOfIntegerNumberString:
+		return nil // no validation needed
+	case Float64AnyOfIntegerNumberString:
+		if err := (validate.Float{}).Validate(float64(s.Float64)); err != nil {
+			return errors.Wrap(err, "float")
+		}
+		return nil
+	case StringAnyOfIntegerNumberString:
+		return nil // no validation needed
+	default:
+		return errors.Errorf("invalid type %q", s.Type)
+	}
+}
+
+func (s IntegerNumber) Validate() error {
+	var failures []validate.FieldError
+	if err := func() error {
+		if err := s.Plain.Validate(); err != nil {
+			return err
+		}
+		return nil
+	}(); err != nil {
+		failures = append(failures, validate.FieldError{
+			Name:  "plain",
+			Error: err,
+		})
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+	return nil
+}
+func (s JaegerAnyOf) Validate() error {
+	var failures []validate.FieldError
+	if err := func() error {
+		if err := s.SizeLimit.Validate(); err != nil {
+			return err
+		}
+		return nil
+	}(); err != nil {
+		failures = append(failures, validate.FieldError{
+			Name:  "sizeLimit",
+			Error: err,
+		})
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+	return nil
+}
+func (s JaegerAnyOfSizeLimit) Validate() error {
+	switch s.Type {
+	case IntJaegerAnyOfSizeLimit:
+		return nil // no validation needed
+	case StringJaegerAnyOfSizeLimit:
+		if err := (validate.String{
+			MinLength:    0,
+			MinLengthSet: false,
+			MaxLength:    0,
+			MaxLengthSet: false,
+			Email:        false,
+			Hostname:     false,
+			Regex:        regexMap["^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"],
+		}).Validate(string(s.String)); err != nil {
+			return errors.Wrap(err, "string")
+		}
+		return nil
+	default:
+		return errors.Errorf("invalid type %q", s.Type)
+	}
+}
+
+func (s OneUUID) Validate() error {
+	var failures []validate.FieldError
+	if err := func() error {
+		if err := (validate.Int{
+			MinSet:        true,
+			Min:           1,
+			MaxSet:        false,
+			Max:           0,
+			MinExclusive:  false,
+			MaxExclusive:  false,
+			MultipleOfSet: false,
+			MultipleOf:    0,
+		}).Validate(int64(s.Version)); err != nil {
+			return errors.Wrap(err, "int")
+		}
+		return nil
+	}(); err != nil {
+		failures = append(failures, validate.FieldError{
+			Name:  "version",
+			Error: err,
+		})
+	}
+	if len(failures) > 0 {
+		return &validate.Error{Fields: failures}
+	}
+	return nil
+}
diff --git a/internal/integration/validate_test.go b/internal/integration/validate_test.go
index 3730db27..152c9277 100644
--- a/internal/integration/validate_test.go
+++ b/internal/integration/validate_test.go
@@ -119,38 +119,6 @@ func TestValidateMap(t *testing.T) {
 	}
 }
 
-func TestValidateSum(t *testing.T) {
-	for i, tc := range []struct {
-		Input string
-		Error bool
-	}{
-		{
-			`{"medium": "text", "sizeLimit": "aboba"}`,
-			true,
-		},
-		{
-			`{"medium": "text", "sizeLimit": 10}`,
-			false,
-		},
-		{
-			`{"medium": "text", "sizeLimit": "10"}`,
-			false,
-		},
-	} {
-		tc := tc
-		t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
-			m := api.AnyOfTest{}
-			require.NoError(t, m.Decode(jx.DecodeStr(tc.Input)))
-
-			checker := require.NoError
-			if tc.Error {
-				checker = require.Error
-			}
-			checker(t, m.Validate())
-		})
-	}
-}
-
 func TestValidateFloat(t *testing.T) {
 	for i, tc := range []struct {
 		Input string