Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Python] python-fastapi 7.9.0 generates imports of UNKNOWN_BASE_TYPE #20154

Closed
5 of 6 tasks
al3ad opened this issue Nov 21, 2024 · 3 comments · Fixed by #20165
Closed
5 of 6 tasks

[BUG][Python] python-fastapi 7.9.0 generates imports of UNKNOWN_BASE_TYPE #20154

al3ad opened this issue Nov 21, 2024 · 3 comments · Fixed by #20165

Comments

@al3ad
Copy link

al3ad commented Nov 21, 2024

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

Generated files have an unknown_base_type import.

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 tests/test_default_controller_impl:

# coding: utf-8

from fastapi.testclient import TestClient


from openapi_server.models.collection_item import CollectionItem  # noqa: F401
#from openapi_server.models.one_of_video_flow_audio_flow_data_flow_multi_essence_flow import OneOfVideoFlowAudioFlowDataFlowMultiEssenceFlow  # noqa: F401
from openapi_server.models.unknownbasetype import UNKNOWN_BASE_TYPE  # noqa: F401


def test_flows_created_post(client: TestClient):
    """Test case for flows_created_post

    
    """
    unknown_base_type = openapi_server.UNKNOWN_BASE_TYPE()

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/
@wing328
Copy link
Member

wing328 commented Nov 21, 2024

thanks for reporting the issue.

can you please test it with the python client generator as well to see if there are similar import issues?

please also use v7.10.0 which is the latest stable version released a few days ago.

@al3ad
Copy link
Author

al3ad commented Nov 22, 2024

Hi, can confirm that this issue still persists with the difference of if in 7.9.0 the generated file is:

# coding: utf-8

from fastapi.testclient import TestClient


from openapi_server.models.collection_item import CollectionItem  # noqa: F401
#from openapi_server.models.one_of_video_flow_audio_flow_data_flow_multi_essence_flow import OneOfVideoFlowAudioFlowDataFlowMultiEssenceFlow  # noqa: F401
from openapi_server.models.unknownbasetype import UNKNOWN_BASE_TYPE  # noqa: F401


def test_flows_created_post(client: TestClient):
    """Test case for flows_created_post

    
    """
    unknown_base_type = openapi_server.UNKNOWN_BASE_TYPE()

then in 7.10.0 it's:

# coding: utf-8

from typing import ClassVar, Dict, List, Tuple  # noqa: F401

from openapi_server.models.collection_item import CollectionItem
from openapi_server.models.one_of_video_flow_audio_flow_data_flow_multi_essence_flow import OneOfVideoFlowAudioFlowDataFlowMultiEssenceFlow
from openapi_server.models.unknownbasetype import UNKNOWN_BASE_TYPE


class BaseDefaultControllerImpl:
    subclasses: ClassVar[Tuple] = ()

    def __init_subclass__(cls, **kwargs):
        super().__init_subclass__(**kwargs)
        BaseDefaultControllerImpl.subclasses = BaseDefaultControllerImpl.subclasses + (cls,)
    async def flows_created_post(
        self,
        unknown_base_type: ,
    ) -> None:
        ...

Thanks for the reply, @wing328

@wing328
Copy link
Member

wing328 commented Nov 24, 2024

thanks for reporting the issue

should be fixed via #20165

please give it a try later with the latest master or snapshot version when you've time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants