swagger-api / swagger-api/swagger-codegen

[lang php] allOf ignored

Open
#10,545 0 comments 0 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

GetSessionListResponse.yaml

description: Response for session list
allOf:
  - $ref: '../common/ApiResponse.yaml'
properties:
  response:
    $ref: '../../models/system/SessionList.yaml'

Variants without ref also don't works:

description: Response for session list
allOf:
  - type: object
    properties:
      success:
        type: boolean
      errors:
        type: array
        items:
          type: object
          properties: {}
      response:
        type: object
        properties: {}
  - type: object
    properties:
      response:
        type: object
        properties:
          memory:
            type: string

ApiResponse.yaml

type: object
properties:
  success:
    type: boolean
  errors:
    type: array
    items:
      type: object
      properties: {}
  response:
    type: object
    properties: {}

But generated with ignored properties success and errors from allOf: - $ref: '../common/ApiResponse.yaml':

GetSessionListResponse.md
# GetSessionListResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**response** | [**\Model\SessionList**](SessionList.md) |  | [optional]

[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

But if I use --lang openapi-yaml then all ok. Generated:

components:
  schemas:
    GetSessionListResponse:
      properties:
        response:
          $ref: '#/components/schemas/SessionList'
      description: Response for session list
      allOf:
      - $ref: '#/components/schemas/ApiResponse'

And correct documentation generated in https://editor.swagger.io/
image

Swagger-codegen version

swagger-codegen-cli-3.0.22.jar and swagger-codegen-cli-3.0.23.jar

Swagger declaration file content or url
openapi: 3.0.1
info:
  title:
  version:
servers:
- url:

paths:
  /system/getSessionList:
    get:
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSessionListResponse'
components:
  schemas:
    GetSessionListResponse:
      description: Response for session list
      allOf:
      - $ref: '#/components/schemas/ApiResponse'
      - type: object
        properties:
          response:
            $ref: '#/components/schemas/SessionList'
    ApiResponse:
      type: object
      properties:
        success:
          type: boolean
        errors:
          type: array
          items:
            type: object
            properties: {}
        response:
          type: object
          properties: {}
    SessionList:
      type: object
      properties:
        sessions:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Session'
        memory:
          type: string
    Session:
      type: object
      properties:
        session:
          type: string
Command line used for generation
docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate --input-spec /local/openapi.yaml --lang php --output /local/out/ -c /local/openapi-codegen-php.json
docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate --input-spec /local/openapi.yaml --lang openapi-yaml --output /local/out/ -c /local/openapi-codegen-php.json
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the issue with openapi.yaml and the swagger-codegen-cli 3.0.22 or 3.0.23 PHP command, then compare its output with the openapi-yaml generation. Start by locating the PHP generator's handling of the GetSessionListResponse allOf schema; done means the generated PHP documentation includes the inherited success and errors properties.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.