Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#12,504 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
java, openapi
領域
tooling

調査の方向性

まず test.yaml と記載されている swagger-codegen CLI コマンドで問題を再現し、次に whateverGet エンドポイントと、それが参照する response の Java 生成を追跡します。$ref の response が 3.0.64 と同様に戻り値の型と resp.getData() を生成し、inline schema に回帰がない状態を完了とします。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Mustache
スター
17.8k
フォーク
6k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

swagger-api/swagger-codegen のほかの issue

swagger-api/swagger-codegen の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。