swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[HTML2] enum element is missing in schemas

Open pakhopav opened this issue 3 years ago • 0 comments

Description

Schema attributes with enum options e.g.

   "type": {
     "enum": [
       "option1",
       "option2"
     ],
     "type": "string"
   }

generate following html element: image 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

pakhopav avatar Sep 16 '22 11:09 pakhopav