OpenAPITools / OpenAPITools/openapi-generator
[BUG] [PHP] generated zend-expressive stub contains syntax errors when pattern of property ends with `*`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Generated zend-expressice stub contains syntax errors when pattern of property ends with *.
The pattern is embedded into annotation and breaks the DocComment.
This is also reproduced in the current sample.
https://github.com/OpenAPITools/openapi-generator/blob/cefd29b6ffc5933ef66de994ecd60128f42f39b7/samples/server/openapi3/petstore/php-ze-ph/src/App/DTO/InlineObject3.php#L75
openapi-generator version
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar version
4.0.0-SNAPSHOT
$ git log --oneline -n 1
cefd29b6ff (HEAD -> master, origin/master, origin/HEAD) [rust-server] Changed query parameters to be url encoded (#2136)
OpenAPI declaration file content or url
See: https://gist.github.com/autopp/472847da6c9de80450117a9cfecbc6d1#file-example-yml
Command line used for generation
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --skip-validate-spec -t modules/openapi-generator/src/main/resources/ze-ph -g php-ze-ph -o /tmp/php-ze-ph -i https://gist.githubusercontent.com/autopp/472847da6c9de80450117a9cfecbc6d1/raw/9ea6e9d6c0e3e9b724f92f2a52b76c7b42f8be29/example.yml
Steps to reproduce
- Run the above command to generate client code for Ruby.
- Run
php -l /tmp/php-ze-ph/src/App/DTO/InlineObject.phpto check syntax of the generated model code. - Get error in
src/App/DTO/InlineObject.php$ php -l /tmp/php-ze-ph/src/App/DTO/InlineObject.php Parse error: syntax error, unexpected '"', expecting function (T_FUNCTION) or const (T_CONST) in /tmp/php-ze-ph/src/App/DTO/InlineObject.php on line 15 Errors parsing /tmp/php-ze-ph/src/App/DTO/InlineObject.php
Related issues/PRs
N/A
Suggest a fix
Sorry, I have no idea. I don't know how to escape */ in a DocComment.
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 PHP generator templates under modules/openapi-generator/src/main/resources/ze-ph and compare them with samples/server/openapi3/petstore/php-ze-ph/src/App/DTO/InlineObject3.php. Reproduce the issue with the documented generation command, then run php -l on the generated DTO. Done means a property pattern ending in * no longer produces a PHP syntax error in the generated DocComment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, php
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100