swagger-api / swagger-api/swagger-codegen

[PHP] oneOf at nullable objects: not uses FQCN

Open
#11,143 0 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.