Skip to content

[BUG] Kotlin code generator does not follow Java convention for sanitizing model names #9683

Open
@tmeneau

Description

@tmeneau

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

The Kotlin code generator currently sanitizes model names using the DefaultCodeGen.specialCharReplacement map, which deviates from how other code generators generate model names (such as java) and results in Kotlin model and file names being generated with unexpected words interposed: MyMinusApiMinusRequestMinusObject.

That said, this behavior is validated in the AbstractKotlinCodegenTest tests, so I was wondering if there's any particular reason to break the convention for Kotlin? If not I'd love to submit a PR to change this!

openapi-generator version

Version 5.1.1 (master)

Steps to reproduce
  1. Copy the AbstractJavaCodegenTest#convertModelName tests to the AbstractKotlinCodegenTest#convertModelName tests
  2. Run the unit tests;
  3. Validate that they fail.
Related issues/PRs
Suggest a fix

This is an easy fix (replace this line with a call to sanitizeName(name)). I'm happy to submit a PR if there wasn't any particular reason to deviate from convention here!

cc @jimschubert @Zomzog (please let me know if I should be CC-ing anyone else)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions