OpenAPITools / OpenAPITools/openapi-generator

[REQ] basePackage option does not apply to apiPackage and modelPackage in kotlin-spring generator

Open
#21,249 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

When using the kotlin-spring generator, I noticed that setting the basePackage option does not automatically apply to apiPackage and modelPackage. I expected that specifying basePackage would serve as the root, and the generator would place APIs under basePackage.api and models under basePackage.model.

However, even when basePackage is set, I still have to manually define apiPackage and modelPackage. Otherwise, the generated files are not placed as expected. I'm wondering if this is an intentional behavior or an area that could be improved for consistency.

Describe the solution you'd like

I would like the generator to treat basePackage as the root namespace, so that:

  • API classes are generated under basePackage.api
  • Model classes are generated under basePackage.model

Unless explicitly overridden by apiPackage or modelPackage.

Describe alternatives you've considered

Additional context

If this behavior is intended for backward compatibility reasons, I understand that it might be difficult to change.
However, if it's by design, I would appreciate a brief explanation of the rationale behind it.

I am using OpenAPI Generator 7.4.0 with Gradle. This behavior was observed using the kotlin-spring generator. Making basePackage behave as a true base path would help simplify configuration and reduce duplication.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the kotlin-spring generator's handling of basePackage, apiPackage, and modelPackage, then locate the generator tests covering these options. Verify how defaults and explicit overrides are resolved. Done means basePackage supplies the .api and .model roots when those options are omitted, while explicit apiPackage or modelPackage values remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, openapi, spring
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.