swagger-api / swagger-api/swagger-codegen
[PHP] ObjectSerializer.sanitizeForSerialization wrong Parameters
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated sanitizeForSerialization function in ObjectSerializer.php not compatible with the type & format parameters.
public static function sanitizeForSerialization($data, $format = null) {}
Inside the same static function we see the line.
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
The parameter swaggerType is wrongly assigned to format parameter.
Swagger-codegen version
swagger-codegen-cli-3.0.26.jar
Swagger declaration file content or url
{ "birth_date": { "type": "string", "format": "date" }, }
Command line used for generation
java -jar swagger-codegen-cli-3.0.26.jar generate -i swagger.json -l php -o .\ --model-package Api\Model --api-package Api --invoker-package App\Http\Controllers\Client
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 the generated ObjectSerializer.php and inspect sanitizeForSerialization, especially its type and format parameters and the recursive call shown in the report. Trace that generated output back to the PHP generator template, then verify generation with the supplied swagger declaration and command; done means the generated call preserves both the Swagger type and format.
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
- 42/100