Skip to content

[BUG][Python] python-fastapi 7.9.0 generates wrong imports #20153

@al3ad

Description

@al3ad

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

An import is generated that does not exist.

openapi-generator version

7.9.0

OpenAPI declaration file content or url

The code for the yaml spec can be found here: https://github.com/bbc/tams/tree/main/api

Generation Details

This is a snippet of the file it generates with the relevant to the issue imports:

from pydantic import ConfigDict, Field
from openapi_server.models.object import object
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class MediaBucketObjectStore(object):
    ...

The issue is the imported object, which doesn't exist.

I believe the generated file should be this:

from pydantic import ConfigDict, Field, BaseModel
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class MediaBucketObjectStore(BaseModel):
    ...
Steps to reproduce
build-server-local-fastapi:
	docker run --user ${USER}:${GROUP} --rm \
                   -v ${PWD}:/local openapitools/openapi-generator-cli:v${GEN_VER} generate \
				   --additional-properties=apiNameSuffix=controller_impl \
                   -t /local/.templates/7.9.0/python_fastapi/.openapi-generator-server/ \
                   -i /local/openapi.yaml \
                   -g python-fastapi \
                   -o /local/python_fastapi/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    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