question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] [GO] can't generate codes with xml tag

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What’s the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What’s the actual output vs expected output?
  • [] [Optional] Bounty to sponsor the fix (example)
Description

even though i use withXml=true, can’t generate codes with xml tag .

actual:

type ResponseSample struct {

	StatusCode int64 `json:"status_code"`

	Message string `json:"message"`
}

expected(like this):

type ResponseSample struct {

        XMLName xml.Name `xml:"response"`

	StatusCode int64 `xml:"status_code"`

	Message string `xml:"message"`
}

My Go version: go version go1.12.13 darwin/amd64

openapi-generator version

v4.1.2

OpenAPI declaration file content or url
ResponseSample:
      type: object
      properties:
        status_code:
          type: integer
          format: int64
          example: 0
        message:
          type: string
          example: 'success'
      xml:
        name: response
      required:
        - status_code
        - message
Command line used for generation
docker run -v ${PWD}:/local openapitools/openapi-generator-cli:v4.1.2 generate \
  -i /local/openapi/openapi.yaml \
  -g go-server \
  -p withXml=true \
  --output /local/${GENERATE_PATH}
Steps to reproduce

please paste the above yaml, then docker run.

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/490

Suggest a fix

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wing328commented, Dec 12, 2019
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/go -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstore,withXml=true,withGoCodegenComment=true $@"

That’s what we use in the Go Petstore (xml) shell script so it looks to me the following is correct: --additional-properties withXml=true

0reactions
wing328commented, Dec 13, 2019

If it’s still an issue, please ping me via Slack.

Closing this for the time being.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to parse xml in GO with : in tags - Stack Overflow
Show activity on this post. I find that if tags in XML file have : in them the unmarshal code in Go does...
Read more >
Can't open file that contains custom XML elements which are ...
Describes an issue in which a particular custom XML markup implementation is removed in Word 2007, Word 2010 and Word 2013.
Read more >
Question: How resolve mal-formed xml error - Boomi Community
I can't get beyond an mal-formed xml error from a Map shpe to a cache shape. Test execution of SF_FX_to_SQL_FFXIntegration_Todd completed ...
Read more >
beevik/etree: parse and generate XML easily in go - GitHub
Represents XML documents as trees of elements for easy traversal. Imports, serializes, modifies or creates XML documents from scratch. Writes and reads XML...
Read more >
XML Files: What They Are & How to Open Them - HubSpot Blog
An XML file contains XML code and ends with the file extension ".xml". ... To create custom tags, a developer writes a Document...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found