Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG][Rust] "X cannot be used as a model name. Renamed to X" is logged on every lookup of a hyphenated name

Open Beginner friendly
#25,014 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java, rust
Domain
tooling

Research direction

Start with AbstractRustCodegen.sanitizeIdentifier and toModelName, then reproduce with the supplied pet-record OpenAPI YAML and Rust generation command. Done means the hyphenated name no longer produces a warning when the cased original and final name match, while genuine renames still warn and generated files remain identical.

Written by the indexing model from the issue text.

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
Description

AbstractRustCodegen.sanitizeIdentifier counts the hyphen and period replacement as a rename and then logs the cased original next to the result. For a name like pet-record both are PetRecord, so the warning carries no information, and toModelName goes through it every time a model name is resolved.

On GitHub's REST description (api.github.com.2022-11-28.json at github/rest-api-description@3cef12e8, 12 MB) the rust generator logs 6,961,556 of these warnings. 6,958,297 have the same name on both sides; the other 3,259 are real renames such as ApplicationJson cannot be used as a model name. Renamed to ApplicationSlashJson. The run takes 4 min 39 s and writes a 1.0 GB log. With the warning limited to real renames the same run takes 5.0 s, writes 2 MB of log, and generates identical files.

openapi-generator version

7.25.0, and master at 10e6c21.

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: hyphenated schema name
  version: "1"
paths:
  /pets:
    get:
      operationId: listPets
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/pet-record"
components:
  schemas:
    pet-record:
      type: object
      properties:
        name:
          type: string
Generation Details
java -jar openapi-generator-cli-7.25.0.jar generate -g rust -i spec.yaml -o out
Steps to reproduce

The command prints this line 16 times:

[main] WARN  o.o.c.languages.AbstractRustCodegen - PetRecord cannot be used as a model name. Renamed to PetRecord

Expected: no warning, since the name only changed case.

Suggest a fix

Warn only when the final name differs from the cased original.

Dominant language
Java
Stars
26.8k
Forks
7.7k
Avg merge
2d 13h
Merged PRs (30d)
103

Getting set up

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.

More from OpenAPITools/openapi-generator

All issues in OpenAPITools/openapi-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.