OpenAPITools / OpenAPITools/openapi-generator
[BUG][PHP] Bug generate client or server PHP library with openapi-generator-online
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
I can't generate any PHP library with the openapi-generator-online, while I can with the CLI version.
The bug is the same for PHP client or server's framework (php-laravel, php-lumen, php-silex, php-slim, php-symfony, php-ze-ph).
The bug is present on both the online test server and my Docker's instance:
http://api.openapi-generator.tech/index.html
https://hub.docker.com/r/openapitools/openapi-generator
The displayed message is:
"{
"timestamp": "2019-10-29T09:19:38.809Z",
"status": 400,
"error": "Bad Request",
"message": "Unable to build target: null",
"path": "/api/gen/clients/php"
}"
The expected response should have been with a status 200 (we can see it if we try the "ada" language).
openapi-generator version
4.1.3 openapi-generator-online
OpenAPI declaration file content or url
This bug doesn't seem to be yaml oriented, but it can be easily reproduced with this one:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml
Command line used for generation
On the request "POST /api/gen/clients/{language}", use {language}="php" and:
"authorizationValue": {
"keyName": "string",
"type": "string",
"value": "string"
},
"openAPIUrl": "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml",
"options": {},
"securitySchemes": {
"description": "string",
"type": "string"
},
"spec": {}
}
Steps to reproduce
- Visit http://api.openapi-generator.tech/index.html
- Click on the line "POST /api/gen/clients/{language}"
- Put the value of "language" to "php"
- In the BodyData, change the parameter's name "securityDefinition" to "securitySchemes" (change introduced by OpenAPI 3.0):
- Click the button "Try"
- Observe the error you see only for the "php" language

Related issues/PRs
N/A
Suggest a fix
The only place in the code where this message can be returned seems to come from this file:
https://github.com/OpenAPITools/openapi-generator/blob/d7b390f328a597438edd6a72a9f1ff495ca7080a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java#L166
with an error between the line 153 and 159 (included).
The error comes from the line 166, because an element (the 28th) of the "List files" is null.
We can see it on this screenshot of a debug execution:
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 reproducing the PHP request against openapi-generator-online with the referenced petstore.yaml, then inspect modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java around line 166. Compare the online service path with CLI generation and trace why the generated file list contains null. Done means the PHP client and server requests return status 200 and generate successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java, openapi, php
- Domain
- api, backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100