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

[JAVA] 3.0.65 java stub generates method with no return value for get endpoints if $ref is used

Aperta
#12,504 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
java, openapi
Ambito
tooling

Direzione di ricerca

Inizia riproducendo il problema con test.yaml e il comando CLI swagger-codegen indicato, quindi traccia la generazione Java per l’endpoint whateverGet e la response a cui fa riferimento. Il lavoro è completato quando una response $ref genera un tipo restituito e resp.getData() come in 3.0.64, senza introdurre regressioni negli schemi inline.

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

Descrizione

Description

With 3.0.65 the methods that are generated for get endpoints (havent checked others) are not returning anything. Same specs worked with 3.0.64.

The generated code looks like this:

    public void whateverGet() throws ApiException {
        whateverGetWithHttpInfo();
    }

while with 3.0.64:

    public InlineResponse200 whateverGet() throws ApiException {
        ApiResponse<InlineResponse200> resp = whateverGetWithHttpInfo();
        return resp.getData();
    }

If i put the schema directly, without using the $ref, the generated code is having the return statement.

Swagger-codegen version

3.0.65

Swagger declaration file content or url
openapi: 3.0.1
paths:
  /whatever:
    get:
      responses:
        "200":
          $ref: "#/components/responses/WhateverGetResponse"

components: 
  responses: 
    WhateverGetResponse:
      description: test
      content:
        application/json:
          schema:
            type: object
            properties:
              name:
                type: string
Command line used for generation

java -jar ~/Downloads/swagger-codegen-cli-3.0.65.jar generate -i test.yaml -l java -o ./debug -DhideGenerationTimestamp=true

Steps to reproduce

just generate with 3.0.65

Related issues/PRs
Suggest a fix/enhancement
Lingua principale
Mustache
Stelle
17.8k
Fork
6k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 swagger-api/swagger-codegen

Tutte le issue di swagger-api/swagger-codegen

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.