swagger-api / swagger-api/swagger-codegen

[Python] Swagger 2.0 - 2.4.23 cannot generate allOf types

Open
#11,225 1 comment 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

I generate REST clients against swagger/openapi v2.0

  • Using swagger-codegen-cli:2.4.8 we get a class "DataDaily" (see json below) with all attributes.
  • Using 2.4.23 we only get the properties immediately under "DataDaily", not respecting the properties in "DataRef"
Swagger-codegen version
  • Using 2.4.23
  • This is a regression from version 2.4.8
Swagger declaration file content or url
    "DataDaily": {
      "allOf": [
        {
          "$ref": "#/definitions/DataRef"
        },
        {
          "type": "object",
          "required": [
            "timestamp",
            "asOfDate"
          ],
          "properties": {
            "seriesId": {
              "title": "seriesId",
              "type": "string"
            },
            "timestamp": {
              "type": "string",
              "format": "date-time"
            },
            "asOfDate": {
              "type": "string",
              "format": "date-time"
            }
          }
        }
      ]
    },
Command line used for generation

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli:2.4.23 generate -i http://internalserver/swagger/v2.0/swagger.json -l python -o /local -c /local/generate/config.json

config.json only contains information on package version.

Steps to reproduce
  • Create a route returning an allOf type
  • Generate Python client using command above
Related issues/PRs

Not that I could find.

Suggest a fix/enhancement

Previous behavior (e.g. 2.4.8) seemed reasonable.

Edit: I found the breakage occurs between 2.4.14 and 2.4.15

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

Use the provided Swagger v2.0 allOf declaration and Docker command to reproduce generation with swagger-codegen-cli 2.4.23, then compare it with 2.4.8 and the reported 2.4.14–2.4.15 boundary. Done means the generated Python client includes DataRef properties in DataDaily while retaining its direct properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.