swagger-api / swagger-api/swagger-codegen

expose parentContainer to templates

Open
#9,926 0 comments 0 reactions 0 assignees View on GitHub

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

logarr-orig.txt
logarr.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.