Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9683
Closed
Open
Issue created Jun 05, 2021 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

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

Created by: 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
  • https://github.com/OpenAPITools/openapi-generator/pull/7598
  • https://github.com/OpenAPITools/openapi-generator/issues/7322
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)

Assignee
Assign to
Time tracking