From bdfbb32cddc1fcbaefdb16da31fd58b0729e77f2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 8 Sep 2025 16:45:46 +0800 Subject: [PATCH] Improve Go client tests (#21919) * test withXml option * fix path * update go code (withXml: true) * test one more go client --- .github/workflows/samples-go-client.yaml | 3 +++ bin/configs/go-petstore-withXml.yaml | 2 +- .../petstore/go-petstore-withXml/model_category.go | 4 ++-- .../client/petstore/go-petstore-withXml/model_pet.go | 12 ++++++------ .../client/petstore/go-petstore-withXml/model_tag.go | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/samples-go-client.yaml b/.github/workflows/samples-go-client.yaml index d4f15e85bf1..5fcbf08d63f 100644 --- a/.github/workflows/samples-go-client.yaml +++ b/.github/workflows/samples-go-client.yaml @@ -5,10 +5,12 @@ on: paths: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**' - 'samples/openapi3/client/petstore/go-petstore-withXml/**' + - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/** pull_request: paths: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**' - 'samples/openapi3/client/petstore/go-petstore-withXml/**' + - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/** jobs: build: @@ -20,6 +22,7 @@ jobs: sample: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/' - 'samples/openapi3/client/petstore/go-petstore-withXml/' + - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/ steps: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 diff --git a/bin/configs/go-petstore-withXml.yaml b/bin/configs/go-petstore-withXml.yaml index 26eb00c1368..de4b48541b3 100644 --- a/bin/configs/go-petstore-withXml.yaml +++ b/bin/configs/go-petstore-withXml.yaml @@ -6,4 +6,4 @@ additionalProperties: enumClassPrefix: "true" packageName: petstore disallowAdditionalPropertiesIfNotPresent: false - withXml: false + withXml: true diff --git a/samples/openapi3/client/petstore/go-petstore-withXml/model_category.go b/samples/openapi3/client/petstore/go-petstore-withXml/model_category.go index 74573760b1a..26b2c296d1c 100644 --- a/samples/openapi3/client/petstore/go-petstore-withXml/model_category.go +++ b/samples/openapi3/client/petstore/go-petstore-withXml/model_category.go @@ -19,8 +19,8 @@ var _ MappedNullable = &Category{} // Category A category for a pet type Category struct { - Id *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty" validate:"regexp=^[a-zA-Z0-9]+[a-zA-Z0-9\\\\.\\\\-_]*[a-zA-Z0-9]+$"` + Id *int64 `json:"id,omitempty" xml:"id"` + Name *string `json:"name,omitempty" xml:"name" validate:"regexp=^[a-zA-Z0-9]+[a-zA-Z0-9\\\\.\\\\-_]*[a-zA-Z0-9]+$"` AdditionalProperties map[string]interface{} } diff --git a/samples/openapi3/client/petstore/go-petstore-withXml/model_pet.go b/samples/openapi3/client/petstore/go-petstore-withXml/model_pet.go index 6497a1a1e44..420e38cb656 100644 --- a/samples/openapi3/client/petstore/go-petstore-withXml/model_pet.go +++ b/samples/openapi3/client/petstore/go-petstore-withXml/model_pet.go @@ -20,14 +20,14 @@ var _ MappedNullable = &Pet{} // Pet A pet for sale in the pet store type Pet struct { - Id *int64 `json:"id,omitempty"` - Category *Category `json:"category,omitempty"` - Name string `json:"name"` - PhotoUrls []string `json:"photoUrls"` - Tags []Tag `json:"tags,omitempty"` + Id *int64 `json:"id,omitempty" xml:"id"` + Category *Category `json:"category,omitempty" xml:"category"` + Name string `json:"name" xml:"name"` + PhotoUrls []string `json:"photoUrls" xml:"photoUrls>photoUrl"` + Tags []Tag `json:"tags,omitempty" xml:"tags>tag"` // pet status in the store // Deprecated - Status *string `json:"status,omitempty"` + Status *string `json:"status,omitempty" xml:"status"` AdditionalProperties map[string]interface{} } diff --git a/samples/openapi3/client/petstore/go-petstore-withXml/model_tag.go b/samples/openapi3/client/petstore/go-petstore-withXml/model_tag.go index 431aff68390..52cc67cf0e4 100644 --- a/samples/openapi3/client/petstore/go-petstore-withXml/model_tag.go +++ b/samples/openapi3/client/petstore/go-petstore-withXml/model_tag.go @@ -19,8 +19,8 @@ var _ MappedNullable = &Tag{} // Tag A tag for a pet type Tag struct { - Id *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` + Id *int64 `json:"id,omitempty" xml:"id"` + Name *string `json:"name,omitempty" xml:"name"` AdditionalProperties map[string]interface{} }