swagger-api / swagger-api/swagger-codegen

[Spring] Codegen 2.2.2 does not render objects comprised by allOf and containing additionalProperties:

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

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

help wanted Issue: Bug Server: Spring
主要言語
Mustache
スター
17.8k
フォーク
6k
PR マージ指標
30日以内にマージされた PR はありません

説明

Description

When running Codegen 2.2.2 to render Spring objects, when the object has a definition using the allOf schema attribute and also the additionalProperties attribute, the rendered Java object contains no members at all.

Swagger-codegen version

swagger-codegen-cli-2.2.2.jar

Swagger declaration file content or url
  DynamicAccountModel:
    allOf:
      - properties:
          accountId:
            type: string
            description: Account ID
      - additionalProperties:
          type: string
Command line used for generation
java -jar ../tools/swagger-codegen-cli-2.2.2.jar generate -i allof-no-render.yaml -l spring -o target
Steps to Reproduce

Execute above command.

Note that the class contains neither derives from HashMap (due to having the additionalParameters attribute) nor contains an accountId member.

package com.foo.bar;

import java.util.Objects;
import java.io.Serializable;
import javax.validation.constraints.*;
/**
 * DynamicAccountModel
 */
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-03-30T07:57:06.421-04:00")

public class DynamicAccountModel  implements Serializable {

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    return Objects.hash();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class DynamicAccountModel {\n");

    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

まず、提供された allOf/additionalProperties YAML に対して、ドキュメント化された swagger-codegen-cli-2.2.2 コマンドを実行し、生成された Spring Java クラスを調べます。このモデルを担当する Spring generator のパスを追跡します。完了の条件は、クラスに accountId が含まれ、空のオブジェクトを生成するのではなく、説明どおりに追加プロパティを処理することです。

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

評価

技術スタック
java, spring
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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