Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the generated go file contains a field in a struct that is not in the definition #63

Open
sumia01 opened this issue Nov 29, 2022 · 0 comments

Comments

@sumia01
Copy link

sumia01 commented Nov 29, 2022

Description

I'm trying to generate structs for go from the schema provided by Tableau (link below), but I'm getting bad results for this XSD version. For comparison, I'm using c# sourcecode generated with xsd (from mono).

The result structures are different than expected.

Steps to reproduce the issue:

  1. get xsd file from https://help.tableau.com/samples/en-us/rest_api/ts-api_3_17.xsd or use https://gist.github.com/sumia01/f15ee5589f4a020b63bd0e016ebaf5b6#file-ts-api_3_17-xsd
  2. generate output file(s)
xgen -i ts-api_3_17.xsd -o 3.17/schema.go -l Go
  1. compare with reference generated with xsd from Mono (https://www.mono-project.com/docs/getting-started/install). I uploaded it here: https://gist.github.com/sumia01/f551985805e2e84c9a83cee1e9ef59f8

Describe the results you received:
In the generated result, there is a Status string in the SiteType struct.
https://gist.github.com/sumia01/f15ee5589f4a020b63bd0e016ebaf5b6#file-schema-go-L1511

But it shouldn't be there, see the c# reference:
https://gist.github.com/sumia01/f551985805e2e84c9a83cee1e9ef59f8#file-tableau_3_17-cs-L2960

And here is the type definition part from the original xsd, I can't find any reference for status here:
https://gist.github.com/sumia01/f15ee5589f4a020b63bd0e016ebaf5b6#file-ts-api_3_17-xsd-L1797

One more strange behaviour found here. If I comment the following part from xsd (https://gist.github.com/sumia01/f15ee5589f4a020b63bd0e016ebaf5b6#file-ts-api_3_17-xsd-L1418)

            <!-- <xs:element name="status" minOccurs="1" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Failed" />
                        <xs:enumeration value="Success" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element> -->

then it's not generated into the SiteType struct. But I don't understand the connection here.

Describe the results you expected:

I'd like to get the same result as in the c# file

Output of go version:

go version go1.19.3 darwin/arm64

xgen version or commit ID:

xgen version: 0.1.0
commit hash: 45dd37dc6afb5afb6ffd28b6e81b760ec6f7e038

Environment details (OS, physical, etc.):

Darwin Sumi-MacBook-Pro.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant