Skip to content

[BUG][python-experimental] API imports may be incorrectly formatted #7187

Description

@timgclark

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

For all models of a specific format, we're seeing duplicate, invalid imports added to APIs by the python-experimental generator.

openapi-generator version

OpenAPITools/openapi-generator/master

OpenAPI declaration file content or url
    fruit.SeedDescriptor:
      title: Fruit:Seed Descriptor
      description: |-
        Descriptor to uniquely identify a fruit seed.
      allOf:
      - # This 'fruit.SeedDescriptor' class inherits all properties from its parent class fruit.ComponentDescriptor.
        $ref: '#/components/schemas/fruit.ComponentDescriptor'
$ grep Descriptor ./api/fruit_api.py
from grocery.model.fruit_seed_descriptor import FruitSeedDescriptor
from grocery.model.fruit_seed_descriptor_response import FruitSeedDescriptorResponse
from grocery.model.fruit_peel_descriptor import FruitPeelDescriptor
from grocery.model.fruit_peel_descriptor_response import FruitPeelDescriptorResponse
...
from grocery.model.fruit_seed_descriptor import fruit.SeedDescriptor
from grocery.model.fruit_peel_descriptor import fruit.PeelDescriptor
Generation Details

java -Dorg.openapitools.codegen.utils.namecache.cachesize=10000 -Dorg.openapitools.codegen.utils.namecache.expireafter.seconds=120 -jar .build/sdk/openapi-generator-cli.jar generate -c python-experimental.yaml -i ../.build/doc/openapi.yaml -g python-experimental -o .build/sdk/fruit [--enable-post-process-file]

Steps to reproduce
Related issues/PRs

This started at some point after #7054 merged

Suggest a fix

#7186 does appear to fix this specific issue. I'm not sure if that's the best possible solution, nor do I have a good concrete unit test case to offer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions