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-fastapi] fastapiImplementationPackage ignores packageName option in favor of the "openapi_server.impl" default package name #20063

Open
4 of 6 tasks
andremueller-cosateq opened this issue Nov 8, 2024 · 1 comment

Comments

@andremueller-cosateq
Copy link

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

When running the openapi-generator with the argument

All generated apis Python files will import

import openapi_server.impl

instead of the expected

import my_package.impl

I did not provide an example swagger.yml file as this is a general problem for arbitrary files.

openapi-generator version

v7.9.0

Generation Details
generate -i swagger.yml \
                  -g python-fastapi \
	          -o out \
	          --additional-properties=packageName=my_package
Suggest a fix

I think the following line within modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\PythonFastAPIServerCodegen.java could fix for that (or the documentation of python-fastapi generator should be adapted):

    @Override
    public void processOpts() {
        super.processOpts();

        if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
            setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
        }

should read

    @Override
    public void processOpts() {
        super.processOpts();
        if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
            setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
            this.implPackage = ((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)).concat(".impl");
        }
@wing328
Copy link
Member

wing328 commented Nov 8, 2024

can you please file a PR with the suggested fix 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

No branches or pull requests

2 participants