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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for PR

why remove "implements CodegenConfig"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is that the class already extends DefaultCodegen, which itself implements the CodegenConfig interface. In Java, if a superclass implements an interface, any subclass automatically inherits that contract, so there’s no need to redundantly declare implements CodegenConfig in the subclass.

This change helps simplify the class declaration and avoids unnecessary repetition, while preserving all functionality and interface compliance. If you’d like confirmation or more detail, you can refer to the CodegenConfig interface and see that all generator classes in the repo follow this pattern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a search for extends DefaultCodegen implements CodegenConfig and found that pretty much all other generators are doing 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
Loading