swagger-api / swagger-api/swagger-codegen

[PHP] perhaps Bug in __construct()

Open
#7,727 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

You must use attributeMap to find the good variable name.

Swagger-codegen version

lastest version

Swagger declaration file content or url

Hi,

https://api-docs.beezup.com/swagger.json

perhaps a bug in constructor variables assignation .
default generated code is by example in camelCase (bug also in snake_case):

$this->container['marketplaceTechnicalCode'] = isset($data['marketplaceTechnicalCode']) ? $data['marketplaceTechnicalCode'] : null;

instead of :

$this->container['marketplaceTechnicalCode'] = isset($data[self::attributeMap()['marketplaceTechnicalCode']]) ? $data[self::attributeMap()['marketplaceTechnicalCode']] : null;

You must use attributeMap to find the good variable name.

Suggest a fix/enhancement

in constructor

$this->container['{{name}}'] = isset($data[self::attributeMap()['{{name}}']]) ? $data[self::attributeMap()['{{name}}']] : null;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the PHP generator template or entry point that assembles the generated __construct() assignments, then compare its use of $data with attributeMap() for camelCase and snake_case output. Done means generated PHP clients use the mapped input name in the constructor, including for the provided BeezUP Swagger declaration.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.