swagger-api / swagger-api/swagger-codegen

[PHP] oneOf miss mapping types

Open
#10,896 2 comments 2 reactions 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

This problem appeared also in javascript.

Generation sdk for file creates invalid EmailResponse model.

oneOf:
        - $ref: '#/components/schemas/CheckIfEmailExistResult'
        - $ref: '#/components/schemas/MailboxvalidatorResult'
        - $ref: '#/components/schemas/PromptEmailVerificationApiResult'

Types and formats were not generated in EmailResponse.

/**
  * Array of property to type mappings. Used for (de)serialization
  *
  * @var string[]
  */
protected static $swaggerTypes = [
        ];

/**
  * Array of property to format mappings. Used for (de)serialization
  *
  * @var string[]
  */
protected static $swaggerFormats = [
        ];
Swagger-codegen version

3.0.24

Swagger declaration file content or url

https://github.com/go-email-validator/email-validator-sdk/blob/e99fe82d3c9d6d520687cf499688112e86acfe03/ev.openapiv3.yaml#L227

Command line used for generation
  docker run --rm -v ${PWD}/php:/local/out -v $(OPENAPI_PATH):/local/openapi.yaml swaggerapi/swagger-codegen-cli-v3:latest generate \
    -i /local/openapi.yaml \
    -l php \
    -o /local/out/

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 with the referenced ev.openapiv3.yaml oneOf declaration at line 227 and the generated php/SwaggerClient-php/lib/Model/EmailResponse.php output. Reproduce generation with the documented Docker command and inspect how the PHP generator handles this schema; done means EmailResponse contains the expected type and format mappings for the oneOf entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, php
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.