OpenAPITools / OpenAPITools/openapi-generator

[BUG] [python-flask] member variable incorrect

Open
#5,907 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Python
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

member variable incorrect

openapi-generator version

v4.3.0

OpenAPI declaration file content or url
openapi: 3.0.0

info:
  version: "1.0.0"
  title: "Test"

paths:
  /in:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/C'
components:
  schemas:
    A:
      type: object
      properties:
        a:
          type: string
    B:
      type: object
      properties:
        b:
          type: string
      allOf:
      - $ref: '#/components/schemas/A'
    C:
      type: object
      properties:
        c:
          type: string
      allOf:
      - $ref: '#/components/schemas/B'
Command line used for generation

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.0 generate -i /local/x.yaml -g python-flask -o /local/out/python -Dmodels

Steps to reproduce
  1. save spec file as x.yaml in current directory
  2. run command above
  3. cat out/python/openapi_server/models/c.py only member variable a/c in class C
  4. paste spec file into http://editor.swagger.io/ all member variable a/b/c in class C
Related issues/PRs

Maybe the same issue? https://github.com/OpenAPITools/openapi-generator/issues/927

Suggest a fix

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 the provided OpenAPI YAML and the python-flask generator command, then inspect the generated out/python/openapi_server/models/c.py. Compare class C with the inherited properties shown in Swagger Editor, especially a, b, and c. Done means the generated C model includes all inherited member variables and the relevant regression behavior is covered.

Written by the indexing model from the issue text.

Assessment

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