Skip to content

Conversation

@sruehl
Copy link
Contributor

@sruehl sruehl commented Sep 4, 2025

Resolves #21898

This PR enables wrapped and xml name support in Golang

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

@wing328 low hanging fruit with a easy fix and big impact. Ready to review and to be merged.

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @lwj5 ready for review

@wing328
Copy link
Member

wing328 commented Sep 4, 2025

@sruehl thanks for the PR

what about updating modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml with some test schemas to cover this change moving forward?

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

the test are already contained in pestore.yaml, or do you have something specific in mind?
image
(Edit: source

)

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

I added two array types for wrapped to that file you mentioned

@sruehl sruehl force-pushed the feat/golang_xml_wrapped_support branch from 3a14e19 to 8426f4b Compare September 4, 2025 15:36
@wing328
Copy link
Member

wing328 commented Sep 4, 2025

@wing328
Copy link
Member

wing328 commented Sep 4, 2025

the test are already contained in pestore.yaml, or do you have something specific in mind?

that's the general one. Go petstore samples use a different one

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

https://github.com/OpenAPITools/openapi-generator/actions/runs/17469134703/job/49613034587?pr=21899

please commit the new files as well

whoops, will do, wasn't aware that that ends up in a sample, sorry :(

@sruehl
Copy link
Contributor Author

sruehl commented Sep 4, 2025

@wing328 samples updated

@wing328
Copy link
Member

wing328 commented Sep 4, 2025

i did a test locally with the withXml option enabled (set to true) and got the following in one of the models:

--- a/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
+++ b/samples/openapi3/client/petstore/go/go-petstore/model_pet.go
@@ -20,14 +20,14 @@ var _ MappedNullable = &Pet{}

 // Pet struct for Pet
 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{}
 }

does the change (e.g. xml:"photoUrls>photoUrl") look good to you?

@wing328
Copy link
Member

wing328 commented Sep 4, 2025

let's give it a try

i'll add some tests for the withXml option later

thanks for the contribution

@wing328 wing328 merged commit 08733aa into OpenAPITools:master Sep 4, 2025
15 checks passed
@sruehl
Copy link
Contributor Author

sruehl commented Sep 5, 2025

does the change (e.g. xml:"photoUrls>photoUrl") look good to you?

yes I does

@wing328
Copy link
Member

wing328 commented Sep 6, 2025

fyi. merged #21913 to add tests for the withXml option

@sruehl
Copy link
Contributor Author

sruehl commented Sep 8, 2025

thx, I left some comments there

Goopher pushed a commit to Goopher/openapi-generator that referenced this pull request Sep 9, 2025
* feat(golang): support for wrapped and xml name

* test(golang): add two test cases for wrapped

- with name
- without name

* chore(golang): update samples
@sruehl sruehl mentioned this pull request Nov 3, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [Golang] xml wrapped and name is ignored

2 participants