Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6617
Closed
Open
Issue created Jun 10, 2020 by Administrator@rootContributor

[BUG] [PHP] Object of class stdClass could not be converted to string

Created by: michabbb

Bug Report Checklist

Description

generating the php classes of these open-api definitions: https://developer.ebay.com/api-docs/sell/analytics/overview.html

leads to a problem i have in ObjectSerializer.php
where i get the error:

Object of class stdClass could not be converted to string

openapi-generator version

tested: 3.3.4 (php5) and 4.3.1 (php7)

OpenAPI declaration file content or url

https://developer.ebay.com/api-docs/master/sell/analytics/openapi/3/sell_analytics_v1_oas3.yaml https://developer.ebay.com/api-docs/master/sell/analytics/openapi/3/sell_analytics_v1_oas3.json

Command line used for generation

generate -i /app/sell_analytics_v1_oas3.yaml -g php -o /app/ --config /app/openapi-config.php.ebay.analytics.json

Steps to reproduce

testing this code:

php7: https://github.com/michabbb/sdk-ebay-rest-analytics php5: https://github.com/michabbb/sdk-ebay-rest-analytics/tree/php5

for real testing, you need an eBay oauth code, then you can use the generated code like that:

$config = Configuration::getDefaultConfiguration()->setAccessToken($ebay_access_token);
        $apiInstance = new SellerStandardsProfileApi(null,$config);
        try {
            $result = $apiInstance->findSellerStandardsProfiles();
            +d($result);
        } catch (\Exception $e) {
            echo 'Exception when calling CustomerServiceMetricApi->getCustomerServiceMetric: ', $e->getMessage(), PHP_EOL;
        }

here you can see an example API result of findSellerStandardsProfiles

Suggest a fix

in ObjectSerializer.php line 299 where this code is in:

} elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
            settype($data, $class);
            return $data;
        }

i have to change:

} elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
            if ($data instanceof \stdClass) {
                settype($data,'array');
            } else {
                settype($data, $class);
            }
            return $data;
        }

that is a hack not a fix... i know... i don´t know whats wrong here.
thanks for any help!!!

Assignee
Assign to
Time tracking