swagger-api / swagger-api/swagger-codegen
[PHP] Wrong arrays of objects code generation
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
php-symfony for server generates wrong type hinting for setter method when array of object required. This could be found in samples provided by codegen: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php#L230
public function setTags(Tag $tags = null) // << should be an array
{
$this->tags = $tags;
return $this;
}
Swagger-codegen version
Both master and 3.0.0.
Swagger declaration file content or url
Pet:
id: Pet
description: "A pet is a person's best friend"
required:
- id
- name
properties:
id:
type: integer
format: int64
tags:
type: array
items:
$ref: Tag
Tag:
id: Tag
properties:
name:
type: string
id:
type: integer
format: int64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php and the Pet/Tag schema shown in the issue. Trace the PHP Symfony generator template that produces setTags; done means the generated setter correctly represents an array of Tag objects, with the sample or relevant generator test regenerated to verify the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100