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-Symfony] Wrong type hint in model setter #1272

Closed
LudoMon opened this issue Oct 19, 2018 · 0 comments · Fixed by #1453
Closed

[PHP-Symfony] Wrong type hint in model setter #1272

LudoMon opened this issue Oct 19, 2018 · 0 comments · Fixed by #1453

Comments

@LudoMon
Copy link
Contributor

LudoMon commented Oct 19, 2018

Description

I use the php-symfony generator to generate some models.
One of them has an array property, that contains objects

When I generate the model, the generated setter has the wrong typehint:

    /**
     * Sets myProp.
     *
     * @param \MyNamespace\MyObject[] $myProp
     *
     * @return $this
     */
    public function setMyProp(MyObject $myProp)
    {
        $this->myProp= $myProp;

        return $this;
    }

The method expects an array of objects, the generated PhpDoc is right but not the type hint

openapi-generator version

3.3.2-SNAPSHOT

OpenAPI declaration file content or url
    MyArray:
      type: object
      required:
      - myProp
      properties:
        myProp:
          type: array
          items:
            $ref: "#/components/schemas/MyObject"
Command line used for generation

java -jar /opt/openapi-generator-cli/openapi-generator-cli.jar generate
-DsrcBasePath=app/src
-DvariableNamingConvention=camelCase
-DphpLegacySupport=false
-Dmodels
-DmodelTests=false
-DmodelDocs=false
--invoker-package MyPackage
--model-package MyModelPackage
--model-name-suffix DTO
-i openapi.yaml
-g php-symfony
-o /var/project

LudoMon added a commit to LudoMon/openapi-generator that referenced this issue Nov 15, 2018
A model with an array property used to have the wrong PHP typehint in
the setter: the array item object type instead of "array"
wing328 pushed a commit that referenced this issue Nov 18, 2018
A model with an array property used to have the wrong PHP typehint in
the setter: the array item object type instead of "array"
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
A model with an array property used to have the wrong PHP typehint in
the setter: the array item object type instead of "array"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants