swagger-api / swagger-api/swagger-codegen
expose parentContainer to templates
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I'm extending the models generated from swaggers with a deepCopy() method for java. For this I need to generate code based on the property types, but in case the basetype is List or Map, the detailed type information is lost to the templates.
I propose exposing the "parentContainer" type in these cases similar to how "items" are exposed for container properties.
The proof-of-concept code is ready, I'll file a PR soon.
Swagger-codegen version
2.4.10, 2.4.11-SNAPSHOT (HEAD)
Swagger declaration file content or url
swagger: "2.0"
info:
version: "1.0.0"
title: "test"
paths: {}
definitions:
ArrType:
type: array
items:
type: string
format: date-time
Command line used for generation
java -jar ~/.m2/repository/io/swagger/swagger-codegen-cli/2.4.10/swagger-codegen-cli-2.4.10.jar generate -i testarr.yaml -l java -o /tmp/test -DdebugModels=true > logarr-orig.txt
java -jar ~/src/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i testarr.yaml -l java -o /tmp/test -DdebugModels=true > logarr.txt
Steps to reproduce
N/A
Related issues/PRs
The PR will include the fix for #9918
Suggest a fix/enhancement
will file a PR
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swagger definition in testarr.yaml and the Java CLI generation commands, then compare the attached debugModels outputs for the original and modified runs. Verify that generated templates can access parentContainer for List or Map properties and that Java generation still completes with the sample definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100