swagger-api / swagger-api/swagger-codegen

[HTML] If top level element is in array inside model object, static html generator is not generating model body

Open
#6,974 1 comment 2 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

If top level element is an array inside model, model object is generated as empty.

Swagger-codegen version

2.2.3

Swagger declaration file content or url
{
  "swagger":"2.0",
  "definitions": {
    "nls_1.0_deploymentContainers": {
      "items": {
        "type": "string"
      }, 
      "type": "array"
    }
  }, 
  "paths": {
    "/test": {
      "get": {
        "responses": {
          "200": {
            "description": "Accepted", 
            "schema": {
              "$ref": "#/definitions/nls_1.0_deploymentContainers"
            }
          }
		}
      }
    }
  }
}
Command line used for generation

swagger-codegen generate -l html -i

Steps to reproduce

Just use above command.

Related issues/PRs
Suggest a fix/enhancement

In DefaultCodegen.class:1305 we need to add values to m.vars variable.

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 DefaultCodegen.class around line 1305 and reproduce the issue using the supplied Swagger JSON and the swagger-codegen generate -l html command. Trace how the array definition affects m.vars; done means the generated HTML model body is populated rather than empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.