swagger-api / swagger-api/swagger-codegen
[PHP-client] int[] paramater types leads to errors
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When using the below mentioned generated client, some methods require int[] as type. However if i follow the generated documentation
it either gives me syntax error, unexpected '[', expecting ')' when i use
$ids = array(new \Swagger\Client\Model\int[]());
or it gives me Exception: Invalid resource type: array when i try something like this:
$ids = array(231431321,3231433141342);
From what i can see, an int[] class is not generated anywhere?
Edit 1:
array(231431321) works fine with codegen v 2.2.1
Swagger-codegen version
2.3.1 and 2.4.0_SNAPSHOT
Swagger declaration file content or url
https://esi.evetech.net/latest/swagger.json
Command line used for generation
java -jar $swagger generate -i https://esi.evetech.net/latest/swagger.json?datasource=tranquility -l php --git-repo-id "esi-php-client" --git-user-id "jbs1" --release-note "$msg"
Suggest a fix/enhancement
Found a solution. this error seems to come from the GuzzleHttp client.
To fix it, the array, that is given to generated methods with int[] parameters, simply needs to be a json:
$ids = json_encode(array(new \Swagger\Client\Model\int[]()));
So just the generation for the documentation needs to be changed, to make it clear to encode the array.
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 documentation in docs/Api/UniverseApi.md, especially the POST universe names parameter example, and compare it with the PHP client behavior described in the issue. Update the example so array parameters are documented in the form the generated client accepts, then verify the corrected example against the referenced ESI Swagger definition and generated client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, php
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100