Skip to content

[BUG] allOf which consists only one element(ref) are generated new model not using exist model #16047

Closed

Description

@y-chan

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

allOf which consists only one element(ref) are generated new model not using exist model.

In below example, Mora interface == AccentPhrasePauseMora interface.

image
openapi-generator version

latest master brunch

OpenAPI declaration file content or url
JSON
{
   "openapi":"3.0.2",
   "info":{
      "title":"VOICEVOX Engine",
      "description":"VOICEVOXの音声合成エンジンです。",
      "version":"latest"
   },
   "paths":{
      "/accent_phrases":{
         "post":{
            "tags":[
               "クエリ編集"
            ],
            "summary":"テキストからアクセント句を得る",
            "description":"テキストからアクセント句を得ます。\nis_kanaが`true`のとき、テキストは次のようなAquesTalkライクな記法に従う読み仮名として処理されます。デフォルトは`false`です。\n* 全てのカナはカタカナで記述される\n* アクセント句は`/`または`、`で区切る。`、`で区切った場合に限り無音区間が挿入される。\n* カナの手前に`_`を入れるとそのカナは無声化される\n* アクセント位置を`'`で指定する。全てのアクセント句にはアクセント位置を1つ指定する必要がある。\n* アクセント句末に`?`(全角)を入れることにより疑問文の発音ができる。",
            "operationId":"accent_phrases_accent_phrases_post",
            "parameters":[
               {
                  "required":true,
                  "schema":{
                     "title":"Text",
                     "type":"string"
                  },
                  "name":"text",
                  "in":"query"
               },
               {
                  "required":true,
                  "schema":{
                     "title":"Speaker",
                     "type":"integer"
                  },
                  "name":"speaker",
                  "in":"query"
               },
               {
                  "required":false,
                  "schema":{
                     "title":"Is Kana",
                     "type":"boolean",
                     "default":false
                  },
                  "name":"is_kana",
                  "in":"query"
               },
               {
                  "required":false,
                  "schema":{
                     "title":"Core Version",
                     "type":"string"
                  },
                  "name":"core_version",
                  "in":"query"
               }
            ],
            "responses":{
               "200":{
                  "description":"Successful Response",
                  "content":{
                     "application/json":{
                        "schema":{
                           "title":"Response Accent Phrases Accent Phrases Post",
                           "type":"array",
                           "items":{
                              "$ref":"#/components/schemas/AccentPhrase"
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   },
   "components":{
      "schemas":{
         "AccentPhrase":{
            "title":"AccentPhrase",
            "required":[
               "moras",
               "accent"
            ],
            "type":"object",
            "properties":{
               "moras":{
                  "title":"モーラのリスト",
                  "type":"array",
                  "items":{
                     "$ref":"#/components/schemas/Mora"
                  }
               },
               "accent":{
                  "title":"アクセント箇所",
                  "type":"integer"
               },
               "pause_mora":{
                  "title":"後ろに無音を付けるかどうか",
                  "allOf":[
                     {
                        "$ref":"#/components/schemas/Mora"
                     }
                  ]
               },
               "is_interrogative":{
                  "title":"疑問系かどうか",
                  "type":"boolean",
                  "default":false
               }
            },
            "description":"アクセント句ごとの情報"
         },
         "Mora":{
            "title":"Mora",
            "required":[
               "text",
               "vowel",
               "vowel_length",
               "pitch"
            ],
            "type":"object",
            "properties":{
               "text":{
                  "title":"文字",
                  "type":"string"
               },
               "consonant":{
                  "title":"子音の音素",
                  "type":"string"
               },
               "consonant_length":{
                  "title":"子音の音長",
                  "type":"number"
               },
               "vowel":{
                  "title":"母音の音素",
                  "type":"string"
               },
               "vowel_length":{
                  "title":"母音の音長",
                  "type":"number"
               },
               "pitch":{
                  "title":"音高",
                  "type":"number"
               }
            },
            "description":"モーラ(子音+母音)ごとの情報"
         }
      }
   }
}
Generation Details

execute:

./mvnw clean package
java -jar  -Dfile.encoding=UTF-8 modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
    -i test.json \
    -g typescript-fetch \
    -o test/ \
    --additional-properties "modelPropertyNaming=camelCase,supportsES6=true,withInterfaces=true,typescriptThreePlus=true"
Steps to reproduce
  1. copy and paste json as test.json.
  2. execute command at Generation Details
Related issues/PRs

#16035 (comment)

Suggest a fix

I will search how to fix.

Activity

  1. wing328 commented on Jul 14, 2023

    @wing328
    Member

    @y-chan I've filed #16096 to fix the issue.

    Can you please pull the branch to give it a try to see if it fixes the issue for your use cases? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions