[JavaJaxRS] Vendor Extensions Not Accessed in model.mustache
还没有人认领这个 Issue。
评估
调研方向
从 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
- Setup directory as shown above.
- 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.
- Update the licenseInfo template directly under jaxrs-cxf folder to the above reference, using the template variable (name) and the vendor extension (x-year).
- Import licenseInfo to model.mustache and api.mustache per the above reference.
- cd into the swagger folder and run the JAR from there.
- When you open the API file(s), you will see that the licenseInfo text is there, with the year and name.
- 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
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
swagger-api/swagger-codegen 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
swagger-api/swagger-codegen#12755 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
难度 1/5 1 小时以内 新手友好度 62/100
swagger-api/swagger-codegen#11942 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
swagger-api/swagger-codegen#11812 · 1 个 reaction ·
-
security vulnerability
难度 2/5 1-3 小时 新手友好度 65/100
swagger-api/swagger-codegen#11594 ·
查看 swagger-api/swagger-codegen 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
SciML/Evolutionary.jl#182 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
simonw/llm-mistral#43 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
rossoctl/context-guru#346 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
prime-radiant-inc/evener#2883 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
GoogleChromeLabs/project-sesame#216 ·
维护者通常 12 天内回复