|
39 | 39 |
|
40 | 40 | import static org.openapitools.codegen.utils.StringUtils.*; |
41 | 41 |
|
42 | | -public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig { |
| 42 | +public class StaticHtml2Generator extends DefaultCodegen { |
43 | 43 | private final Logger LOGGER = LoggerFactory.getLogger(StaticHtml2Generator.class); |
44 | 44 |
|
45 | 45 | protected String invokerPackage = "org.openapitools.client"; // default for Java and Android |
@@ -141,6 +141,8 @@ public String getTypeDeclaration(Schema p) { |
141 | 141 | return super.getTypeDeclaration(p); |
142 | 142 | } |
143 | 143 |
|
| 144 | + |
| 145 | + |
144 | 146 | @Override |
145 | 147 | public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) { |
146 | 148 | OperationMap operations = objs.getOperations(); |
@@ -288,6 +290,44 @@ public String escapeUnsafeCharacters(String input) { |
288 | 290 | return input; |
289 | 291 | } |
290 | 292 |
|
| 293 | + @Override |
| 294 | + public String getSchemaType(Schema p) { |
| 295 | + String schemaType = super.getSchemaType(p); |
| 296 | + |
| 297 | + // For oneOf schemas, provide a more human-readable format for HTML display |
| 298 | + if (schemaType != null && schemaType.startsWith("oneOf<") && schemaType.endsWith(">")) { |
| 299 | + // Extract the types inside oneOf<...> and format them as "Type1 or Type2" |
| 300 | + String innerTypes = schemaType.substring(6, schemaType.length() - 1); |
| 301 | + String[] types = innerTypes.split(","); |
| 302 | + List<String> formattedTypes = new ArrayList<>(); |
| 303 | + |
| 304 | + for (String type : types) { |
| 305 | + String trimmedType = type.trim(); |
| 306 | + // Convert technical names to more readable ones |
| 307 | + if ("object".equals(trimmedType)) { |
| 308 | + formattedTypes.add("Object"); |
| 309 | + } else if ("string".equals(trimmedType)) { |
| 310 | + formattedTypes.add("String"); |
| 311 | + } else if ("integer".equals(trimmedType)) { |
| 312 | + formattedTypes.add("Integer"); |
| 313 | + } else if ("number".equals(trimmedType)) { |
| 314 | + formattedTypes.add("Number"); |
| 315 | + } else if ("boolean".equals(trimmedType)) { |
| 316 | + formattedTypes.add("Boolean"); |
| 317 | + } else if ("array".equals(trimmedType)) { |
| 318 | + formattedTypes.add("Array"); |
| 319 | + } else { |
| 320 | + // Capitalize first letter for other types |
| 321 | + formattedTypes.add(trimmedType.substring(0, 1).toUpperCase() + trimmedType.substring(1)); |
| 322 | + } |
| 323 | + } |
| 324 | + |
| 325 | + return String.join(" or ", formattedTypes); |
| 326 | + } |
| 327 | + |
| 328 | + return schemaType; |
| 329 | + } |
| 330 | + |
291 | 331 | @Override |
292 | 332 | public GeneratorLanguage generatorLanguage() { |
293 | 333 | return null; |
|
0 commit comments