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

It does not seem to like "xsd:anyType" and Include #14

Open
PRTGC opened this issue May 31, 2023 · 1 comment
Open

It does not seem to like "xsd:anyType" and Include #14

PRTGC opened this issue May 31, 2023 · 1 comment

Comments

@PRTGC
Copy link

PRTGC commented May 31, 2023

Hi...
I'm trying to generate from the vmware vim25 wsdl..

The structures from the included files do not always get generated

         <include schemaLocation="core-types.xsd" />
pub type HostConnectFaultFault = HostConnectFault;
error[E0412]: cannot find type `HostConnectFault` in this scope
   --> src\vim25.rs:637:34
    |
637 | pub type HostConnectFaultFault = HostConnectFault;
    |                                  ^^^^^^^^^^^^^^^^ not found in this scope

It has a lot of structs based on 'xsd:anyType:

   <complexType name="DynamicArray">
      <sequence>
         <element name="val" type="xsd:anyType" maxOccurs="unbounded" />
      </sequence>
   </complexType>
   <complexType name="DynamicData">
      <sequence>
      </sequence>
   </complexType>
   <complexType name="DynamicProperty">
      <sequence>
         <element name="name" type="xsd:string" />
         <element name="val" type="xsd:anyType" />
      </sequence>
   </complexType>
   <complexType name="ArrayOfDynamicProperty">
      <sequence>
         <element name="DynamicProperty" type="vim25:DynamicProperty" minOccurs="0" maxOccurs="unbounded" />
      </sequence>
   </complexType>
   <complexType name="KeyAnyValue">
      <complexContent>
         <extension base="vim25:DynamicData">
            <sequence>
               <element name="key" type="xsd:string" />
               <element name="value" type="xsd:anyType" />
            </sequence>
         </extension>
      </complexContent>
   </complexType>

Which produces:

pub struct DynamicProperty {
	#[yaserde(rename = "name", prefix = "nsi2", default)]
	pub name: String, 
	#[yaserde(rename = "val", prefix = "nsi2", default)]
	pub val: AnyType, 
}
  --> src\vim25.rs:121:11
    |
121 |     pub val: AnyType, 
    |              ^^^^^^^ not found in this scope

Any thoughts on work-arrounds ?
Thanks
JR

@mibes404
Copy link
Owner

Hi JR,

Unfortunately the yaserde framework does not seem to support an Any type (or something similar to Value in serde_json).

This means you need to create structs for these fields by hand.

To get the code to compile, you can include a minimal AnyType:

#[derive(Debug, Default, YaSerialize, YaDeserialize, Clone)]
pub struct AnyType;

You may try an upstream feature request to include support for such a field type.

Kind regards,
Marcel

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

2 participants