Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !1099

[Python] Commenting supportsInheritance is enabling the model properties inhe…

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/narenandu/python_codegen_model_inheritence_fix into master 6 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: narenandu

@wing328

CC'ing technical committee: @taxpon @frol @mbohlool @cbornet @kenjones-cisco to review the pull request if your PR is targeting python programming language.

Description of the PR

It is kind of counter intuitive, but setting supportsInheritance = true is failing to get the properties from the parent when a child model inherits. Didn't dive deep in to the actual base class for the code generation, but commenting out the line from PythonClientCodegen.java fixed the issue.

This solves the reported issues

  • https://github.com/OpenAPITools/openapi-generator/issues/453 (@poli-granot)
  • https://github.com/OpenAPITools/openapi-generator/issues/623 (@emreakca)

There could be multiple reasons since I didn't go to the root cause

  • First that there is no AbstractPyCodegen.java, which might/might not tackle the issue
  • Second, we don't know if other code gen for other languages are working since, they also are using supportsInheritence = true in their generation code. Just to quote a few
    • AbstractJavaCodegen (@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger )
    • JavascriptClientCodegen (@CodeNinjai @frol @cliffano)
    • CSharpClientCodegen / AbstractCSharpCodegen.java (@mandrean @jimschubert)
    • AbstractKotlinCodegen (@jimschubert @dr4ke616)
Compare
  • master (base)

and
  • latest version
    390f3eea
    1 commit, 2 years ago

1 file
+ 2
- 1

    Preferences

    File browser
    Compare changes
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java
+ 2
- 1
  • View file @ 390f3eea


@@ -68,7 +68,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
// at the moment
importMapping.clear();
supportsInheritance = true;
// Commenting supportsInheritance is enabling the model properties inheritence properly from parent model
//supportsInheritance = true;
modelPackage = "models";
apiPackage = "api";
outputFolder = "generated-code" + File.separatorChar + "python";
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: Java Enhancement: Feature
2
Client: Java Enhancement: Feature
    Assign labels
  • Manage project labels

Milestone
5.0.0
5.0.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: OpenAPITools/openapi-generator!6912
Source branch: github/fork/narenandu/python_codegen_model_inheritence_fix

Menu

Explore Projects Groups Snippets