Skip to content

[Java] Class name / file name casing mismatch for acronyms causes compilation failure #7654

@peombwa

Description

@peombwa

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Java

Describe the bug

The Java code generator produces files where the file name doesn't match the public class name inside, causing compilation to fail with:

error: class X is public, should be declared in a file named X.java

Acronyms (e.g., DLP, BI, MS365D) are likely cased inconsistently between JavaPathSegmenter.NormalizeFileName (which generates the file name) and CodeClassDeclarationWriter (which writes the class declaration). This results in 19 broken files under com.microsoft.graph.beta.models.security.

Expected behavior

The generated file name and public class name always match exactly.

How to reproduce

See microsoftgraph/msgraph-beta-sdk-java#1309 — Gradle Build, API Level Lint, and CodeQL all fail with 19 compileJava errors.

Open API description file

No response

Kiota Version

Microsoft.OpenApi.Kiota v1.31.1

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

N/A

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

Fix should normalize acronym casing on `CodeClass.Name` in `JavaRefiner.cs` or `JavaPathSegementer.cs`.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Needs Triage 🔍

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions