swagger-api / swagger-api/swagger-codegen
[PHP] Quotes in enum values are not escaped
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If enum values contain single quotes the codegen generates not valid PHP code.
Swagger-codegen version
2.4.0
Swagger declaration file content or url
{
"swagger":"2.0",
"info": {
"title": "Foo",
"version": "1.0.0"
},
"paths": {
},
"definitions": {
"Foo": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Foo 'bar'"
]
}
}
}
}
}
Command line used for generation
docker run --rm --volume=$PWD:/app --workdir=/app swaggerapi/swagger-codegen-cli generate \
--input-spec ./swagger.json \
--lang php
Generated PHP-file contains syntax error
<?php
namespace Swagger\Client\Model;
class Foo implements ModelInterface, ArrayAccess
{
...
const TYPE_FOO_BAR = 'Foo 'bar''; // unescaped quotes
...
}
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 by running the documented Docker generation command with the provided Swagger definition and PHP output. Trace the PHP generator entry point and the template that emits enum constants, then verify that the generated Foo class contains valid escaping for the quoted enum value and can be parsed as PHP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100