Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import static org.openapitools.codegen.utils.StringUtils.*;

public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {
public class StaticHtml2Generator extends DefaultCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(StaticHtml2Generator.class);

protected String invokerPackage = "org.openapitools.client"; // default for Java and Android
Expand Down Expand Up @@ -141,6 +141,8 @@ public String getTypeDeclaration(Schema p) {
return super.getTypeDeclaration(p);
}



@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap operations = objs.getOperations();
Expand Down Expand Up @@ -288,6 +290,44 @@ public String escapeUnsafeCharacters(String input) {
return input;
}

@Override
public String getSchemaType(Schema p) {
String schemaType = super.getSchemaType(p);

// For oneOf schemas, provide a more human-readable format for HTML display
if (schemaType != null && schemaType.startsWith("oneOf<") && schemaType.endsWith(">")) {
// Extract the types inside oneOf<...> and format them as "Type1 or Type2"
String innerTypes = schemaType.substring(6, schemaType.length() - 1);
String[] types = innerTypes.split(",");
List<String> formattedTypes = new ArrayList<>();

for (String type : types) {
String trimmedType = type.trim();
// Convert technical names to more readable ones
if ("object".equals(trimmedType)) {
formattedTypes.add("Object");
} else if ("string".equals(trimmedType)) {
formattedTypes.add("String");
} else if ("integer".equals(trimmedType)) {
formattedTypes.add("Integer");
} else if ("number".equals(trimmedType)) {
formattedTypes.add("Number");
} else if ("boolean".equals(trimmedType)) {
formattedTypes.add("Boolean");
} else if ("array".equals(trimmedType)) {
formattedTypes.add("Array");
} else {
// Capitalize first letter for other types
formattedTypes.add(trimmedType.substring(0, 1).toUpperCase() + trimmedType.substring(1));
}
}

return String.join(" or ", formattedTypes);
}

return schemaType;
}

@Override
public GeneratorLanguage generatorLanguage() {
return null;
Expand Down