[BUG][Rust] "X cannot be used as a model name. Renamed to X" is logged on every lookup of a hyphenated name
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenAPITools/openapi-generator
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OpenAPITools/openapi-generator#24997 ·
Maintainers usually reply within 1 day
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24859 ·
Maintainers usually reply within 1 day
-
[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=trueOpenIssue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24842 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenAPITools/openapi-generator#24830 ·
Maintainers usually reply within 1 day
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenAPITools/openapi-generator#24816 · 1 comment ·
Maintainers usually reply within 1 day
All issues in OpenAPITools/openapi-generator
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oracle/javavscode#652 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
AloisSeckar/demos-java#380 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openhab/openhab-core#5847 ·
Maintainers usually reply within 1 day