swagger-api / swagger-api/swagger-codegen
[PHP] oneOf at nullable objects: not uses FQCN
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The config used to generate the code contains this:
"invokerPackage": "Base\Sub",
In case of a nullable object property for example:
prop1:
nullable: true
oneOf:
- $ref: '#/components/schemas/Prop1'
The generated PHP code will contain the following:
protected static $swaggerTypes = [
'courier' => 'OneOfProp1'];
whereas it should contain this:
protected static $swaggerTypes = [
'courier' => '\Base\Sub\OneOfProp1'];
This causes the ObjectSerializer::deserialize to fail because the OneOfProp1 can't be found/loaded.
Swagger-codegen version
3.0.26
Command line used for generation
swagger-codegen generate -i apiContract/api.yaml -l php -c swaggerCodegenConfig.json -o ../generated/api-client
Suggest a fix/enhancement
Use the FQCN
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 locating the PHP generator template or entry point that produces the swaggerTypes mapping, then inspect how nullable oneOf properties are handled. Re-run the provided swagger-codegen command with the example configuration and verify that the generated type uses the invokerPackage FQCN and that ObjectSerializer::deserialize can load it.
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
- 45/100