[JavaJaxRS] Vendor Extensions Not Accessed in model.mustache
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con las plantillas de jaxrs-cxf, especialmente licenseInfo.mustache, model.mustache y pojo.mustache, y compara su contexto de renderizado con api.mustache y apiServiceImpl.mustache. Reproduce el problema usando el YAML de OpenAPI proporcionado y swagger-codegen-cli-3.0.24. La tarea estará terminada cuando x-year se renderice desde la plantilla licenseInfo incluida en los archivos model y POJO generados, tal como lo hace en los archivos API.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Mustache
- Estrellas
- 17.8k
- Forks
- 6k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de swagger-api/swagger-codegen
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
swagger-api/swagger-codegen#12755 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
swagger-api/swagger-codegen#11942 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
swagger-api/swagger-codegen#11812 · 1 reacción ·
-
security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
swagger-api/swagger-codegen#11594 ·
Todos los issues de swagger-api/swagger-codegen
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
microsoft/magentic-ui#588 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
alexgorbatchev/simple-ptt#3 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
CorrelAid/formtransform#44 ·