swagger-api / swagger-api/swagger-codegen

php 7 symfony bug with array

Open
#10,821 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

if you create an object list:

Foo:
   type: object
   properties:
     list:
       type: array
       items:
         $ref: "#/definitions/Bar"
 Bar:
   type: object
   properties:
     name:
       type: string

the generation with param -l php-symfony
will create for "Foo" a method

/**
     * Sets list.
     *
     * @param App\Model\SW\Bar[]|null $list
     *
     * @return $this
     */
    public function setList(Bar $list = null)
    {
        $this->list = $list;

        return $this;
    }

this method setList(Bar $list = null) is wrong for PHP 7 because the argument should be "array" instead of "Bar"

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

Start with the php-symfony generator entry point selected by -l php-symfony and reproduce the provided Foo/Bar schema. Inspect how the generated setList signature is chosen for array properties. Done means the generated setter accepts an array rather than Bar for the listed object array case.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.