goetas-webservices / xsd2php

Convert XSD into PHP classes and JMS serializer definitions
MIT License
236 stars 90 forks source link

Trying to convert OAS but getting "can't find type errors" #82

Open WillemRoman opened 5 years ago

WillemRoman commented 5 years ago

I'm getting the following errors trying to convert OAS 2017A specification:

In SchemaReader.php line 1024:

  Can't find type named {}#POS_Type, at line 1 in /Users/kazimi/Downloads/2017A_10_Publication/OpenTravel_2017A_XML/OTA_AirCheckIn.xsd  

In Schema.php line 100:

  Can't find the Type named {}#POS_Type.  

Config:

# config.yml

xsd2php:
  namespaces:
    'http://www.opentravel.org/OTA/2003/05': 'App\Services\OAS'
  destinations_php: 
    'App\Services\OAS': app\Services\OAS
  destinations_jms:
    'App\Services\OAS': app\Services\OAS
  naming_strategy: long

Versions:

goetas-webservices/xsd-reader      v0.3.4     Read any XML Schema (XSD) programmatically with PHP
goetas-webservices/xsd2php         v0.3.4     Convert XSD  (XML Schema) definitions into PHP classes and JMS metadata
goetas-webservices/xsd2php-runtime v0.2.9     Convert XSD  (XML Schema) definitions into PHP classes

Would be great if you could help me out!

Kalyse commented 5 years ago

@WillemRoman Got a similar issue. What was your resolution?

goetas commented 5 years ago

It looks that the OTA Common.xsd was not imported. Make sure that your XSD loads it

Kalyse commented 5 years ago

It looks that the OTA Common.xsd was not imported. Make sure that your XSD loads it

That's exactly what I was thinking. I've been trying to generate the XSD from the 2014B OTA specification. (Which I attached)
2014B_10_Publication.zip

Upon running:

 ./bin/xsd2php  convert src/App/Providers/IntegrationBundle/Resources/config/xsd2php.yml src/App/Providers/IntegrationBundle/Resources/schema/*.xsd

The follow error is returned:

In SchemaReader.php line 1024:
  Can't find type named {}#POS_Type, at line 1 in /var/www/symfony/src/App/Providers/IntegrationBundle/Resources/schema/OTA_AirCheckIn.xsd
In Schema.php line 100:
  Can't find the Type named {}#POS_Type.

This made me think that perhaps the "OTA_AirCheckIn.xsd" does not load the Common.xsd. I can see that it does, however it's through a nested include.

vr4_0776

Which then eventually loads it via: <xs:include schemaLocation="OTA_CommonTypes.xsd"/>

vr4_098a

You can see the XSD I'm trying to generate from. I've just extracted the entire XSD, however, I'm really only interested in the OTA_Hotel*

I really don't have any idea how to continue investigations on this.

root@43f6889c4f4b:/var/www/symfony# composer info | grep xsd
Do not run Composer as root/super user! See https://getcomposer.org/root for details
goetas-webservices/xsd-reader            v0.3.4                Read any XML Schema (XSD) programmatically with PHP
goetas-webservices/xsd2php               v0.3.4                Convert XSD  (XML Schema) definitions into PHP classes and JMS metadata
goetas-webservices/xsd2php-runtime       v0.2.9                Convert XSD  (XML Schema) definitions into PHP classes

I've tried many variations of the following:

# config.yml
# Linux Users: PHP Namespaces use back slash \ rather than a forward slash /
# So for destinations_php, the namespace would be TestNs\MyApp

xsd2php:
    namespaces:
        '': 'App\Providers\IntegrationBundle\Outgoing\OTA\Model'
        'http://www.w3.org/2001/XMLSchema' :   'App\Providers\IntegrationBundle\Outgoing\OTA\Model'
        'http://www.opentravel.org/OTA/2003/05': 'App\Providers\IntegrationBundle\Outgoing\OTA\Model'
        'http://www.opentravel.org/OTA/2003/05/common' : 'App\Providers\IntegrationBundle\Outgoing\OTA\Model'
    destinations_php:
        'App\Providers\IntegrationBundle\Outgoing\OTA\Model': src/App/Providers/IntegrationBundle/Outgoing/OTA/Model
    destinations_jms:
        'App\Providers\IntegrationBundle\Outgoing\OTA\Model': src/App/Providers/IntegrationBundle/Resources/serializer/OTA
    naming_strategy: short
    path_generator: psr4
WillemRoman commented 5 years ago

I still have exactly the same issue as @Kalyse , any idea @goetas ? It seems that the OTA common are included in the XSD files but happenend to not be loaded within the converter script. Thanks a lot in advance!

Kalyse commented 5 years ago

I'm not able to look at this, but just before I finished for work on Friday, I decided to stop trying to convert everything, and instead only convert the OTA_*RS.xsd and OTA_RQ.xsd.

The reasoning what that those XSD should contain everything anyway. This succeeded. However, I have not had any chance to actually check if it's worked because I was finishing work.

You might want to try that. Let me know how you get on...