diff --git a/examples/anyof-allof-oneof/anyofallofoneof.gen.go b/examples/anyof-allof-oneof/anyofallofoneof.gen.go index 99b8616833..554a2df0fc 100644 --- a/examples/anyof-allof-oneof/anyofallofoneof.gen.go +++ b/examples/anyof-allof-oneof/anyofallofoneof.gen.go @@ -10,9 +10,7 @@ import ( ) // Client defines model for Client. -type Client struct { - Name string `json:"name"` -} +type Client = OverlayClient // ClientAndMaybeIdentity defines model for ClientAndMaybeIdentity. type ClientAndMaybeIdentity struct { @@ -25,10 +23,7 @@ type ClientOrIdentity struct { } // ClientWithId defines model for ClientWithId. -type ClientWithId struct { - Id int `json:"id"` - Name string `json:"name"` -} +type ClientWithId = OverlayClient // Identity defines model for Identity. type Identity struct { diff --git a/examples/anyof-allof-oneof/cfg.yaml b/examples/anyof-allof-oneof/cfg.yaml index 6db7862270..40e4641d24 100644 --- a/examples/anyof-allof-oneof/cfg.yaml +++ b/examples/anyof-allof-oneof/cfg.yaml @@ -6,3 +6,5 @@ generate: output-options: # NOTE that this is only required for the `Unreferenced` type skip-prune: true + overlay: + path: overlay.yaml diff --git a/examples/anyof-allof-oneof/overlay.yaml b/examples/anyof-allof-oneof/overlay.yaml new file mode 100644 index 0000000000..9f8cf0771b --- /dev/null +++ b/examples/anyof-allof-oneof/overlay.yaml @@ -0,0 +1,11 @@ +overlay: 1.0.0 +info: + title: "Example to indicate how to use the OpenAPI Overlay specification (https://github.com/OAI/Overlay-Specification)" + version: 1.0.0 +actions: + - target: $.components.schemas.Client + update: + x-go-type: OverlayClient + - target: $.components.schemas.ClientWithId + update: + x-go-type: OverlayClientWithId diff --git a/examples/anyof-allof-oneof/overlays.go b/examples/anyof-allof-oneof/overlays.go new file mode 100644 index 0000000000..338d636671 --- /dev/null +++ b/examples/anyof-allof-oneof/overlays.go @@ -0,0 +1,12 @@ +package anyofallofoneof + +// OverlayClient defines model for OverlayClient. +type OverlayClient struct { + Name string `json:"name"` +} + +// OverlayClientWithId defines model for OverlayClientWithId. +type OverlayClientWithId struct { + Id int `json:"id"` + Name string `json:"name"` +} diff --git a/examples/anyof-allof-oneof/overlays_test.go b/examples/anyof-allof-oneof/overlays_test.go new file mode 100644 index 0000000000..0c7148faf1 --- /dev/null +++ b/examples/anyof-allof-oneof/overlays_test.go @@ -0,0 +1,17 @@ +package anyofallofoneof + +import "testing" + +func TestAllOfOverlay(t *testing.T) { + var inner any = Client{} + _, ok := inner.(OverlayClient) + if !ok { + t.Errorf("expected Client to be of type OverlayClient") + } + + var outer any = ClientWithId{} + _, ok = outer.(OverlayClientWithId) + if !ok { + t.Errorf("expected ClientWithId to be of type OverlayClientWithId") + } +}