swagger-api / swagger-api/swagger-codegen
[html2] When using array of objects, array initially renders as 'undefined'
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If there is a request or response that uses an array of non-primitives, the parameter for that request/response initially renders as an array with the contents of 'undefined'.
Swagger-codegen version
Using v2.3.1
Swagger declaration file content or url
This can be seen in the petstore example:
- path: /pet/findByTags
operations:
- method: GET
summary: Finds Pets by tags
notes: "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."
type: array
items:
$ref: Pet
nickname: findPetsByTags
produces:
- application/json
- application/xml
parameters:
- name: tags
description: Tags to filter by
required: true
allowMultiple: true
type: string
paramType: query
responseMessages:
- code: 400
message: Invalid tag value
deprecated: "true"
Command line used for generation
Using the 'html2' generation language
Steps to reproduce
Generate 'html2' output from a specification that includes an array of objects.
I have tested this with both a reference (the example above) and the explicit definition of the schema object in-line with the array definition, e.g.:
- path: /pet/findByTags
operations:
- method: GET
summary: Finds Pets by tags
notes: "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."
type: array
items:
type: "object"
properties:
propA:
type: "string"
propB:
type: "string"
nickname: findPetsByTags
produces:
- application/json
- application/xml
parameters:
- name: tags
description: Tags to filter by
required: true
allowMultiple: true
type: string
paramType: query
responseMessages:
- code: 400
message: Invalid tag value
deprecated: "true"
Related issues/PRs
I can't find any examples or mentions of this issue
Suggest a fix/enhancement
Seems to be a discrepancy with the ordering between parsing schema definitions and rendering parameters, since even an in-line schema object is loaded into the defs object.
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 by generating html2 output from the petstore example, focusing on the /pet/findByTags array of non-primitives and comparing referenced and inline object schemas. Trace how schema definitions are loaded before request and response parameters are rendered. Done means arrays of objects render their contents instead of 'undefined'.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100