swagger-api / swagger-api/swagger-codegen
[HTML2] enum element is missing in schemas
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Schema attributes with enum options e.g.
"type": {
"enum": [
"option1",
"option2"
],
"type": "string"
}
generate following html element:

However, if parent attribute is collapsed, Enum element is missing (if the schema is big enough some attributes may be collapsed by default).
Here another related issue is raised:
Children of array schema will never be collapsed (not-array schema children on 3rd "depth level" and deeper will be collapsed by default).
Swagger-codegen version
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.33</version>
Swagger declaration file content or url
Example json declaration file that reproduces the problem:
https://gist.github.com/pakhopav/b0bd9b5bdfe388a244e4e39463af6b21
Command line used for generation
mvn -f pom-generators.xml io.swagger.codegen.v3:swagger-codegen-maven-plugin:generate
Steps to reproduce
Generate html page using declaration file provided by the gist link above.
You will see 2 similar schemas: first one is array (uncollapsed, with Enum element) and second one is not array (collapsed and without Enum elemnent)
Related issues/PRs
Suggest a fix/enhancement
Change the logic in mustaches files that add html elements depending on whether the schema is collapsed.
Mustaches files:
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/htmlDocs2/js_jsonschemaview.mustache
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
Reproduce the missing Enum element with the linked JSON declaration and the Maven generation command. Start with modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache and js_jsonschemaview.mustache, then compare the array and collapsed non-array schemas. Done means the generated HTML retains the Enum element when the parent attribute is collapsed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, javascript
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100