diff --git a/CHANGELOG.md b/CHANGELOG.md index 139211ac7..3e8aa517f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - **Feature:** Add waiter for deletion of organization - `iaas`: [v0.29.1](services/iaas/CHANGELOG.md#v0291) - **Bugfix:** Parsing oneOf with enum and string value +- `stackitmarketplace`: [v1.7.1](services/stackitmarketplace/CHANGELOG.md#v171) + - **Bugfix:** oneOfs with enums and strings can not be parsed ## Release (2025-08-13) - `scf`: diff --git a/services/iaasalpha/model_create_network_ipv4.go b/services/iaasalpha/model_create_network_ipv4.go index 2296bd4bc..ff5471a30 100644 --- a/services/iaasalpha/model_create_network_ipv4.go +++ b/services/iaasalpha/model_create_network_ipv4.go @@ -39,30 +39,29 @@ func CreateNetworkIPv4WithPrefixLengthAsCreateNetworkIPv4(v *CreateNetworkIPv4Wi func (dst *CreateNetworkIPv4) UnmarshalJSON(data []byte) error { var err error match := 0 + // Workaround until upstream issue is fixed: + // https://github.com/OpenAPITools/openapi-generator/issues/21751 + // Tracking issue on our side: https://jira.schwarz/browse/STACKITSDK-226 // try to unmarshal data into CreateNetworkIPv4WithPrefix - err = json.Unmarshal(data, &dst.CreateNetworkIPv4WithPrefix) + dstCreateNetworkIPv41 := &CreateNetworkIPv4{} + err = json.Unmarshal(data, &dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix) if err == nil { - jsonCreateNetworkIPv4WithPrefix, _ := json.Marshal(dst.CreateNetworkIPv4WithPrefix) - if string(jsonCreateNetworkIPv4WithPrefix) == "{}" { // empty struct - dst.CreateNetworkIPv4WithPrefix = nil - } else { + jsonCreateNetworkIPv4WithPrefix, _ := json.Marshal(&dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix) + if string(jsonCreateNetworkIPv4WithPrefix) != "{}" { // empty struct + dst.CreateNetworkIPv4WithPrefix = dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix match++ } - } else { - dst.CreateNetworkIPv4WithPrefix = nil } // try to unmarshal data into CreateNetworkIPv4WithPrefixLength - err = json.Unmarshal(data, &dst.CreateNetworkIPv4WithPrefixLength) + dstCreateNetworkIPv42 := &CreateNetworkIPv4{} + err = json.Unmarshal(data, &dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength) if err == nil { - jsonCreateNetworkIPv4WithPrefixLength, _ := json.Marshal(dst.CreateNetworkIPv4WithPrefixLength) - if string(jsonCreateNetworkIPv4WithPrefixLength) == "{}" { // empty struct - dst.CreateNetworkIPv4WithPrefixLength = nil - } else { + jsonCreateNetworkIPv4WithPrefixLength, _ := json.Marshal(&dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength) + if string(jsonCreateNetworkIPv4WithPrefixLength) != "{}" { // empty struct + dst.CreateNetworkIPv4WithPrefixLength = dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength match++ } - } else { - dst.CreateNetworkIPv4WithPrefixLength = nil } if match > 1 { // more than 1 match diff --git a/services/iaasalpha/model_create_network_ipv4_test.go b/services/iaasalpha/model_create_network_ipv4_test.go index 7b8f0d01a..d5f368bd8 100644 --- a/services/iaasalpha/model_create_network_ipv4_test.go +++ b/services/iaasalpha/model_create_network_ipv4_test.go @@ -9,3 +9,35 @@ API version: 2alpha1 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package iaasalpha + +import ( + "testing" +) + +// isOneOf + +func TestCreateNetworkIPv4_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := &CreateNetworkIPv4{} + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + marshalJson, err := v.MarshalJSON() + if err != nil { + t.Fatalf("failed marshalling CreateNetworkIPv4: %v", err) + } + if string(marshalJson) != string(tt.args.src) { + t.Fatalf("wanted %s, get %s", tt.args.src, marshalJson) + } + }) + } +} diff --git a/services/iaasalpha/model_create_network_ipv6.go b/services/iaasalpha/model_create_network_ipv6.go index bd95d9ee8..707624ef9 100644 --- a/services/iaasalpha/model_create_network_ipv6.go +++ b/services/iaasalpha/model_create_network_ipv6.go @@ -39,30 +39,29 @@ func CreateNetworkIPv6WithPrefixLengthAsCreateNetworkIPv6(v *CreateNetworkIPv6Wi func (dst *CreateNetworkIPv6) UnmarshalJSON(data []byte) error { var err error match := 0 + // Workaround until upstream issue is fixed: + // https://github.com/OpenAPITools/openapi-generator/issues/21751 + // Tracking issue on our side: https://jira.schwarz/browse/STACKITSDK-226 // try to unmarshal data into CreateNetworkIPv6WithPrefix - err = json.Unmarshal(data, &dst.CreateNetworkIPv6WithPrefix) + dstCreateNetworkIPv61 := &CreateNetworkIPv6{} + err = json.Unmarshal(data, &dstCreateNetworkIPv61.CreateNetworkIPv6WithPrefix) if err == nil { - jsonCreateNetworkIPv6WithPrefix, _ := json.Marshal(dst.CreateNetworkIPv6WithPrefix) - if string(jsonCreateNetworkIPv6WithPrefix) == "{}" { // empty struct - dst.CreateNetworkIPv6WithPrefix = nil - } else { + jsonCreateNetworkIPv6WithPrefix, _ := json.Marshal(&dstCreateNetworkIPv61.CreateNetworkIPv6WithPrefix) + if string(jsonCreateNetworkIPv6WithPrefix) != "{}" { // empty struct + dst.CreateNetworkIPv6WithPrefix = dstCreateNetworkIPv61.CreateNetworkIPv6WithPrefix match++ } - } else { - dst.CreateNetworkIPv6WithPrefix = nil } // try to unmarshal data into CreateNetworkIPv6WithPrefixLength - err = json.Unmarshal(data, &dst.CreateNetworkIPv6WithPrefixLength) + dstCreateNetworkIPv62 := &CreateNetworkIPv6{} + err = json.Unmarshal(data, &dstCreateNetworkIPv62.CreateNetworkIPv6WithPrefixLength) if err == nil { - jsonCreateNetworkIPv6WithPrefixLength, _ := json.Marshal(dst.CreateNetworkIPv6WithPrefixLength) - if string(jsonCreateNetworkIPv6WithPrefixLength) == "{}" { // empty struct - dst.CreateNetworkIPv6WithPrefixLength = nil - } else { + jsonCreateNetworkIPv6WithPrefixLength, _ := json.Marshal(&dstCreateNetworkIPv62.CreateNetworkIPv6WithPrefixLength) + if string(jsonCreateNetworkIPv6WithPrefixLength) != "{}" { // empty struct + dst.CreateNetworkIPv6WithPrefixLength = dstCreateNetworkIPv62.CreateNetworkIPv6WithPrefixLength match++ } - } else { - dst.CreateNetworkIPv6WithPrefixLength = nil } if match > 1 { // more than 1 match diff --git a/services/iaasalpha/model_create_network_ipv6_test.go b/services/iaasalpha/model_create_network_ipv6_test.go index 7b8f0d01a..5d8a1708d 100644 --- a/services/iaasalpha/model_create_network_ipv6_test.go +++ b/services/iaasalpha/model_create_network_ipv6_test.go @@ -9,3 +9,35 @@ API version: 2alpha1 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package iaasalpha + +import ( + "testing" +) + +// isOneOf + +func TestCreateNetworkIPv6_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := &CreateNetworkIPv6{} + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + marshalJson, err := v.MarshalJSON() + if err != nil { + t.Fatalf("failed marshalling CreateNetworkIPv6: %v", err) + } + if string(marshalJson) != string(tt.args.src) { + t.Fatalf("wanted %s, get %s", tt.args.src, marshalJson) + } + }) + } +} diff --git a/services/stackitmarketplace/CHANGELOG.md b/services/stackitmarketplace/CHANGELOG.md index 8b5427503..16e4df118 100644 --- a/services/stackitmarketplace/CHANGELOG.md +++ b/services/stackitmarketplace/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.7.1 +- **Bugfix:** oneOfs with enums and strings can not be parsed + ## v1.7.0 - **Breaking Change:** Update `InquiryFormType` enums diff --git a/services/stackitmarketplace/VERSION b/services/stackitmarketplace/VERSION index b7c8e167d..6c4fc2034 100644 --- a/services/stackitmarketplace/VERSION +++ b/services/stackitmarketplace/VERSION @@ -1 +1 @@ -v1.7.0 \ No newline at end of file +v1.7.1 \ No newline at end of file diff --git a/services/stackitmarketplace/model_inquiries_create_inquiry_payload.go b/services/stackitmarketplace/model_inquiries_create_inquiry_payload.go index 0aa1c3ea3..5f83118f8 100644 --- a/services/stackitmarketplace/model_inquiries_create_inquiry_payload.go +++ b/services/stackitmarketplace/model_inquiries_create_inquiry_payload.go @@ -55,56 +55,51 @@ func SuggestProductAsInquiriesCreateInquiryPayload(v *SuggestProduct) InquiriesC func (dst *InquiriesCreateInquiryPayload) UnmarshalJSON(data []byte) error { var err error match := 0 - // try to unmarshal data into BecomeVendor - err = json.Unmarshal(data, &dst.BecomeVendor) + // Workaround until upstream issue is fixed: + // https://github.com/OpenAPITools/openapi-generator/issues/21751 + // Tracking issue on our side: https://jira.schwarz/browse/STACKITSDK-226 + // try to unmarshal data into SuggestProduct + dstInquiriesCreateInquiryPayload1 := &InquiriesCreateInquiryPayload{} + err = json.Unmarshal(data, &dstInquiriesCreateInquiryPayload1.SuggestProduct) if err == nil { - jsonBecomeVendor, _ := json.Marshal(dst.BecomeVendor) - if string(jsonBecomeVendor) == "{}" { // empty struct - dst.BecomeVendor = nil - } else { + jsonSuggestProduct, _ := json.Marshal(&dstInquiriesCreateInquiryPayload1.SuggestProduct) + if string(jsonSuggestProduct) != "{}" { // empty struct + dst.SuggestProduct = dstInquiriesCreateInquiryPayload1.SuggestProduct match++ } - } else { - dst.BecomeVendor = nil } // try to unmarshal data into ContactSales - err = json.Unmarshal(data, &dst.ContactSales) + dstInquiriesCreateInquiryPayload2 := &InquiriesCreateInquiryPayload{} + err = json.Unmarshal(data, &dstInquiriesCreateInquiryPayload2.ContactSales) if err == nil { - jsonContactSales, _ := json.Marshal(dst.ContactSales) - if string(jsonContactSales) == "{}" { // empty struct - dst.ContactSales = nil - } else { + jsonContactSales, _ := json.Marshal(&dstInquiriesCreateInquiryPayload2.ContactSales) + if string(jsonContactSales) != "{}" { // empty struct + dst.ContactSales = dstInquiriesCreateInquiryPayload2.ContactSales match++ } - } else { - dst.ContactSales = nil } - // try to unmarshal data into RegisterTesting - err = json.Unmarshal(data, &dst.RegisterTesting) + // try to unmarshal data into BecomeVendor + dstInquiriesCreateInquiryPayload3 := &InquiriesCreateInquiryPayload{} + err = json.Unmarshal(data, &dstInquiriesCreateInquiryPayload3.BecomeVendor) if err == nil { - jsonRegisterTesting, _ := json.Marshal(dst.RegisterTesting) - if string(jsonRegisterTesting) == "{}" { // empty struct - dst.RegisterTesting = nil - } else { + jsonBecomeVendor, _ := json.Marshal(&dstInquiriesCreateInquiryPayload3.BecomeVendor) + if string(jsonBecomeVendor) != "{}" { // empty struct + dst.BecomeVendor = dstInquiriesCreateInquiryPayload3.BecomeVendor match++ } - } else { - dst.RegisterTesting = nil } - // try to unmarshal data into SuggestProduct - err = json.Unmarshal(data, &dst.SuggestProduct) + // try to unmarshal data into RegisterTesting + dstInquiriesCreateInquiryPayload4 := &InquiriesCreateInquiryPayload{} + err = json.Unmarshal(data, &dstInquiriesCreateInquiryPayload4.RegisterTesting) if err == nil { - jsonSuggestProduct, _ := json.Marshal(dst.SuggestProduct) - if string(jsonSuggestProduct) == "{}" { // empty struct - dst.SuggestProduct = nil - } else { + jsonRegisterTesting, _ := json.Marshal(&dstInquiriesCreateInquiryPayload4.RegisterTesting) + if string(jsonRegisterTesting) != "{}" { // empty struct + dst.RegisterTesting = dstInquiriesCreateInquiryPayload4.RegisterTesting match++ } - } else { - dst.SuggestProduct = nil } if match > 1 { // more than 1 match diff --git a/services/stackitmarketplace/model_inquiries_create_inquiry_payload_test.go b/services/stackitmarketplace/model_inquiries_create_inquiry_payload_test.go index 8d52b2c3c..7d2cddb4d 100644 --- a/services/stackitmarketplace/model_inquiries_create_inquiry_payload_test.go +++ b/services/stackitmarketplace/model_inquiries_create_inquiry_payload_test.go @@ -9,3 +9,35 @@ API version: 1 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package stackitmarketplace + +import ( + "testing" +) + +// isOneOf + +func TestInquiriesCreateInquiryPayload_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := &InquiriesCreateInquiryPayload{} + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + marshalJson, err := v.MarshalJSON() + if err != nil { + t.Fatalf("failed marshalling InquiriesCreateInquiryPayload: %v", err) + } + if string(marshalJson) != string(tt.args.src) { + t.Fatalf("wanted %s, get %s", tt.args.src, marshalJson) + } + }) + } +}