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

'-' within schema causes invalid stuct name to be created '-' can't be within struct name #47

Open
nlacey opened this issue Dec 1, 2017 · 13 comments · May be fixed by #142
Open

'-' within schema causes invalid stuct name to be created '-' can't be within struct name #47

nlacey opened this issue Dec 1, 2017 · 13 comments · May be fixed by #142

Comments

@nlacey
Copy link
Contributor

nlacey commented Dec 1, 2017

injested wsdl files with - in there field name,
In order to get the program to create the go code,
I needed to go through encoder.go and add string.Replace on '-' with "" one the various tag fields

@fiorix
Copy link
Owner

fiorix commented Dec 5, 2017

Can you give an example?

@nlacey
Copy link
Contributor Author

nlacey commented Dec 21, 2017

I'm sorry for how long this took me.
If you replace nick-name with nickname, in the included file, the problem will work.

problem_example_wsdl.txt

I messed around wtih wsdlgo/encoder.go so struct names wouldn't include the '-' character, which allowed your code to run.

@fiorix
Copy link
Owner

fiorix commented Dec 22, 2017

Alright, so this is mainly about removing - from function names and variables but keeping them in the XML tags? PR?

@nlacey
Copy link
Contributor Author

nlacey commented Dec 26, 2017

correct, attached export.go that worked with example file,
encoder.txt

created cleanString function (currently removes '-' and ' ')
Not sure how complete it is, but it was able to convert the previously attached file thanks!

@fiorix
Copy link
Owner

fiorix commented Dec 29, 2017

Yeah we need to fix this. @flavioayra just reported the same problem, finding "-" and "." in type/op names.

@fiorix fiorix closed this as completed in 8877781 Dec 29, 2017
@fiorix
Copy link
Owner

fiorix commented Dec 29, 2017

Should be good now.

@warroyo
Copy link

warroyo commented Feb 28, 2018

@fiorix i am still seeing this issue with "." in the name, was this added to fix "." or just "-"

here is an example file. it is from the F5 Networks WSDL. unfortunately they use "." all over the place.

for refrence here is the error

 generated bad code: 1182:16: expected type, found '.' (and 1 more errors)
    1180
 1181	// management.ResourceRecordPortType implements the ManagementResourceRecordPortType interface.
 1182	type management.ResourceRecordPortType struct {
 1183		cli *soap.Client
 1184	}
 1185

wsdl.txt

@fiorix
Copy link
Owner

fiorix commented Mar 1, 2018

I think I missed the "." in the regex that makes it a valid Go symbol:

var validGoSymbol = regexp.MustCompile(`[0-9_]*[^0-9a-zA-Z_]+`)

@warroyo
Copy link

warroyo commented Mar 1, 2018

@fiorix in this case the "." is actually invalid in the type name, i think that problem is that it is not using the validGoSymbol function when creating types

@fiorix fiorix reopened this Mar 14, 2018
@fiorix
Copy link
Owner

fiorix commented Mar 14, 2018

PR?

@prologic
Copy link

prologic commented Oct 3, 2022

@fiorix I'm also seeing this as well.

For example:

$ wsdl2go < ParseAddress.wsdsl > ParseAddr.go
2022/10/03 12:04:06 generated bad code: 3:13: expected ';', found '-'
    1	// Code generated by wsdl2go. DO NOT EDIT.
    2
    3	package plsp-public
...

This WSDL comes from: https://information.qld.gov.au/service/Addressing/ValidationService/PLSplusPublic/soap?wsdl

@prologic prologic linked a pull request Oct 3, 2022 that will close this issue
@prologic
Copy link

prologic commented Oct 3, 2022

#47 fixes a bunch of bugs I found with generating type names, method names and so on. This resolves my problem as well as the one found in this issue. I'm not happy with the code, but it generated valid Go code finally 😅

@prologic
Copy link

prologic commented Oct 3, 2022

FWW I achieved much better results by using the wsdlgen cli utility found in this package:

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

Successfully merging a pull request may close this issue.

4 participants