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

PHP client Class '\Swagger\Client\Model\Object' not found #1503

Closed
bthibault opened this issue Nov 3, 2015 · 8 comments
Closed

PHP client Class '\Swagger\Client\Model\Object' not found #1503

bthibault opened this issue Nov 3, 2015 · 8 comments
Milestone

Comments

@bthibault
Copy link

i'm getting PHP Fatal error: Class '\Swagger\Client\Model\Object' not found in vendors/SwaggerClient-php/lib/ObjectSerializer.php on line 211

There are nested object types in the return object and I think somehow its looking for a generic Object.

@bthibault
Copy link
Author

on commit 7ac91ce

@bthibault
Copy link
Author

It looks like bare json ints are getting parsed and set to type Model/Object in the php

"phone": {
"name": "H258C",
"features": "",
"pk": 2127,
"devicemcd": "3001",
"carrierfk": 4570,
"phonetypefk": 1
}

devicemcd gets set to type "string"
carrierfk gets set to type "Model/Object" which doesn't exist

@wing328
Copy link
Contributor

wing328 commented Nov 4, 2015

@bthibault do you have the swagger spec that you can share with us to reproduce the issue? please also make sure you're using the latest version (master)

FYI. We already have some test cases to cover deserialization: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php#L98

@bthibault
Copy link
Author

swagger spec :

{"apiVersion":"2.0","swaggerVersion":"1.2","basePath":"/","resourcePath":"/phone","apis":[{"path":"/phone/{phoneId}","operations":[{"method":"GET","summary":"Returns a phone based on ID","notes":"","type":"PhoneMerged","nickname":"PhoneGetRoute","parameters":[{"name":"phoneId","description":"ID of phone that needs to be fetched","required":true,"type":"integer","format":"int32","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":200,"message":"Ok"}]}]}],"models":{"FeaturesvaluepairSimple":{"id":"FeaturesvaluepairSimple","properties":{"featuretype":{"type":"string"},"feature":{"type":"string"}}},"FeaturesSimple":{"id":"FeaturesSimple","properties":{"feature":{"type":"string"}}},"PhoneMerged":{"id":"PhoneMerged","properties":{"phone":{"$ref":"Phone"},"carrier":{"$ref":"Carrier"},"features":{"type":"array","items":{"$ref":"FeaturesSimple"}},"featurevaluepairs":{"type":"array","items":{"$ref":"FeaturesvaluepairSimple"}},"accessories":{"type":"array","items":{"$ref":"IncludedaccessorySimple"}},"image":{"$ref":"PhoneImage"}}},"IncludedaccessorySimple":{"id":"IncludedaccessorySimple","properties":{"accessory":{"type":"string"}}},"Phone":{"id":"Phone","properties":{"pk":{"$ref":"Object"},"name":{"type":"string"},"features":{"type":"string"},"carrierfk":{"$ref":"Object"},"phonetypefk":{"$ref":"Object"},"devicemcd":{"type":"string"}}},"PhoneImage":{"id":"PhoneImage","properties":{"url":{"type":"string"}}},"Carrier":{"id":"Carrier","properties":{"pk":{"type":"integer","format":"int64"},"carrierName":{"type":"string"}}}}}

so I guess the problem is $ref: Object

cc: @wing328

@wing328
Copy link
Contributor

wing328 commented Nov 4, 2015

Yes, $ref refers to "Object" which is not defined.

May I know how you obtain the Swagger spec? Using some third-party plug-ins?

@bthibault
Copy link
Author

spray swagger plugin

"com.gettyimages" %% "spray-swagger" % "0.5.1"

So this is through Scala / Slick / Spray the items getting defined as $ref: Object are defined by scala case classes as Option[Long] so the Scala option is probably throwing it off.

@wing328
Copy link
Contributor

wing328 commented Nov 4, 2015

I would suggest you to report the issue to https://github.com/gettyimages/spray-swagger/issues.

Another approach is you manually update the Swagger spec with properly-defined models.

@bthibault
Copy link
Author

Yeah I'm manually updating for now...apparently there is already an open ticket : gettyimages/spray-swagger#31

THanks for helping me track this down.

@fehguy fehguy modified the milestone: v2.1.5 Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants