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

[JavaJaxRS] Vendor Extensions Not Accessed in model.mustache

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

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

評価

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

調査の方向性

jaxrs-cxf templates から始め、特に licenseInfo.mustache、model.mustache、pojo.mustache に注目し、それらのレンダリングコンテキストを api.mustache および apiServiceImpl.mustache と比較してください。提供された OpenAPI YAML と swagger-codegen-cli-3.0.24 を使用して問題を再現してください。生成された model ファイルと POJO ファイルで、API ファイルと同様に、含まれている licenseInfo template から x-year がレンダリングされれば完了です。

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

説明

Description

When I update the licenseInfo.mustache template to reference vendor extensions and nest it in other templates, it works fine in files such as api.mustache, api_test.mustache, and apiServiceImpl.mustache. It does not output the value in model.mustache or pojo.mustache. Referencing included template variables (such as infoName) works fine.

Swagger-codegen version

swagger-codegen-cli-3.0.24 (cannot use latest at the moment due to Java version)

Swagger declaration file content or url

Unfortunately I cannot paste all of the code in here, but I can at least show how things are referenced/declared:
Folder structure:

swagger
    /gen
        /codegen
            swagger-codegen-cli-3.0.24.jar
        /templates
            /jaxrs-cxf
            <contents of JavaJaxRS folder from JAR file>
    /output
        /api
openapi: 3.0.1
x-year: 2025
info:
    name: Your Name
paths:

Declaration in licenseInfo.mustache:

{{vendorExtensions.x-year}}

Use of licenseInfo.mustache in model.mustache and api.mustache

{{>licenseInfo}}

config-api.json

{
    "hideGenerationTimestamp": true,
    "java8": true,
    "dateLibrary": "java8",
    "useSwaggerFeature": true,
    "modelPackage": "some.package.name",
    "apiPackage": "some.package.name",
    "invokerPackage": "some.package.name",
    "useOas2": false,
    "ignoreImportMappings": false,
    "importMappings": {
        "Set": "java.util.Set"
    },
    "addConsumesProducesJson": true
}
Command line used for generation
java -jar ./gen/codegen/swagger-codegen-cli-3.0.24.jar generate -D useGenericResponse=true -i swagger.yaml -t gen/templates/jaxrs-cxf -l jaxrs-cxf -o output/api -c config-api.json
Steps to reproduce
  1. Setup directory as shown above.
  2. Using any yaml file with a defined model, add the x-year property at the root level. Also, to show that included variables work fine, ensure to include info -> name in the yaml.
  3. Update the licenseInfo template directly under jaxrs-cxf folder to the above reference, using the template variable (name) and the vendor extension (x-year).
  4. Import licenseInfo to model.mustache and api.mustache per the above reference.
  5. cd into the swagger folder and run the JAR from there.
  6. When you open the API file(s), you will see that the licenseInfo text is there, with the year and name.
  7. When you open the model file, you will notice that the licenseInfo text is there, with the name, but minus the year. So, I think the import is working, but perhaps there's a vendor extension scoping issue somewhere?
Related issues/PRs

I didn't find anything similar.

Suggest a fix/enhancement

Fix the issue.

主要言語
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

Backend & API Design の issue をもっと見る

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

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