swagger-api / swagger-api/swagger-codegen
DefaultGenerator ignores return value of postProcessOperations and postProcessOperationsWithModels
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The postProcessOperations and postProcessOperationWithModels in the CodegenConfig are called by the DefaultGenerator (line 930 and 931 of DefaultGenerator.java swagger-codegen-3.0.4). We can work around it by changing the input map but this is not desirable.
There is also a problem with the following method in DefaultGenerator:
private void generateModels(List<File> files, List<Object> allModels) {
...
}
This method possible changes the allModels via the post processed model methods in the config classes. This method must be changed to return the (possibly) mutated models so that the subsequent generateApis method can consume it in the postProcessedOperationsWithModels method.
Swagger-codegen version
3.0.4 - not a regression just a programming error
Swagger declaration file content or url
Not a bug - code problem
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
- Change the two lines to add local variables to these methods:
Map<String, Object> postProcessedOperations = config.postProcessOperations(operations);
postProcessedOperations = config.postProcessOperationsWithModels(postProcessedOperations, allModels);
- Change the private method generateModels to
private Map<String, Object> generateModels(List<File> files, List<Object> allModels) {
...
}
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 in DefaultGenerator.java around lines 930-931 and inspect how CodegenConfig.postProcessOperations and postProcessOperationsWithModels are called. Trace generateModels and generateApis to confirm how the possibly mutated models flow between them. Done means the returned post-processed maps and models are consumed by subsequent generation steps, with relevant existing tests or generation checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100