Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa Adatta ai principianti
#25,014 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, rust
Ambito
tooling

Direzione di ricerca

Inizia con AbstractRustCodegen.sanitizeIdentifier e toModelName, quindi riproduci il comportamento con lo YAML OpenAPI pet-record fornito e il comando di generazione Rust. Il lavoro è completato quando il nome con trattino non produce più un avviso quando il nome originale, con la relativa distinzione tra maiuscole e minuscole, e il nome finale coincidono, mentre i rinomini effettivi continuano a produrre un avviso e i file generati rimangono identici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
26.8k
Fork
7.7k
Merge medio
1g 11h
PR unite (30g)
139

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenAPITools/openapi-generator

Tutte le issue di OpenAPITools/openapi-generator

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.