-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
Generate backed enums from XSD #561
Conversation
ae96bd9
to
e6959a3
Compare
This PR makes it possible to generate PHP enums directly from the WSDL. Can you try to run it on your services to see how that works for you? |
Tried regenerating with enums and it works. I don't have complex schemas with 'local' enums, but what I do have works fine. And enum case generation is rather beautiful. 😁 |
Hi, I've tested the code on the scheme with multiple local enums and ran into some name conflicts (unlucky, the WSDL is not public). The only other framework that generates local enums (what I know) is svcutil. To reduce conflicts, they prepend the name of the parent type to the enum name. Example XSD:
The output enum would be called PersonGender. Nevertheless, it's an awesome addition to this framework. |
Prepending the parent type’s name is actally a nice strategy. |
It should be fairly easy to add indeed. |
@MudrakIvan It turns out prepending the type name is not as straight forward as I first though... @rauanmayemir The |
This PR will generate PHP backed enum types for XSD enumerations:
It splits the generated TypeMap into 2 sections:
You can regenerate your existing classmap like this:
Which will be used by the generated Client Factory:
The generated property types will now contain a link to the generated backed enum type:
Which will then be used to power the encoding package:
❗ Local enumerations ❗
Your XSD might contain types that contains their own enumerations that are not available as global schema simple-types:
Since these types don't really have a global name and might conflict with other types in your schema, we decided to only generate global types by default. In this case, the code will keep on generating the list of possible values inside the docblocks on the property.
If you DO want to opt-in to local enumeration generation, you can do so from within the code generation config. As mentioned before : this might be conflicting with other parts of the XSD, so use with care !